OWADVL
OWADVL

Reputation: 11154

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

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

Upvotes: 8

Views: 639

Answers (2)

Mikhail
Mikhail

Reputation: 898

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.

Upvotes: 3

scb
scb

Reputation: 46

I got the same problem and ended up solving it client-side by setting a certain context. I have an older bot that doesn't have the "Stories" interface, so this solution may not apply to your case, but maybe it is of some help.

  1. When the bot sends an open question, it should also set a special context i.e. open_question_xyz or something like that, and send it back to the client app.
  2. When the client app receives the context, save it to some var.
  3. Before processing the next user input, your app first checks if the open_context_xyz var is set, and if it is, instead of sending the query directly to wit.ai, it captures the raw text, and also sets a context like resolved_open_question_xyz so the bot knows where to pick up the conversation.

Upvotes: 2

Related Questions