In this tutorial, We are going to learn how one can create a chat app using DialogFlow and MessengerX.io.
We can easily create our logic pipeline (like how and what our chatbot will respond) and connect it in our website, deploy if required on play store or on MessengerX.io Platform and monetize it! (applicable for consumer bots)
Prerequisite
Python 3.6+
MessengerX.io FREE Auth Token
DialogFlow
Getting Started
First we will clone the template which contains the starter code
git clone https://github.com/machaao/machaao-dialogflow-template.git
cd machaao-dialogflow-template
Getting DialogFlow Auth Key
We will follow this doc created by google to enable the DialogFlow API and create the Auth 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.
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.
Upon login, you should be able to create a new chatbot and the corresponding FREE API key.
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.
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
# 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.
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