1

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.

The story looks like this: example of story

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?

green-creeper
  • 316
  • 3
  • 15

1 Answers1

1

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.

Community
  • 1
  • 1
  • Thanks Emiliano, I do this. But what's in case if only first message has intent? Should I set it in context to have it during next steps of dialogue? – green-creeper Dec 02 '16 at 15:49
  • @green-creeper i believe, yes, you should persist your intent on the context conversation. Also, in your second example where you have two tastes entities i think it would be a good idea to apply/use roles in that case: https://wit.ai/docs/recipes#differentiate-several-entities-according-to-their-role-in-the-message . Best, Emiliano. – Emiliano Dalla Verde Marcozzi Dec 06 '16 at 18:44
  • @green-creeper did you solve this using the context? I'm having similar problems. – André Dec 15 '16 at 13:36
  • @André Not yet. I made a new story where I pass required intent in any conditions, just guess that particular story should have same intent all the way long. I'm building wit.ai java library, so it takes longer – green-creeper Dec 16 '16 at 16:14