In this tutorial, we will learn how to set up a conversational AI Chatbot using Wit.ai and MessengerX.io
https://dev.messengerx.io/witty-jokes
- Golang — Basic
- Wit.ai
- Ngrok (local tunnel to your laptop for development purposes)
- MessengerX Wit template
- Platform API Token / Key
- GNU Screen / Terminal
- Javascript Enabled Browser (Google Chrome)
Today, we will learn how to set up a conversational AI Chatbot using Wit.ai and Machaao Chatbot Template on MessengerX.io platform.
So, assuming we have all the above covered — Let’s get started!
Visit https://portal.messengerx.io/ then login or signup on the platform.
Fill out the form shown below and create a new chat bot, place None in webhook URL and image URL and then press create.
Click on Settings and copy the API Key, you will need it later.
Now, we need API Token from Wit.ai. So, sign up on Wit.ai.
Click on Create > Your App > Settings then copy the server access token, that is your Wit API Token.
1. Conversational AI: Code/No Code
2. Chatbots 2.0: Simplifying Customer Service with RPA and AI
git clone https://github.com/machaao/messengerx-wit-go.gitcd messenger-wit-gols
You can download ngrok from ngrok — download
Download & Install the Go-Lang stable version from here: https://golang.org/dl/
go get github.com/dgrijalva/jwt-gogo get github.com/wit-ai/wit-go
ngrok allows you to expose a web server running on your local machine to the internet.
We will be setting MessengerX.io & Wit.ai API token as environment variable.
# For Linux and Mac OSexport MachaaoApiToken=<YOUR-MESSENGERX-API-TOKEN>export WitApiToken=<YOUR-WIT-API-TOKEN># For Windows (PowerShell)$env:MachaaoApiToken = '<YOUR-MESSENGERX-API-TOKEN>'$env:WitApiToken = '<YOUR-WIT-API-TOKEN>'
OR
You can even directly set the respective API Token in the main.go file.
Now, navigate to the working directory messenger-wit-go
Open bot.js in an editor and at line 17 place your API-KEY, copied from MessengerX.io portal.
screengo run main.go
Press ‘Ctrl+a’ then ‘d’ to detach from the screen.
Note: If you are using VPS then just add PORT 3000 to inbound rules and skip the below step.
screenngrok http 4747
Note: Copy the forwarding url. You will need this.
Press ‘Ctrl+a’ then ‘d’ to detach from the screen.
Log on to https://portal.messengerx.io/ and click on settings to update the chatbot webhook URL.
Paste <FORWARDING-URL>/machaao_hook or paste the VPS domain:4747 and save it.
That’s it.
The Chatbot will also be available on the web.
If everything went well you can see your chatbot at
https://dev.messengerx.io/<chatbot_name> OR https://ganglia-dev.machaao.com/<chatbot_name>
To integrate the chatbot into your website use iframe.
<iframe src=”https://dev.messengerx.io/<chatbot_name>”width=”400″ height=”600″></iframe>
We will now use Wit.ai to train our chatbot to understand the input and extract useful information from the user input message. We have to input sample input text and define what type of data we want.
Type the sample text, highlight the sample data you want to capture then select from the entity or create one, then click on Train and Validate.
Entity detects the similar data and captures it.
After training few data headover to settings to test the AI, if it is getting desired value or not.
In the HTTP API section enter your query then send a GET request to the API.
You would get result similar to this.
After getting desired entity value, you are good to go.
With Wit.ai and MessengerX.io, you can create and deploy your scalable ChatBot in no time, as we already know the scalability and performance of GoLang.
Github Repo: MessengerX-Wit-Go
Demo: https://dev.messengerx.io/witty-jokes
Checkout my other tutorials too