Back in March, I started working at Rasa as an Engineering Manager, but before I joined, I hadn't had much practical experience with machine learning and conversational AI. Coming from a software engineering background, I had a general idea, but I didn't fully realize the potential of today's conversational AI frameworks. Often, the latest AI technology hits the news, but you might not see the actual impact on actual products used by actual people.
So I set out to build my conversational AI product intuition, and more specifically, deeply understand how Rasa and Rasa X work. As an engineer, it's key to understand what end users actually go through when they use our products: is it easy to get started? how hard is it to set up a given feature?
To do that, I decided to build a small chatbot called BoulderBot that can answer basic questions about bouldering - mainly because I like bouldering a lot.
Learning process
With this goal in mind, I went through our public documentation and made a list of all the features my bot could have. And then I started implementing some of them. But this exercise wasn't about coding, it was about learning (and sharing my learnings with the team). I even made the project one of my goals for the quarter:
Along the way, I learned a few things about setting up a Slack channel in Rasa X that I thought would be useful for fellow makers. If you're using Rasa X but haven't set up a channel yet, I hope this helps you!
Creating a Slack app
I started by heading to the Slack channel documentation. The first step is to create a Slack app here: https://api.slack.com/apps. If you haven't created Slack apps before (like me), you might feel a bit overwhelmed by the number of options, but luckily, the Rasa documentation describes which options to configure.
To make it possible to interact with my chatbot from Slack, my Slack app needed to send events to Rasa X via a webhook, which is configured through the Event Subscriptions pane.
This is where I hit my first roadblock: when setting up the various events to send to one of the Rasa X endpoints, Slack expects the endpoint to respond to a "challenge request", for security purposes. But since I hadn't configured the Slack channel in Rasa X yet, it cannot respond to this challenge request. No big deal, I thought, I'll come back to this step later.
My next step was to get the Bot User OAuth Access Token from the OAuth & Permissions pane by installing the app in a Slack workspace. The catch here was that I needed to give my chatbot at least one permission, otherwise it wouldn't work. I selected channels:history
because it kind of makes sense for the bot to have access to the history of a channel, and it seems like the right level of permissions.
Setting up the Slack channel in Rasa X
So, at this point I had a Bot User OAuth Access Token, but Rasa X still wasn't configured. The documentation mentions that I needed to update my credentials.yml
file, but since I installed Rasa X using the one-line deployment script, I needed to find a different way to configure the credentials. Luckily, the Rasa X documentation was here to help me. I just needed to run the following, and that should do it:
# this sets a environment variables
$ export ADDITIONAL_CHANNEL_CREDENTIALS="slack.slack_token='...',slack.slack_channel='...'"
# this updates the Rasa X instance and uses the environment variables
$ curl -s get-rasa-x.rasa.com | sudo -E bash .
One thing I wasn't sure about: how do I find the ID of a Slack channel? 🤔 Easy: copy a link to a message in a channel, and look at the URL!
After a few seconds, the command completed, and to verify that everything was running fine, I ran kubectl get pods
and checked that all the pods were running. Great! And finally, remember the Event Subscriptions setting from before? Now I went back and configured it. And, no surprise there, Rasa X now responded to the challenge request sent by Slack! Brilliant.
Chatting with BoulderBot
Time to talk to my bot via Slack 🤖. The first thing I tried was sending "Hello" in the channel, but no answer came back, even after a few minutes. The next thing I tried was @-mentioning the bot. Still no answer.
My next step was to look at the logs of my deployment. I wasn't yet super familiar with all the services that are part of a Rasa X deployment just yet, so I needed to take a closer look at the architecture and the different containers. I turned my attention to the rasa-production
container, as it deals with input channels. Using the kubectl log
command revealed the issue:
The server responded with: {
'ok': False,
'error': 'missing_scope',
'needed': 'chat:write:user',
'provided': 'channels:history,im:history,groups:history,mpim:history'
}
Updating my Slack bot's permissions to include chat:write
did the trick. And magic happens:
Wrapping up
With this short exercise, I got closer to my goal of understanding how Rasa and Rasa X work. It gave me good insights into concepts like input channels and the overall Rasa X architecture - and the cool thing is that I could actually chat with BoulderBot via Slack, a service I already use every day at work.
The learning process is not over yet! I've got a lot of other features to try and implement for BoulderBot. To name a few: Knowledge Base Actions, Evaluating NLU and Core models or Connecting to a Frontend.