Want to save time by automatically replying to messages in Slack?
Then, you should create a Slack chatbot, which will take care of that!
In this tutorial, I will explain:
- What Slack bots are
- How Slack chatbots work
- And how you can create a Slack chatbot yourself, without writing a single line of code
Let’s dive in!
Table of Contents
What are Slack bots?
A Slack chatbot is an automated conversation system embedded into Slack. It can send welcome messages to Slack users who visit the bot and automatically reply to specific words in a Slack conversation or channels.
Slack chatbots work 24/7 and can have multiple conversations at once.
Besides, you can add Slack bots to channels in Slack where they can talk in group conversations.
Here is an example of a Slack chatbot that automatically tells jokes:
How do Slack bots work?
Slack chatbots are often created based on a conversational flow.
And most flows are built using three simple elements:
- Trigger: tells the chatbot when to start a conversation
- Action: Tells the chatbot what to do
- Condition: Performs checks on the user based on if this, then that
For example, when a visitor sends a message to your Slack chatbot, the chatbot will first check if the user is a first-time visitor of the chatbot or a returning visitor.
If the visitor is a first-time visitor, it will send the “first-time visitor” message and ask a question. If the visitor is a returning visitor, it will send the “Returning visitor” message and notify an agent.
How to make a chatbot on Slack?
Slack doesn’t have a platform that allows you to create bots directly on their platform. Therefore, we need to use a third-party chatbot platform to create our Slack bot.
Now, let’s create a Slack chatbot in a few simple steps, without using a single line of code:
1. Sign up for a free Flow XO account for your Slack bot
The first step is to create a free Flow XO account by clicking the button below:
2. Create a flow and reply to specific words
Once you have signed up for your account, you need to go Flows and click on + New in the top-right corner:
Here, we can determine if we want to go with a pre-built template or with a Blank Flow. We will select the Blank flow:
Then, we need to determine what triggers this flow, which will be a New message:
We will set it up for all the bots connected to our Flow XO account (we will set this up later):
And then we can determine the word we want to reply to. As an example, we want to reply when somebody asks for the wifi password.
So, we will fill in the following words and phrases:
And we will set up so that the chatbot will reply in a private conversation and in public Slack channels:
Now your flow will be saved and will look something like this:
If you click on the name of the flow (“Untitled flow”), you can also edit give it a better name so you know what the flow is about:
3. Determine the auto-reply for Slack messages
Now that we created our flow, we need to determine the automatic reply we want to send if someone asks for the wifi password.
You can create this reply by clicking on the + icon in the flow builder:
Choose for Send message:
And we can set a simple auto-reply for this message and click on Save:
Lastly, you need to activate the flow in the upper-right corner by clicking on the Off toggle:
That’s it! Now, every time a user asks for the wifi password, your chatbot will automatically reply to it.
You can even test this out by clicking on the message bubble in the bottom right and talk to your chatbot:
Connect your bot to Slack
The last thing we need to do is connect our bot to our Slack workspace.
And this is also the most trickiest part of the tutorial. But if you just follow every step that I take, you can connect your Flow XO Bot to Slack.
We can do this in a few simple steps:
- Create a bot in Flow XO and connect it to a Slack app
- Add a Redirect URL and add the right scopes
- Add Event Subscriptions to your Slack bot
- Add Interactivity to your Slack app
- Enable Slash Commands and your Slack chatbot to your workspace
1. Create a Bot in Flow XO and connect it to a Slack App
The first step is to go to Bots in Flow XO and click on New in the top-right corner:
Then, select Slack as your channel:
And you can give your Bot a name, such as “Chatimize’s Slack Chatbot”:
Before we can actually create the bot, we first need to add some information to Slack and from Slack to Flow XO.
So in order to do this, we need to create an app inside Slack.
Therefore, you need to go to https://api.slack.com/apps?new_app=1 and click on Create an App:
Choose to create an app from scratch:
And fill in the name of your app (can be the same name as in Flow XO) and pick the right Slack workspace:
Now your Slack app is created, which we are going to use for our Slack chatbot.
Once you have created your Slack app, you automatically go to the Basic information tab of your app.
If you scroll down, you will find the section App credentials and you need to copy your Client ID and Client Secret to Flow XO:
2. Add a Redirect URL and add the right scopes
Next, we need to go to OAuth & Permissions and add a Redirect URL to our Slack App.
You can get this URL from Flow XO. So if we go back to Flow XO, you will see that we have a Slack App Redirect URI, which we need to copy and paste into Slack:
Once you have added the Redirect URL, we need to add Bot Token and User Token scopes to our Slack app. We need this to be able to actually receive and send messages from Flow XO to Slack.
So in Slack, you can just scroll down on the same page and add the following Bot Token Scopes:
And add the following User Token Scope:
So it eventually looks like this:
3. Add Event Subscriptions to your Slack bot
Following, we need to add Event Subscriptions to our Slack bot.
In Slack, go to Event Subscriptions, set it to On in the top-right corner and add the following Bot User Events (under “Subscribe to bot events”):
Then, you also need to add the “Slack App Interactive Messages Action URL” from Flow XO to your Slack app:
4. Add Interactivity to your Slack app
Next, we need to add Interactivity to our Slack app.
In Slack, go to Interactivity & Shortcuts, enable the Interactivity and paste the “Slack App Interactive Messages Action URL” from Flow XO inside the Request URL and click on Save changes:
5. Enable Slash Commands and your Slack chatbot to your workspace
Lastly, we need to enable slash commands and our slack chatbot to our Slack workspace.
First, go to your Slack app, click on App home and enable Allow users to send Slash commands and messages from the messages tab:
With this feature enabled, people in your Slack workspace can write slash commands and your bot can understand them and possibly process them.
Next, we need to go back to Flow XO and click on Next at the right-bottom of the page:
Then, you need to click on Add to slack to add your chatbot to your Slack workspace:
Slack will open up and you need to give permission to add the chatbot to your workspace:
And now your chatbot is successfully connected to your Slack workspace. You can find the chatbot under “Apps” in the left sidebar and talk to it:
Add your Slack Bot to a channel
When you’ve added your chatbot to your Slack workspace, it isn’t automatically added to every channel.
If you want to add your chatbot to a channel, you can just mention them inside the channel and Slack will automatically ask if you want to add them:
Now, you only have to click on Invite them and when you say “wifi password” the chatbot will reply inside the channel:
Now It’s Your Turn
And that’s how you create a Slack chatbot, without writing a single line of code.
Now I have a question for you: How are you planning to use Slack chatbots for your business?
Please let me know by leaving a comment below👇