AI Chatbot using RASA and MessengerX.io

In this tutorial, we will learn to build and run a custom AI chatbot in Python using RASA and MessengerX.io

Basic AI Chatbot Demo

figure

https://dev.messengerx.io/rasa.sample

Requirements

1. Get your FREE MessengerX.io Chatbot API Token

  1. Login/Signup at MessengerX.io Portal
  2. Create a new app by clicking the New App
  3. Fill in the blank details, then click Create.
  4. Open settings of the ChatApp.
  5. Copy the Token.

2. Clone the Chatbot Starter Repository

Next, Lets clone the open source sample rasa chatbot template as shown below

git clone https://github.com/machaao/rasa-sample-nlu-bot.git

cd rasa-sample-nlu-bot

3. Install the Dependencies/Requirements

Here, We will be installing Rasa 2.2.0, Machaao Python Module – 0.2.0 and PyYAML (Optional)

Note: Might take some time depending on your internet speed.

pip install -r requirements.txt 
pip install -U PyYAML 

4. Replace the API Key

Now, we need to paste the Chatbot API Token which we copied from MessengerX.io Portal and the Chatbot API Token will be able to securely send messages with the server and user.

Use a text editor to open config/credentials.yml

connectors.MachaaoConnector.MachaaoInputChannel:
    api_token: <YOUR API-TOKEN>
    base_url: "https://ganglia-dev.machaao.com"

5. Starting RASA Action Server Locally

Here, we need to run the Action server, it is used for predicting the response for users. If you want to learn more about RASA Action Server, you can visit this page.

Open a terminal/powershell.

rasa run actions --actions actions

This command will start the action server, if you see any warning, don’t get bothered.

6. Starting Rasa Core Locally

Open another terminal/powershell.

The server should start at PORT 5005.

rasa run -m models --debug --endpoints config/endpoints.yml --credentials config/credentials.yml --enable-api --cors “*” --connector "connectors.MachaaoConnector.MachaaoInputChannel"

7. Start Tunnel Server

Tunnel server is used for exposing your port to web. We will be using the FREE machaao tunnel server.

Open another terminal/powershell.

machaao tunnel -p 5005 -t <Chatbot-Api-Token>

8. Updating the Webhook URL on MessengerX.io Portal

Update your bot Webhook URL on MessengerX.io Portal with the url provided as shown below.

Webhook Url: <TUNNEL-URL>/webhooks/machaao/incoming

You can test your new AI chatbot by visiting, https://dev.messengerx.io/<chatbot-name>

Congrats, your shiny new sample AI chatbot is ready.

Checkout https://blog.messengerx.io for more tutorials on AI and Chatbots

Happy Coding and Happy New Year!