Wednesday, August 31, 2016

BotKit Questionnaires

questionnaires are the ChatBot equivalent of forms, where user interaction is better served with simple UI elements such as buttons.
A questionnaire is a list of questions of various types that Eva will ask the end user. As a questionnaire is an interactive message it can only be the last in the list of returned messages and there can only be a single interactive message in the list.
To request asking the end user questions, return the following interactive message from any applicative webhook:

The "_type" of the message is always: "QuestionnaireEvent"

"questionnaireAnsweredHook" is an enumeration of the webhook to call when the questions have all been answered. "payload" is an object that will be added to the payload of the "questionnaireAnsweredHook".

"questionnaireAbortedHook" has the same structure of a "questionnaireAnsweredHook". A "questionnaireAbortedHook" will be called if the validation of an open "QuestionMessage" fails three times.
This key is optional.

Send 1 or more questions, of any of the supported types in the list of "questions".
In this example there are 3 questions.
Each question has a "name" which will be the key of the result in the payload to be delivered to the "questionnaireAnsweredHook".

The 1st question in the example is an EmailQuestion.
The open reply will be validated using a built-in regular expression for email addresses.
Eva will then send out an email to the designated address to make sure the submitted email is valid and owned by the end user!
The 2nd question in the example is a multiple choice question, typed "MultiChoiceQuestion" with 3 choices.

The 3rd question in the example is an open question for which you may request a validation regular expression.

As usual, this functionality works across all messaging platforms! Facebook Messenger, Telegram, Kik, Line, Skype etc.

Detailed docs can be found here:

Happy Botting!

No comments:

Post a Comment