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: http://docs.evature.com/botkit.html#interactive-message-questionnaires

Happy Botting!

Sunday, August 7, 2016

BotKit OAuth Login

When a user starts a conversation with your business, you may want to identify her as a customer who already has an account with your business. To help with this, we have created a platform-agnostic secured protocol to link and unlink the messaging end-user identity with your business user identity.

OAuth-style LogIn allows you to invite users to log-in using your existing authentication flow thus to provide a more secure, personalized and relevant experience to users.

To request a Log In return a special message of type LoginOAuthEvent from any applicative webhook.
As this 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.

Here is an example of such a reply:

{
    "botkitVersion": "0.3.0", 
    "messages": [
        {
            "_type": "LoginOAuthEvent", 
            "loginSuccessHook": {
                "webhook": "flight_boarding_pass"
            }, 
            "text": "Please Login in first", 
            "webLoginUrl": "https://chat.evature.com/demo_login"
        }
    ]
}
  • _type - Must be LoginOAuthEvent
  • loginSuccessHook - a JSON object with either webhook - an enumeration of an existing webhook, or url
  • text - any text message - mandatory.
  • webLoginUrl -  a URL to the web login page.
The end user will be presented with a log in request. Once she clicks on it she will be redirected outside the messaging platform and into the a web browser window with the business specific log in process.

The URL webLoginUrl will be extended with a query parameter called redirect_uri.
If the log in is successful, redirect the browser to the redirect_uri specified in your callback to complete the flow, and append a new authorization_code query parameter. Eva will add the contents of authorization_code to the subsequent
applicative webhook calls as a new key called privateId.

Detailed BotKit docs can be found here: http://docs.evature.com/botkit.html