MULTI CHANNEL CONNECTOR DEPLOYMENT 2 RASA CHATBOT – EASY STEPS | FACEBOOK | TELEGRAM | SOCKETIO | WHATSAPP

OVERVIEW

In this blog, you will learn,

  • How to integrate rasa chatbot to telegram?
  • How to integrate rasa chatbot to whatsapp?
  • How to integrate rasa chatbot to facebook messenger?
  • How to integrate rasa chatbot to socket.io?
  • How to integrate rasa chatbot to multiple channel together?

In our previous blogs you have learnt that how you can integrate rasa chatbot to multiple channels seperately. In this blog you will see that how you can integrate the rasa chatbot to multiple channels, like facebook messenger, whatsapp, telegram, any website, etc.

Introduction

To integrate your chatbot on multiple channels, firstly you must have any chatbot(whether a new one or the one that you have already built with rasa chatbot). In this blog, I will using the chatbot that I have already used in the below video,

You can download the code here:

Download Code for InnovateYourselfBot

Once you have cloned the code, now lets start by integrating the chatbot on multiple channel one by one.

How to integrate rasa chatbot to telegram?

Firstly, lets integrate the chatbot on telegram, for that you need to have the verify, access_token and webhook_url. To know how to get them check the below video and update them in the credentials.yml of the rasa chatbot in the given format,

telegram:
  verify: "<name-of-bot>"
  access_token: "<access-token-generated>"
  webhook_url: "https://<domain-here>/webhooks/telegram/webhook"

Once, you have the verify and access_token with you, just update them in the above format, also add the webhook_url with the domain or the ngrok domain generated and update in the above format. Then add the credentials to the credentials.yml.

How to integrate Rasa Chatbot to whatsapp?

Now let’s integrate the rasa chatbot to whatsapp. For that a third party named twilio is used. To connect your chatbot to whatsapp through twilio. You will first have to create a new project on twilio as shown in the below video.

After following all the steps you will get the final credentials for twilio in the given format.

twilio:
  account_sid: "<account-sid>"
  auth_token: "<auth-token>"
  twilio_number: "whatsapp:+14155238886"

Once you got the account_sid and auth_token, update them in the given format and then add it to the credentials.yml file.

How to integrate Rasa Chatbot to Facebook Messenger

Now let’s integrate the rasa chatbot to facebook messenger. For that facebook provides the api for developers. Create you app on this website and generate the tokens required as shown in the below video.

Once you have created the app successfully, create a page on your facebook account and link it to your app as shown in the video and add the credentials to the credentials.yml in the given format.

facebook:
  verify: "<name-of-app>"
  secret: "<secret-access-token>"
  page-access-token: "<generated-access-token>"
connect to facebook messenger channel

How to integrate rasa chatbot to socket.io

Now let’s integrate the rasa chatbot to any website with socketio. For that we have to inject a script on to the website with the domain link of rasa chatbot int it and also to inject the credentials socketio in credentials.yml of rasa chatbot as shown in the below video.

socketio:
  user_message_evt: user_uttered
  bot_message_evt: bot_uttered
  session_persistence: true
<script>!(function () {
  let e = document.createElement("script"),
    t = document.head || document.getElementsByTagName("head")[0];
  (e.src =
    "https://cdn.jsdelivr.net/npm/[email protected]/lib/index.js"),
    // Replace 1.x.x with the version that you want
    (e.async = !0),
    (e.onload = () => {
      window.WebChat.default(
        {
          selector: "#webchat",
          initPayload: "/greet",
          customData: {"language": "en"}, // arbitrary custom data. Stay minimal as this will be added to the socket
          socketUrl: "http://localhost:5005/",  // Enter this if you have rasa server running locally otherwise enter domain name.
          socketPath: "/socket.io/",
          title: "Innovate Yourself",
          subtitle: "Get It, Make It.",
          params: {"storage": "session"}
        },
        null
      );
    }),
    t.insertBefore(e, t.firstChild);
})();
</script>

How to integrate Rasa Chatbot to Multiple Channel

After you have added the credentials of all the channels that you want to integrate your rasa chatbot to, then you have to start your rasa server with the given commands to run it.

rasa run -m models –enable-api –cors “*” –debug

and in another terminal start the action server if you have any custom actions with,

rasa run actions

credentials.yml

# This file contains the credentials for the voice & chat platforms
# which your bot is using.
# https://rasa.com/docs/rasa/messaging-and-voice-channels

rest:
#  # you don't need to provide anything here - this channel doesn't
#  # require any credentials


facebook:
  verify: "<name-of-app>"
  secret: "<secret-access-token>"
  page-access-token: "<generated-access-token>"

telegram:
  verify: "<name-of-bot>"
  access_token: "<access-token-generated>"
  webhook_url: "https://<domain-here>/webhooks/telegram/webhook"

twilio:
  account_sid: "<account-sid>"
  auth_token: "<auth-token>"
  twilio_number: "whatsapp:+14155238886"

#slack:
#  slack_token: "<your slack token>"
#  slack_channel: "<the slack channel>"
#  slack_signing_secret: "<your slack signing secret>"

socketio:
  user_message_evt: user_uttered
  bot_message_evt: bot_uttered
  session_persistence: true

#mattermost:
#  url: "https://<mattermost instance>/api/v4"
#  token: "<bot token>"
#  webhook_url: "<callback URL>"

# This entry is needed if you are using Rasa X. The entry represents credentials
# for the Rasa X "channel", i.e. Talk to your bot and Share with guest testers.
rasa:
  url: "http://localhost:5002/api"

Now your rasa server is up and running and also its linked to multiple channels, Now talk to the chatbot on the channels where you have setup your chatbot.

Time to wrap up now. Hope you liked our content on How to deploy rasa chatbot to multiple channels. See you in our next blog, thanks for reading our blog and do leave a comment below to help us improve the content to serve you all of our experience with you. Stay tuned with us for more Rasa Chatbot contents.

Also check out our other playlist Rasa Chatbot, Internet of things, Docker, Python Programming, etc.
Become a member of our social family on youtube here.

Stay Home and Stay Safe.

Ashish Saini
Ashish Saini

I am a software developer for Python/Machine Learning. Also, I’m Rasa Hero at Rasa. Also, I’m a Youtuber where I regularly uploads the videos to help this generation learn about the technology just like they are playing games.

Leave a Reply

Your email address will not be published. Required fields are marked *