Reputation: 316
I'm writing a bot powered by wit.ai and want to figure out how to do it right. I followed the documentation, but there are some gaps.
I'm interested in particular case when in the first message I have only "intent" and in the second user message I have only "taste" (or two). Wit.ai api sometimes returns "stop" and doesn't jump to getCocktail execution.
How should I keep context of the dialogue to show that intent is still "cocktail"? Should I store it in context object?
Upvotes: 1
Views: 433
Reputation: 41
At your 'getCocktail' function code, you need to update your conversation context with the keys that corresponde ('cocktail', or 'no-taste'). Depending on what key you set in your context, is how the conversation flow will go on Wit.
You can see an example that validates if an email is valid here: https://stackoverflow.com/a/40933658/6664102 . If its not valid it sets a 'bad-email' key in the context, so then at Wit.ai you can define a conversation flow in the case the user input is an invalid email. Its similar to your use case (instead of adding a 'bad-email' context key, you add a 'no-taste' key into the context.
You can find more info about context on wit docs: https://wit.ai/docs/recipes#manage-context-and-session-id
Hope this helps a bit,
Best,
Emiliano.
Upvotes: 1