You're discussing a problem with your team and need a link to the bug to show them exactly what you're talking about. You could open your browser, search for the bug, and, once found, paste it into your conversation. Or you could type the bug's name in your chat app, and a bot could find the bug info and share it in the conversation automatically. Perhaps you need to find someone's contact info and then send them an invoice. Just type their name, and a bot can do both in seconds.
Bots are handy little assistants that hang out in your app, wait for commands, then find or create the thing you need. They're another way to use your favorite apps without opening them. They're the big new thing—a core part of Slack, Facebook Messenger, and Telegram's newest features.
And turns out, bots are simple enough for anyone to make. Here's how you can make a Slack Bot to do anything you want in a few minutes without any coding—along with a dozen examples of bots that real teams are using today, and a Slack bot cheat sheet for a handy reference to help build your own bots.
- What Is a Bot?
- What Do You Need to Build a Bot?
- What Types of Bots Can I Build?
- How to Build a Bot in Slack
- Bots That Help Teams Get Work Done From Slack
What Is a Bot?
Robots can drive cars across Mars, clean nuclear reactors, and cut precise holes in your smartphone's metal frame.
Bots are a little different. They live in your apps, not in the physical world. Rather than working assembly lines, they focus processing power on looking up facts and sending notifications when you need them. They're tiny programs without buttons or icons. Instead of clicking a search button, you'll type a command like /giphy volcano
to instruct the bot to find what you're looking for (a volcano gif from Giphy, in this case).
Bots are a buzzword right now, the big new thing in everything from Slack to Alexa. And yet, they're not exactly that new of an idea. Google, in many ways, is a bot that can answer lots of questions. Search for current time SF
, and you'll get the current time in San Francisco just by typing.
DOS-era programs also behaved much like a bot. Open Terminal on your Mac and type uptime
, or open Command Prompt on your PC and type net statistics server
, and an age-old bot will tell you how long your computer's been turned on.
Handy, right? Instead of finding the right app and clicking the right button, you type in a quick command and get what you want.
Perhaps you don't want to use Terminal all day—and you want something more personalized than Google offers. Say you want to find internal contact info, or make an invoice, or decide where to grab lunch as a team. You don't need a new app, and you don't need to open Google. All you need is your own bot, inside an app you're already using.
What Do You Need to Build a Slack Bot?
You only need 3 things to build a bot:
- A place to type your text
- A bot to read your text
- An app to do something with your text
All bots need to start is some text—the text you type that tells them what to do. That could be a Tweet (with Twitter bots that reply with flight status, say), a text message (like the y or n
messages you send to your carrier to change your phone plan), or perhaps an email. Chat apps are an especially perfect place for bots. Odds are you already use a chat app—and they include both a text box to type commands into and a conversation view to see what the bot replies.
Team chat app Slack is the perfect place to build bots for anything you need—and what we'll focus on in this tutorial. It's free to start using, and it's a tool where you likely already discuss ideas and projects with your team—with a text box that's perfect for sending commands to your bot.
Bots come built into Slack. We'll look at how to set them up in a minute, but here are the basics: Essentially, you give the bot a name, tell it where to watch, and when you type a specific word or symbol, the bot will start listening and then send that text to your app.
Apps are the tricky part. They're famously difficult to build, and are the one step that might keep you from building your own bots. But they don't have to be that difficult. Instead of coding your own app, you could use pre-built integrations from Zapier instead.
Zapier is a tool that connects your apps without any complicated code, so you can pass data between them. Using Zaps, or integrations inside Zapier, you can connect Slack to hundreds of other apps just by clicking through a simple wizard. For example, once you build a Slack Zap, it can watch for commands in any chat channel and kick off a workflow in another app, or track down info in one tool and send it back to Slack. That's how you can build the most powerful bots in your own Zapier-powered slash commands, as we'll walk you through below.
So let's use all 3, and see what type of bots we can build.
What Types of Slack Bots Can I Build?
The first time you open Slack, you'll be greeted by a friendly Slackbot that asks your name and time zone. Type in the replies, and your account will be personalized without a click, like magic.
You can then harness that magic yourself with your own bots. These come in three varieties:
Slackbot Responses
The simplest bots come built into your Slack settings. You add a phrase for the Slackbot to watch for, and then tell it how to respond.
Say you want a simple way to find the security code for your office: just tell Slackbot to watch for messages that say office security code
, then have it respond with the number. You could make more whimsical prank bots that send GIFs—or more serious bots to share important phone numbers, email addresses, or other helpful info.
To make a Slackbot Response, just go to slack.com/customize/slackbot and add the phrase and response you want. These will automatically work in any channel other than your personal Slackbot channel.
Or, you can make your own custom bots in Slack that watch Slack for text and automatically reply, either with the bot API or Zapier. We'll look at that below.
Notification Bots
Notification bots are the next easiest Slackbot to make. Instead of watching Slack for a phrase you type, they watch another app for an update and send it to Slack.
They look like another user in Slack, with their own name and icon. They'll show up every so often when there's something new—a news update, new document, or trending hashtag, perhaps—and post it to your Slack channels.
There are dozens of notification bots for social networks, news, and more in the Slack App Directory. Or, you can build your own notification bots with Zapier—perhaps even using a pre-made Slack integration that you can set up in a few clicks.
We'll look at how to make these in just a minute—but here are some popular Slack integrations if you can't wait.
Slash Commands
If you're looking for a bot that you can summon at will, though, slash commands are your best bet. Unlike notification-based bots, slash command bots wait for your signal, then perform some sort of task based on context that you provide.
You trigger them by typing a /
followed by their name (/giphy
, say, for the Giphy bot), and then type in a command. The bot will then find what you're looking for and post it back to Slack in a reply.
Bots can do just about anything you want: start a new meeting, compute a value, do research, and more. For that, you'll need to either code your own app or use Zapier integrations to connect Slack to over 700 of your favorite apps.
How to Build a Bot in Slack
Now that you know the type of bots you can build, it's time to make your own. Let's look at how you can make customized bots in Slack for replies, notifications, and commands—all without writing a line of code.
Building a Slack Reply Bot
Slackbot's default reply tool is rather limited, since it can only post the same response every time. What if you want a customized response—or perhaps a random response—each time?
For that, a Zapier-powered reply bot is your best option. First you'll need to create a Zapier account or log into your Zapier account.
Then, click the Make a Zap button in the top right corner, and select Slack as your Trigger app. On the next page, have your Zap watch Slack for a new message posted anywhere. Alternately, if you want this bot to only work in one channel, you could have Zapier watch that specific 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. Add another action to your Zap, this time selecting the Filter by Zapier app. In its settings, have it watch the Text field for the term you want.
If you want the bot to run whenever those words are posted to Slack, then have the filter watch for (Text) Contains
. Otherwise, if you want it to only watch for that specific phrase on its own, have the filter watch for (Text) Exactly matches
.
Then, you can add your reply, creating a basic bot. Just 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" and then 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. 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.
For something more customized, though, 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 +
on the left sidebar of your Zap to add a new action, and 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.
With that done, repeat those steps, only this time select Slack as your action app, and choose its Send Channel Message action. Then, in the message text box, add your birthday message and click the plus button on the right to add your random GIF from Formatter. Turn your Zap on, and the next time someone says "happy birthday" they'll get surprised with one of your GIFs.
Building 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 kanban board. First make a new Zap for Trello–with the "Make a Zap with Trello" button. Then, in the Choose Trigger step, select New Card to have it watch Trello for new cards on the board you want to watch.
Next, click the plus sign +
to 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. You can customize the message with any text you want. Click the + icon on the right of the message text field in Zapier to add info from Trello about the card, such its name, link, description, and more.
You can quickly make Slack notification bots for any of the 700+ apps that connect to Zapier, or with any site that uses RSS. Here are some popular integrations to get started with in a few clicks:
Building 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 can make a bot for that and more.
It all starts by adding a new app to your Slack account. Go to api.slack.com/apps, select Create New 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 require coding. Instead, we're going to select the Slash Commands button. Click Create New Command, then it's time to set your bot up.
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
We skipped one field—the Request URL. Here, you'll add a Webhook URL where Slack will send the data you typed to the command. You can use that to code your own app, pulling out the text, username, and other data from Slack from the webhook.
We're going to build our bot without coding—so we'll use Zapier's Webhook integration to capture the data from Slack and put it to work. Let's grab that URL first.
In a new tab or window, make a new Zap using Zapier's Webhooks app. Select Catch Hook when setting up the Webhook integration, click Continue on the options (you don't need to add anything here), then copy the Webhook link you'll see in the testing page.
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 we can build the rest of its Zapier integration. Just open Slack, type in your command followed by 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.
It's time to make our bot smart. 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.
Now, it's time to use the data. Here are some quick ideas to try with Zapier integrations:
- 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.
Let's try using a search to find a contact from Google Contacts account. Add an action to the Zap, select Google Contact, 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 Use a Custom Value at the bottom of the channel list, then use the Channel Name field from your webhook to select the channel where the slash command was used.
All you need to do now is create your message. Click the + icon beside the Message Text field to add any info you found from the Zapier search. 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, and Zapier will do the work for you automatically.
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(bob@gmail.com)
, and Zapier will recognize each as a separate item you can use in subsequent actions.
Then, when you build your Zap, you can select the Name and Email fields individually to add them as a new contact in Google Contacts.
With those powerful tools, combined with the hundreds of apps that connect to Zapier, you can build bots that do anything you want.
Example Bots That Help Teams Get Work Done From Slack
You could make a bot for anything—but what would actually be a useful bot for your team?
On the Zapier team, we have a number of bots both for play and productivity. The oldest slash command on our account is a GoToMeeting integration: Type /gtm
anywhere in our Slack, and a bot uses Zapier to make a new GoToMeeting link and share it in the conversation for a quick way to jump on a call with team members.
Need to reserve a server for testing? /reserve
does that in Zapier's Slack. /afk
lets us tell the team if we'll be out of office like those old AIM away messages, /compute
finds answers from Wolfram|Alpha, and /random
gives us an easy way to make decisions with random numbers. And, when it's time to unwind, /spyfall
starts a text-based game of Spyfall using direct messages to tell each player their role.
But that only scratches the surface of what bots can do in Slack. Here are some other great Zapier-powered bots for Slack—ones that just might fit needs your team has, too.
Write Invoices and Emails
Tired of writing the same emails over and over? The Billfixers team was, too, so they built a bot to write emails.
"The need that prompted both of them was trying to find ways to increase our efficiency instead of doing things by hand, but without having to add a bunch more applications to our workflow," says Billfixers co-founder Ben Kurland. "It was just time on our end that we weren't actually using to help our customer, just to do what was essentially data entry."
So, when they need to tell a customer that they just saved them money on a bill or need to send along an invoice, they can now send that person's name to their bot. It finds their info in SalesforceIQ, uses some code to calculate the savings, creates a draft email in Gmail, then shares it to Slack. "From there, a human can add finishing touches and spend their time adding meaningful interaction with our clients, rather than having to act as a robot themselves," says Kurland.
That worked so well, they also built another bot to create invoices in Freshbooks right from Slack.
Find Email Addresses and Other Data
Google is great for web searches—but when you need to find a contact's email or a specific item in your database, it's often far harder to find what you need. You have to remember which app to check, open that app, search, and finally find what you're looking for.
Or, you could just use bots in Slack to help with all of your searches, as the 90 Minute Books team does.
Their set of search bots started out with a $whois
bot built by co-founder Stuart Bell. You post someone's email address to this bot, and it searches FullContact then returns their full contact info to Slack.
They then added a bot to shorten links, and another to generate a Book ID for new book projects. And when they need more info about a book, the $gogo
bot will find all of the info about a book project from its ID.
"It gives people visibility without needing access," says Bell. "And even for the team that do have access, a quick check often saves them having to log in to a different tool.
Choose Lunch Destinations
"What's for lunch?" is a question everyone's asked—and when it's time to have a team lunch, it's a question that's hard to solve.
"Lunch is a serious matter, with Livestorm being French," says CEO Gilles Bertaux. "We usually spend a lot of time looking for a place and then debate about it. So we thought it would be nice to have a little something that could help us decide and experience new meals."
And so, they built a food bot with Zapier and Slack. They scraped the best lunch options with delivery near their office from Yelp using Import.io, and saved them to a Google Sheets spreadsheet. Then, with a Schedule Zap, they have the bot run at the same time every day, choosing a random restaurant from the spreadsheet and posting it to Slack.
It gave them handy food recommendations right when they needed them—and has inspired them to make a better curated database for more customized lunch recommendations than Yelp's top listings.
Find Bug Info Automatically
Bots even make sure the apps for shows like The Voice UK and Britan's Got Talent work perfectly. Tellybug, the team behind those and other tools to make TV shows engaging, wanted a simple way to collaborate on bug reports right from Slack.
"People would mention a bug number in Slack (or on a call) and then everyone would have to go search to look up the bug," says Tellybug CTO Malcolm Box. "This seemed automatable."
So, with a Zapier-powered Slack reply bot, the Tellybug team built a Zap that watches Slack for mentions of bugs. Whenever it finds one, it searches for the bug in Fogbugz, their bug tracking app. Then, with some filters and code to pull out the relevant info, the bot posts the correct info about the bug back into Slack.
"The bot's made it much easier to have discussions about bugs and to keep everyone on the same page when doing bug triage," says Box.
Run Standup Meetings in Chat
You need to know what each person on your team is working on, but you might not need to waste time with a full meeting. Instead, you could rely on a bot like the Robots and Pencils team does.
Each weekday, their bot posts a Standup Time reminder with questions about what they're working on. Each team member can then reply, using Zapier Named Variables to list replies to each question. A Zap then saves each response to a Google Sheets spreadsheet for a log of each virtual meeting. "From here I can put together some cool burndown charts based on other spreadsheets I have created," writes product manager Ben Myers.
Add Tasks to Your To-do List
Or, if you just need a simple way to add tasks to your project, a bot can handle that, too. Parabol CEO Jordan Husney does just that with a bot, for a quick way to add tasks to Trello that come up during their Slack-powered standup meetings.
Once again using Named Variables in Zapier, he posts a new task to his jrtask
bot, and Zapier turns that text into a new card in Trello. "Lowering the friction of capturing tasks means spending more time staying focused on the task in front of you," writes Husney—which is exactly what his Trello and Slack bot does.
Remind Your Team to Submit Timesheets
Want to spend less time reminding your team about regular tasks—and want to make sure you don't come across as nagging?
"I found myself often sending random timesheet reminder memes to my team, so I automated this," says devPHASE lead developer Matt Healy. So, with a bit of PHP code to pull a random timesheet meme from Google Images, and a Zap to post that image along with a reminder into Slack, he automated that task away.
Then, as Healy says, "hilarity and timesheet completion ensues."
For a more powerful workflow, you could make a companion timesheet tool similar to the standup meeting bot above that lets your team post their time logs to your time tracking app right from Slack.
Learn About Your Team Members
Automated Insights builds tools to turn data into stories automatically—and they wanted the same automated insights about their own team. So, during a team hackathon, director of customer experience Matt Nisonger and his team turned their employee directory into a bot.
"Our head of HR collects a lot of information about each employee's personal interests, hobbies, etc., but never did anything with it," says Nisonger. "That spawned the idea of using a Slack bot to learn interesting things about new and existing employees."
With a Typeform for to survey the team, Google Sheets to save the data, and their own Wordsmith app to turn the data into stories, they had everything needed to build a bot.
Now, when a new team member joins the team, they're asked to fill out the survey, and the bot shares info about the new team member in Slack. And if you ever want some trivia about someone on the team, just send their name to the bot and it'll reply with a fun fact about them.
That's only one of the many ways the Automated Insights team uses bots. "we probably have 10-20 various bots integrated with Slack, everything from Intercom to bug reporting to server status reporting," says Nisonger. "Some are better than others, but overall they've been positive for productivity."
Create Support Tickets Inside Conversations
Want to make sure problems are solved for your team as quickly as possible? You could build a bot for that, as the Business Insider team did.
"Our team's main communication tool is Slack, and we wanted to make it super easy for anyone on the team to submit a ticket through Slack," says Business Insider team member Kyle Dowley. All their team has to do is use their ticket bot and post the problem they're having. That has Zapier check Google Sheets for that team member's contact info, then uses it and the Slack message to create a ticket in Zendesk. When that's done, the Zap sends that team member a direct message in Slack to let them know the ticket's been created—and also gives them a link to the FAQ to perhaps help them find a solution on their own.
"For many people, using this bot is now the preferred method of submitting support requests to our team," says Dowley. "It helps to make sure all support requests are in one place with better tracking and visibility."
And it's simple to use: you can ask other team members if they're having the same problem, then turn the issue into a ticket right from the same Slack conversation.
Download a Slack Bot Cheat Sheet
Now that you know how to build a bot, it's time to build your own. But you'll need a way to keep track of each step to make sure you can make every bot you need.
Just check out the cheat sheet below—or download a PDF copy—to make sure you never forget how to build bots in Slack.
Go Build Your Own Bots!
Building your own robot is difficult. You'd need motors, controllers, gears, and dozens of other parts—not to mention time to code the robot and get it working the way you want.
Bots? They only take a few minutes, and they're free!
Just make a Zapier account, open Slack, and start building a robotic buddy who can lend you a hand. Or, try building a similar bot with Twitter, HipChat, Telegram, SMS messages, or any other chat-like tool Zapier supports. Need a simpler way to make appointments, a filtered notification tool that doesn't ding every minute, or a detailed workflow to build documents in a second? You can make a bot for that.
What will your bot do?
Made a great bot in Slack or another chat app? We'd love to hear about it in the comments below!
Honda Asimo robot photo by Satoru Fujiwara via Flickr.
source https://zapier.com/blog/how-to-build-chat-bot/
No comments:
Post a Comment