Integration of Susi AI to Gitter

This blog post discusses the development of Susi Messenger bot on Gitter. It replies instantly to the messages sent to it, using the Susi API. The Streaming API notifies us when a user messages to the SUSI chat room. The REST API helps to message back with a reply from SUSI API, to the SUSI chat room. Feel free to message to the already made SUSI AI account on Gitter and have a chat with it. Prerequisites Basic knowledge about calling API’s and fetching data or posting data to the API. Node.js language. Github Heroku Figure - Architecture for running SUSI AI on different messaging services. This blog post will walk you through each of the steps required to integrate SUSI AI to Gitter: Setup SUSI AI Bot on Gitter Create a Github or twitter account with a username having 'Susi' as its substring because this is the name that will be shown with the reply string we will get from Susi AI. Now you need to sign in to Gitter with a twitter or Github account from here. Create your community by visiting this page. After writing your community name press next, invite the people you want to be in this room and press next. You will be redirected to your communities lobby. This lobby is the chat room to which we will deploy our SUSI AI. Now visit the Gitter developer page, press sign in on the top right. You will be redirected to your apps page. Copy the personal access token written there as shown in this image: (The area colored black will have your access token). 5. On a new tab, in your browser visit   https://api.gitter.im/v1/rooms?access_token=YOUR_ACCESS_TOKEN, with YOUR_ACCESS_TOKEN replaced by the token we just copied. A JSON object will be shown on our browser screen. You will see the value of 'name' key as YOUR_COMMUNITY_NAME/Lobby. Copy the id of this chat room, as we will need it later. You can refer to the image below, you will have your chat room id in the area colored black. Create a new heroku app here. This app will accept the requests from Gitter and Susi api. Set the config variables for this heroku app in the setting tab of your account. Set ROOM_ID to the id of the chat room and TOKEN to the personal access token, we copied in steps 4 and 5. These were the formalities to be done to have our chat bot account on Gitter. Let’s jump to the code part of how this integration will be done: To use the two config variables set in Heroku, we need these two lines in our Node js code: var roomId = process.env.ROOM_ID; var token = process.env.TOKEN; We need to set up an options variable with our access token and room id in it: // Setting the options variable to use it in the https request block var options = { hostname: 'stream.gitter.im', port: 443, path: '/v1/rooms/' + roomId + '/chatMessages', method: 'GET', headers: {'Authorization': 'Bearer '…

Continue ReadingIntegration of Susi AI to Gitter