Integrating RASA chat bot with Slack
Shrijan Choudhary » I will try to maintain the brevity of the article without missing on any crucial step and I guarantee that if you follow the steps, you will have a working slack bot for yourself.
Creating a slack app
- To create the app go to Your Apps and click on Create New App.
Basic information
: Scroll down to reach theDisplay Information
filling the name, description, a photo and a background colour for your bot.
Authorization and Permission for your BOT
add the permissions for your bot so that it can read and write text messages with anyone who wants to interact with your bot.
-
Head over to
OAuth & Permissions
and scroll down toScopes
. To add the permissionschat:write
im:read
im:write
im:history
mpim:history
app_mentions:read
channels:history
groups:history
reactions:write
- Scroll up and click
Install App
option to install the app on slack with these permissions.
Setting up the RASA credentials.yml
- Copy the
Bot User OAuth Token
and paste in thecredentials.yml
page of your RASA project
- Head over to
Basic Information
to gather theSigning Secret
.
- Keep the
slack_channel
parameter empty.
Running scripts for actions, ngrok and shell.
-
Running the action script
Un-comment the
action_endpoint
tag in theendpoints.yml
$ rasa run actions
-
Start your RASA shell
Make sure you are on the RASA project directory and the virtual environment of project
$ rasa run --port 5002 \ --connector slack \ --credentials credentials.yml \ --endpoints endpoints.yml \ --log-file out.log \ --cors * \ --enable-api \ --debug
-
Start ngrok on the
5002
port$ ngrok http 5002
-
Copy the URL and append
webhooks/slack/webhook
to get something like below:https://b90b-202-44-192-214.ngrok.io/webhooks/slack/webhook
Final configurations on Slack
-
Go to the Event Subscription section and then toggle the Enable Events switch on the page to ensure it is ON.
-
Paste the above copied
ngrok URL
to Request URL -
Waiting for a “Verified” remarks against your request URL section.
-
Go to
Subscribe to bot events
and add the following events- message.channels
- message.groups
- message.im
- message.mpim
-
Save the changes and reinstall the app.
To start chatting with your bot, go to https://slack.com/intl/en-in/ and click Launch Slack to go to your workspace. Select your bot from the left hand side menu and start chatting! :)