Understanding context and responding accordingly

(Vila Vg) #1

Hi there,

Assuming i have a bot that has 2-3 different fruits like apple, orange and banana. Each product has certain attributes like weight and calories count etc. Now if a user has selected a product like orange, then if the user type weight, is it possible for the bot to understand that based on the user’s most recent choice of fruit ie. orange, that the value to respond with is the weight of the orange and not the weight of the banana or apple which it might if keyword matching was in play.

Thanks!

(Karen Barker) #2

Hi there,

You’d need to use the Ask a Question service to ask the user which fruit, followed asking another question of what data they want to know about the fruit. The users answers to these questions will be accessibile throughout the flow. You could then use the answers given to do a lookup (database search?) to get the answers and display to the user.

(Vila Vg) #3

HI @KarenBaker,

Does that mean that the keyword listener is different per flow? so If i user is in the “apple” flow, and typed calories, it will only return calories for the apple?

also, after that if the user types “banana” or “banana calories” i’d like to return banana calories even if it means they’re in the apple flow?

Thanks

(Karen Barker) #4

Hi,

I was imagining a single flow. It could be triggered on a keyword of say “Information”. You then ask the user 2 questions - 1) What Fruit?
2) Information type?
Then have a lookup to your database to get that information to return to the user in a message.

You could use our Flow GoTo labels if you wanted to be able to go back and forward to different parts in the flow.
If you offer shortcut buttons on messages to ask the user whether they’d like more information same fruit, query a different fruit etc.

(Vila Vg) #5

Hi Karen,

that’s not a very desired flow from the perspective of the user. I mean that the bot needs to automatically infer that because the user chose banana any following queries are in context of the banana rather than throwing up options and choices over and over. any other solution?

(Vila Vg) #6

@KarenBarker just picking this up again, is there a way to accomplish the following for context:

step1 ask user what kind of fruit they prefer >
step2 user picks banana
step 3 any subsequent questions the user asks are answered specifically about the banana.

the user can tap on a quick reply to **change fruit ** and go to step 1 and pick a different fruit.

Is this achievable?

(Vila Vg) #7

@KarenBarker @johnjackson any further inputs would be very helpful!

I found a library on GitHub that might help with context. The creator of the library also had some comments on how to integrate it with FLowXO but I could use some help on this further please

Here’s the issue on GitHub: https://github.com/ashubham/bot-context/issues/1

and a sample of the code usable via webhooks:

(Karen Barker) #8

Hi there,

My first reply here using the go to labels could still work without you needing to use an external library.

In my first reply I outlined a flow as following:
I was imagining a single flow. It could be triggered on a keyword of
say “Information”. You then ask the user 2 questions - 1) What Fruit?
2) Information type?
Then have a lookup to your database to get that information to return to the user in a message.

You could use our Flow GoTo labels if you wanted to be able to go back and forward to different parts in the flow.
If
you offer shortcut buttons on messages to ask the user whether they’d
like more information same fruit, query a different fruit etc.

If you’d like the fruit to be implied, then you could have your label just before point 2 and pass the value of question one back through using metadata key value pairs. That way you would only be asking them for the next item of information they require.

Without putting the bot into a question asking mode the bot will not understand what the user is asking and therefore won’t be able to respond correctly.

From what I can tell with the library on GitHub it would create a very similar flow to doing the above. :pensive: