Slackbots are handy robot assistants that hang out in Slack, wait for commands, then find or create the thing you need. You can build a Slackbot right now, in just a few minutes, without any code.
How hard will it be? It depends on what you want your bot to do.
Reply bots respond when someone uses a specific phrase, and are the easiest bots to make. These are perfect for automatically answering questions that tend to come up often on Slack.
Notification bots watch what's happening in other apps and send any updates to Slack, and they're fairly easy to make. These bots keep your team up-to-date with info from other apps so you don't need to jump back and forth.
Slash command bots are triggered by a command beginning with a slash, and are one of the hardest kinds of bots to make. An example is
/giphy, which is a command that triggers a bot for finding animated GIFs. You can make similar bots that grab information from other apps.
In this article, we'll outline how to make all three kinds of bots using Zapier, a tool that connects apps without any code. Feel free to follow along with our PDF cheat sheet as you go.
This article focuses on making bots in Slack, but you can use Zapier to make bots in other chat apps, on social networks, through SMS, and more. Learn more about how Zapier works to get started.
How to build a Slack reply bot
Reply bots can save your team time by answering questions that come up time and time again. They constantly watch every Slack channel and respond for you when specific phrases are mentioned.
There are two ways to make this kind of bot. The first is to set up a Slackbot response. The second, which requires a bit more setup but is a lot more customizable, is to build a custom bot using Zapier. Let's dive in.
How to build a simple Slack reply bot using Slackbot
Slackbot responses, the simplest way to build a bot, are right in your Slack settings. Just go to slack.com/customize/slackbot, add a phrase for the Slackbot to watch for, and then tell it how to respond.
Here at Zapier, for example, employees frequently ask how to refer their friends for open positions, so we made a Slackbot response that answers this question.
Note that you can add as many trigger phrases as you want—just separate them using a comma, as shown above. Here's how it looks when someone uses one of those phrases:
This saves our recruiting team from having to constantly answer the same question. It's quick to set up and works in every Slack channel.
The downside: this tool is rather limited, since it can only post the same response every time. What if you want a customized response each time? What if you want the bot to have a custom name and icon? That's when you'll use Zapier.
How to build a custom Slack reply bot using Zapier
Then, click the Make a Zap button in the top left corner, and select Slack as your trigger app.
For the trigger event, choose New Public Message Posted Anywhere. Alternatively, if you want this bot to only work in one channel, you could select New Message Posted to Channel.
Then you'll need a filter to watch for a specific term—otherwise, your bot would run every time anything is posted to Slack. Click the + button below the current step, and choose Filter by Zapier.
In the filter settings, have it watch the Text field for the term you want.
If you want the bot to run whenever any of those words are posted to Slack, then set the filter to (Text) Contains. If you want it to only run when it sees that specific phrase on its own, have set it to (Text) Exactly matches. Then in the third field, type the words you want the bot to watch for.
Learn more about filters in our Zapier Filter guide.
Now you'll add your reply, creating a basic bot. To do that, add another step to your Zap, selecting the Slack app and the Send Channel Message action. There, in the Channel field, select Choose a custom value. Select the channel name from your original Slack message, so the reply will end up in the same spot.
All that's left is to type in the message you want to post in the Message Text box. You can write whatever you want and even tag the person who sent the original message. Scroll on down, and you can add a name and icon to your bot—or have it post to Slack using your name, if you want. Save and turn on your Zap, and it'll send your customized message every time there's a match.
To customize things even more, you can try a Formatter action before your bot's reply. Formatter is a handy tool that can format your text, calculate values, choose random values from a list, and more.
Say you want to make a birthday bot that sends a random GIF from a list whenever someone says "Happy birthday!" Our filter above is already watching for the correct phrase—all we need now is the Pick from list Formatter, and a few GIFs.
To add the Formatter action, click the Continue button or + below the Filter step to add a new action. Choose the Formatter by Zapier app. Then, select the Pick from list formatter in the Transform field, and enter the GIF links in the Input fields.
Now add another step, this time selecting Slack as your action app. Choose Send Channel Message as the action. Then, in the message text box, add your birthday message and select your random GIF from Formatter from the dropdown. Turn your Zap on, and the next time someone says "happy birthday," they'll get surprised with one of your GIFs.
How to build a Slack notification bot
Notification bots are even easier to build in Zapier. All you need is an app or site to watch for notifications, and Zapier can automatically send those to Slack for you.
Say you want to be notified in Slack whenever new tasks are added to your Trello board. First make a new Zap, and select Trello as your trigger app. For your trigger action, select New Card.
Click Continue, and you can choose which board and list you'd like to get notifications for. After this, you can format the message your bot will send. To do that, click the + and add a Slack action.
Now you can set the Zap to send a message either to a channel or as a direct message to anyone on your team. Once you choose, you can customize the message with any text you want (in the Message field).
As you type, you'll see a dropdown with info from Trello about the card, such as its name, link, description, and more—click anything in this dropdown to add it to your message.
Tip: Slack has its own formatting rules for things such as links, bolded text, and block quotes. You'll want to familiarize yourself with these so that your messages come out looking right.
You can quickly make Slack notification bots for any of the thousands of apps that connect to Zapier, or with any site that uses RSS. Here are some popular integrations to get started. Click Use this Zap, and we'll walk you through the process.
How to build a Slack slash command bot
Now you're ready to build the most advanced bots in Slack: slash commands. They're the bots that wait for a command and then do whatever you asked. Make a document, find an email address, start a call, log records—you name it.
It all starts by adding a new app to your Slack account. Go to api.slack.com/apps, click Create an App, enter a name for your app, and select the correct Slack account where you want to use the new Slack bot.
Slack will then show some options to add features to your app. You can add bot users, interactive messages, and more—but each of those requires coding. Instead, we're going to select the Slash Commands button. Click Create New Command.
First, add a command with a slash in front of it—perhaps
/contact if you want to look up contact info,
/weather to build a weather bot, or anything else that fits your needs. You can then add a short description and usage hint.
There's one more field to fill in: Request URL. We'll grab that URL from Zapier's webhooks integration.
In a new tab or window, make a new Zap using Zapier's Webhooks app, and select Catch Hook as the trigger event.
Click Continue, and you'll see your webhook URL. Copy it, and make sure you also check the Enable to respond with an empty body option.
With that Webhook link copied, go back to your Slack slash command's configuration page from before, and paste the link into the Request URL field—and then save your settings.
Now it's time to test your slash command so you can build the rest of its Zapier integration. Just open Slack, and type in your command followed by the text you'd like to use in the bot.
I'm building a bot that will find contacts in Google Contacts and send me their email address in Slack, so I'll enter a name that I can use to search Google Contacts.
Note: If you don't check the Silent Mode box on the Webhooks' settings page in Zapier, you'll see some confirmation text when you run the bot in Slack—don't worry, that's just text that Slack will send to confirm the bot was triggered correctly. You can simply ignore it, or you can go back and add
/silent/ to the end of your Webhooks URL in Slack's settings to turn on Silent Mode.
Now, it's time to use the data. Here are some quick ideas of what your command might do:
Use Formatter to split your text into sections, format the text, calculate numbers, and more.
Use searches and lookups to find info in your favorite apps—perhaps to find an entry in a spreadsheet, a contact in a CRM, a customer from your payment app, and more. There are also searches in apps like GIPHY that can find info online based on your query.
Use standard Zapier actions to save info to your apps—say to add a new contact, create a document, log time spent on a task, and more.
Go back to the tab where you'd opened Zapier, and click the OK I did this button for your webhook step. Zapier will find the data from your slash command, and you'll be ready to put it to work.
Let's try using a search to find a contact from Google Contacts account. Add an action to the Zap, select Google Contacts, then use the Find Contact action. Have it search by name, then select the text from your slash action as the search query.
Now that Zapier's found your contact, it's time to send it back to Slack. Just add another action to your Zap, and select the Send Channel Message action. Instead of selecting a specific Slack channel to post the message to, choose Custom, and click into the Channel ID field to find the channel.
All you need to do now is create your message. Type whatever you want in the Message Text field, grabbing any information from the previous steps in the menu below the text box. Then, customize the bot, adding the same name and icon image as you added to Slack previously.
Test the Zap, and you'll get the response in Slack you wanted.
Now, anytime you need a contact—or whatever you built your bot for—just type your slash command followed by the text you need to use. Your bot will do the work for you.
Want to build a more advanced bot? Try adding extra steps to your Zap—perhaps to create a template document and then post it to Slack—or use Code Steps to create advanced bots without having to code a full app. Or, for the most advanced bots, try using named variables to gather more than one text item at once. Just decide what you want to gather with the bot and a standardized name for each item, then write them followed by parentheses with the values you want. For example, say you want to gather a name and email in your bot. In Slack, type
Name(Bob Smith) Email(firstname.lastname@example.org), and Zapier will recognize each as a separate item you can use in subsequent actions.
The original version of this article was published in March 2018 by Matthew Guay.