Deploy SUSI.AI to a Messenger
Integration of SUSI AI to messenger platform has become a vital step as to enhance the popularity of this chatbot and to target a large base of users. For example - Viber claims that it has a user base of 800 million. So just integrating SUSI AI to Viber can increase its user base exponentially. This integration also proves to be a big boon, if the chat bot learns with the number and variations in the questions being asked. Like in the case of the web chat client (Susi AI). This blog post will walk you through on how to deploy SUSI.AI to a messenger platform (Viber and Line messengers are used as an example in this post). We will be using Node.js and REST API technology in our example integrations. The repository of deployment of Susi AI to Viber can be found at susi_viberbot, and to Line messenger at susi_linebot. The SUSI AI Viberbot can be followed from here and Linebot by scanning this QR code. The diagram below will give you an overview on what flow is followed to deploy SUSI AI chatbot to various messenger platforms. Fig: Integration of Susi AI to chat messengers. Let’s walk through each of the steps mentioned in the above diagram. To get familiar with SUSI.AI chatbot. We have an API from where we fetch answers. To get a reply for the query ‘hi’, we can visit the API link with the query ‘hi’ appended to it (http://api.susi.ai/susi/chat.json?q=hi). You can chat with SUSI AI here. To set up a private SUSI AI chatbot account. A account must be set up in the messenger platform, so that the user can message in that account to get a reply by the chatbot. Steps to set up the chatbot account is dependent on the messenger platform. To set up a webhook url. The message sent to the chatbot account, must somehow connect to the chatbot. This message can be fed as a query to the chatbot, so that accordingly chatbot can think of a reply. To achieve this we need a url referred to as the webhook url. The messages sent by the user, to the SUSI AI chatbot account on the messenger, can then be redirected to this url. (Heroku platform allows 5 apps to be hosted on its platform for free, so you can check this documentation on how to host a node js app there.) Now we need to think on how to handle these messages. To host code on our webhook url As said earlier, we will be using Node js technology. Generally, the messages from our SUSI AI chatbot account on the messenger will travel as requests to our webhook url. These come as POST requests to our url. To handle that we can use this piece of code: app.post('/', function(request, response) { response.writeHead(200); // first step here, getting the message string from the request body // second step, calling the chatbot to get the reply to this message //…
