Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wit.ai capture free text from whatever the user gives you

Tags:

wit.ai

I have the following problems. I have several points into the conversation where I have to capture "free" text. Ex: what are your thoughts on xyz ? why do you want xyz ?... They are opened questions and the user can answer whatever they want.

How to I enable this ? because I tried different combinations and the bot either repeats some questions or skips some ?

Thank you

like image 787
OWADVL Avatar asked Sep 27 '16 14:09

OWADVL


1 Answers

If you're using the converse api you can try to set a corresponding context property before you send the response back to wit.ai and then use the updated context in your story.

For instance, I created a test story for you (the app is empty - just created the whole thing from scratch): story screenshot

As the result I was able to get into this point during the conversation: conversation

So what you need to do is to define an action like captureUserInput in my example and instruct your bot to await for a certain key in your context. In my example it's represented by the user_input key.

In your client app, you need to react to a corresponding action (captureUserInput in my example) appropriately. When sending the POST to wit.ai converse API set the corresponding key. For instance:

$ curl -XPOST 'https://api.wit.ai/converse?v=20160526&session_id=some_session_id' \
  -d '{"user_input":"put what the user responded here"}' \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H 'Authorization: Bearer $TOKEN'

The wit.ai engine should capture your context and take it into account when responding back to you (like This is what you said: {user_input} in my example)

I hope this will work for you. I based my findings on the following: https://wit.ai/docs/quickstart - see the step 4 and the wit.ai reference for the converse api.

like image 50
Mikhail Avatar answered Sep 21 '22 10:09

Mikhail