Integrating Rasa Chatbot With Slack
What is Slack?
Slack is essentially a chat room or a collaboration hub that is used by the company to share work between teams and is designed to replace email as your primary method of communication and sharing.
It’s designed to support the way people naturally work together, so you can collaborate with people and also allows for private messages to share information, files, and more all in one place.
Slack integrates. with a host of other apps so you can manage your entire workflow through one platform.
As you have created the bot then we need to change a few things so to integrate rasa with slack and you have to install rasa and first make the chabot only then you can integrate it with slack.The steps to follow are-
Now we need an application to attach our bot like Messenger, Slack, etc. In This work we will focus on Slack, create the app on the below link:
then you will see this page
1.Click on Create App, give a name to the app, and select your workspace:
The workspace will be the slack id that you have to created to integrate rasa chatbot with slack
This will redirect you to your app dashboard. From there, you can select the Event Subscriptions? option:
- Click event subscription> Then enable the events >then we need to go back to the code and then we need to get the requested URL from
We are going to use another useful tool to deploy our chatbot to Slack. That’s ngrok and you can use the following link to download it:
To activate ngrok first run all the command that I am putting here.
1.rasa run actions (to run the actions.py file)
2.rasa run (this is to run the whole rasa chatbot as if we do not run this then we will not be able to use ngrok as there will be no client to recieve the instruction to connect with ngrok)
3.Then after this run
command- ngrok http 5005 (5005 is the port at which we will connect with the rasa bot.This port address that is been used to run the chatbot)
4.After we will get the ngrok running then take the url of http://ngrok_url and copy the url as it will be used to connect rasa with slack.
- Now you will put the ngrok HTTP file that I have marked to the event subscription replace the ngrok part with your ngrok URL:
To check whether it is connected you need to copy the http ngrok url and run it in your web browser.If it is connected then it will give you a message like
Hello from rasa:1.10.1
And then it will be verified in Enable events-
5.Under the Subscribe to Bot Events, click on the Add Bot User Event button. It will reveal a text field and a list of events. You can enter terms into this field to search for events you want your bot to respond.
6. We have to go to OAuth & Permissions and then we need to install the app to our workspace that we had created
7. Install the app so that the app gets installed in slack.
8. After installing we will get the Bot User OAuth Access Token
You need to supply a credentials.yml with the following content:
- The slack_channel can be a channel or a person that the bot should listen to for communications, in addition to the default behavior of listening for direct messages and app mentions, i.e. “@app_name”. To get the channel id, right click on the channel choose Copy Link and the id will be the last component in the URL.
- Use the entry for Bot User OAuth Access Token in the “OAuth & Permissions” tab as your slack_token. It should start with xoxb.
- Open a new terminal and start the action server:
rasa run actions
9.You?ll, see that the server is running on port 5055. Now stop the server, and go to yml file and paste these lines (they already exist as comments, just remove the #) :
9.1 Now add chat.write scope in Bot Token Scopes >Scope which is under( OAuth & permission )
- Then reinstall the app and then go to your slack workspace and then in app select your app and then run your chatbot through the slack
And you can make certain changes and make a full functioning chatbot app.