A quick start tutorial on creating and deploying a Python based AI sample chatbot template

A quick start tutorial on creating and deploying a Python based AI sample chatbot template

Today, We will learn how to set up a base for a Python based AI chatbot using the MACHAAO + RASA Sample Chatbot Template.

Sample Chatbot UI

So, I have chosen the above mentioned chatbot template because it is easy to learn, build, deploy, monetise, integrate and manage.

So, we will require

So, assuming we have all the above covered - Let’s get started!


Register and Get your FREE API Key

Visit https://portal.messengerx.io/ then login/signup on the platform. 

Create a Mini App and fill out the form, place None in webhook URL and image URL and then press create.

MessengerX platform

Click on Settings and copy the API Key, you will need it later.

Cloning the Chatbot template

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

cd rasa-sample-nlu-bot

ls

the result must be this

No alt text provided for this image

Installing the required libraries and files

Here I will install rasa and ngrok. You can download ngrok from ngrok - download

NOTE: pip must be the latest version.

python3 -m pip install --upgrade pip
pip3 install rasa
pip3 install -U PyYAML
sudo snap install ngrok

rasa is a machine learning framework built on python. You can train your chatbot using rasa its easily. Read this for more info.

ngrok allows you to expose a web server running on your local machine to the internet.

Placing the API Key

Open this file in a text editor

 config/credentials.yml

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

You can also put the API Key and base URL in connectors/MachaaoConnector.py at line 30 and 32.

Starting RASA Action service

Here, we need to run the Action service in the background. So, we will use the Screen. If you don't know about Screen then this is a very good article How To Use Linux Screen.

Now, navigate to the working directory

screen

rasa run actions --actions actions

Press 'Ctrl+a' then 'd' to detach from the screen.

Starting RASA Core service

Again we have to run the RASA Core service in the background and will use the Screen again.

screen

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

Press 'Ctrl+a' then 'd' to detach from the screen.

Starting NGROK server (optional)

Note: If you are using VPS then just expose PORT 5005 inbound port and skip this step.


screen

ngrok http 5005
Note: Copy the forwarding url. You will need this.

Press 'Ctrl+a' then 'd' to detach from the screen.

Updating the webhook on Machaao Platform

Log on to https://portal.messengerx.io/ and click on settings to update the chatbot webhook URL.

Paste the <forwarding_url>/webhooks/machaao/incoming (forwarding url copied from ngrok) or paste the VPS domain:5005 and save it.

No alt text provided for this image


Re-train the sample model

In your project directory, this will delete the previous models and retrain it.

rm -rf models/*

rasa train

That's it.

If everything went well you can see your chatbot at

https://dev.messengerx.io/<chatbot_name>

To integrate the chatbot into your website use iframe.

<iframe src="https://dev.messengerx.io/<chatbot_name>" width="400" height="600"></iframe>

If you have any questions or errors feel free to ask in the comment box

Rasa.sample

MessengerX.io | Connecting Bot Developers to App Publishers[3] Tutorial: Rasa Basics

Aditya Chavan

Growth Marketer ?? | AI Chatbot | Product Launch Strategist | Scaling eCommerce

4 年

Superstuff Abhishek R.

Harshal Dhir

AI Scientist, Co-Founder @ Stealth Mode AI Startup, Distributed AI Cloud Computing

4 年

Thanks for this Abhishek R. :)

回复

要查看或添加评论,请登录

社区洞察

其他会员也浏览了