Build deeply personalized chatbots at production scale

Chatbots are now generally agreed upon as one of the fastest gateways into the ever changing field of machine learning.

This tutorial serves as a quick start guide for developers who are interested in the art of building deeply personalized chatbots.


Minimum Requirements

  • Python3 – Basic Understanding
  • Desktop Terminal (Windows / Mac / Linux)
  • Brew / Snap (Mac / Windows)
  • Ngrok
  • Platform API Token / Key
  • Active Internet Connection
  • Javascript Enabled Browser (Chrome / Safari / Firefox)
  • MessengerX Wiki (Reference)

In this tutorial, We will learn how to set up a simple echo bot using machaao python module in less than 10 minutes.

So, assuming we have all the minimal requirements covered.

Let’s get started!


Signup for your FREE API key

Signup via MessengerX.io – Dev Portal

Upon login, you should be able to create a new chatbot and the corresponding FREE API key.

MessengerX.io - Portal - Login / Signup - Chatbots
MessengerX.io – Dev Portal

Create your first chatbot application via portal

Upon login, Please click the fairly prominent “Add New App” button.

You should now see a popup screen as shown below.

Enter a display name for your chatbot.

To continue with the process, you can enter “None” in Webhook URL and Image URL field for now.

Next, Press “Save Changes” to generate a new API key for your bot.

MessengerX.io - Portal - My Chatbots
Create a new chatbot

Let’s proceed by saving the changes.

Next, Click on Settings and note down the API Key, you will need it later during the process.

Install the machaao python module

We will need to install the machaao library module to continue.

To continue, let’s install the module as shown below via PIP

# For Linux/MacOS
pip3 install machaao

# For Windows
pip install machaao

# For Ubuntu
sudo snap install ngrok

# For MacOS
brew install ngrok

# For other OS visit: https://ngrok.com/download

Finally, Let’s install NGROK so that we are done with the basic system requirements.

Create a new chatbot project locally

Once the machaao pip module has been installed on your system / laptop.

You can now create a new chatbot project by running the “machaao” command as shown below.

machaao --start <project_name>
# Creates a folder and copies the chatbot files.

cd <project_name>
# Changes current directory to the project directory

This will create a directory with the specified <project_name>

Next, Open chatbot.py in your favorite python editor and update the API key and base URL as shown below.

# Get the API Token from - https://portal.messengerx.io
MESSENGERX_API_TOKEN = "<API_KEY_FROM_PORTAL>"

# Base URL is used to communicate with either Dev or Prod APIs.
MESSENGERX_BASE_URL = "https://ganglia-dev.machaao.com" [for development purposes]

Run your local chatbot server

Next, Run the chatbot server via command line terminal.

# For Linux/MacOS
python3 chatbot.py

# For Windows
python chatbot.py

Setup your web server for development

Almost there…

Continuing on, let’s run NGROK in the command line terminal as shown below.

# Copy the HTTPS forwarding URL
ngrok http 5000
NGROK
NGROK – Local Tunneling
# Copy the HTTPS NGROK forwarding URL
https://<....>.ngrok.io/

NOTE: Not required on a VPS, Shared Hosting Providers such as Heroku.

Update your Chatbot Webhook URL

Next, Click on the chatbot settings and update your webhook as shown below.

Continuing, Update the webhook as shown here “https://<….>.ngrok.io/machaao/incoming” without quotes and save it.

MessengerX.io - Portal - Update your new chatbot
Update your chatbot settings with the new url

Your echo chatbot is now ready for development

If everything went well, your chatbot should now be ready to receive and process messages to or from users via Web / Android.

Congrats, you are now on your way to a deeper machine learning journey.

Finally, You can now show off your shiny new sample echo bot via https://dev.messengerx.io/<chatbot_name>

#HappyCoding


Get Started with building deeply personalized chatbots today with MessengerX.io

blog.messengerx.io