Skip to content

How to build your own Slack bot

By Justin Pot · October 24, 2022
how-to-build-chat-bot primary img

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.

Zapier is the leader in workflow automation—integrating with thousands of apps from partners like Google, Salesforce, and Microsoft. Use interfaces, data tables, and logic to build secure, automated systems for your business-critical workflows across your organization's technology stack. Learn more.

In this article, we'll outline how to make all three kinds of bots using Zapier, a tool that connects apps without any code.

This article focuses on making bots in Slack, but you can use Zapier to make bots with the other tools you use, too. Here's how to build a chatbot with team chat apps like Discord, Microsoft Teams, and more.

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.

Slackbot response for referrals

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:

Slackbot reply in action

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

First you'll need to create a Zapier account or log in to your Zapier account.

Then, click the + Create a Zap button in the top left corner, and select Slack as your trigger app.

New Message posted anywhere in Slack

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.

Next, you'll need to connect your Slack account to Zapier by clicking + Connect a new account. Once you've connected your account, select it from the dropdown menu and click Continue.

Next, you'll be asked if you want your trigger to apply to bot messages. Since you're creating a bot yourself, you'll want to choose No and click Continue.

Then, click Test Trigger so Zapier can create a test event to make sure the trigger is working properly. Once the test runs successfully, click Continue.

Now you'll need a filter to watch for a specific term—otherwise, your bot would run every time anything is posted to Slack. For your action app, choose Filter by Zapier.

Filter option in Zapier

In the filter settings, have it watch the Text field for the term you want.

Filtering your Slack messages

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 the channel name from your original Slack message, so the reply will end up in the same spot.

customized message in Slack

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. When everything looks good, you're ready to use your Zap and 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.

Formatter in Zapier

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. When this Zap is running, 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.

Trello Zap

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.

Trello fields in Zapier

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 we recommend. Click the button next to a Zap you'd like to try and you can get started.

Send new Gmail emails as Slack channel messages

  • Gmail logo
  • Slack logo
Gmail + Slack
More details
    Don't waste your time manually checking email. With this Gmail integration, you can forward each new email in your Google inbox to a specified Slack channel! Learn more in our

    Send Slack channel messages for new Google Calendar events

    • Google Calendar logo
    • Slack logo
    Google Calendar + Slack
    More details
      "Heads up! Team meeting starts in 10 minutes." This Zap will be sure you and your team are ready for the next event with a Slack notification, automatically sent ten minutes before any new scheduled event starts on your Google Calendar.

      Share new RSS items in Slack

      • RSS by Zapier logo
      • Slack logo
      RSS by Zapier + Slack
      More details
        Automatically notify your team in Slack when a new item is published in an RSS feed of your choice. Customize the Slack message, too, showing the author, source, link to the article, and more.

        How to build a Slack slash command bot

        Add Slack App

        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.

        Create Slash Command for Slack bot

        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.

        Webhooks for Zapier

        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.

        Adding the Webhook URL

        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.

        Slash command in Slack

        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.

        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.

        Google Contact search

        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.

        Channel ID field

        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.

        Select correct Slack channel

        Test the Zap, and you'll get the response in Slack you wanted.

        Bot response in Slack

        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(bob@gmail.com), and Zapier will recognize each as a separate item you can use in subsequent actions.

        How to build a chatbot with your other chat apps

        You can use Zapier to build notification bots in any of the tools you use to get work done. Just connect the app you’d like to be notified about—like your CRM, support ticket tool, or to-do list app—to the team chat app where you'd like to receive notifications, like Discord, Microsoft Teams, or Google Chat. Here are a few popular ways to build your own chatbot:

        Get notifications for tasks

        Send Discord messages with new Trello cards

        • Trello logo
        • Discord logo
        Trello + Discord
        More details
          Keeping your followers engaged in a project is important, but it also requires a lot of time-consuming communication. Save yourself some effort when you use this integration, which automatically posts a message to a specified Discord channel when a new card is added in Trello. Make sure everyone stays in the know, hands free!

          Send Discord channel messages with new Google Sheets rows

          • Google Sheets logo
          • Discord logo
          Google Sheets + Discord
          More details
            Need to send some bulk messages but don't want to waste time copying and pasting again and again? We have a solution! Create a Google Sheets spreadsheets for all the messages you need to send. Then set up this integration and new rows will send Discord channel messages automatically. Get all your messages out in one simple step.

            Send messages in Microsoft Teams from new Airtable records

            • Airtable logo
            • Microsoft Teams logo
            Airtable + Microsoft Teams
            More details
              Organization and communication can feel like two separate workflows, but why not do both at once? This integration lets you do exactly that, automatically sending new messages within a Microsoft Teams channel when new records become available in Airtable. Collaborate on tasks as you update your database to double your productivity!

              Get ChatWork notifications for new or moved Trello cards

              • Trello logo
              • Chatwork logo
              Trello + Chatwork
              More details
                Managing tasks within the team is challenging because individuals have different ways to manage their tasks. The ChatWork and Trello integration is one solution to increase collaboration between your team members. When you add new cards on Trello, Zapier automatically sends a message to ChatWork’s groupchat, so all group members are notified about the task.

                Get notifications for leads

                Send Discord messages with new Google Forms responses

                • Google Forms logo
                • Discord logo
                Google Forms + Discord
                More details
                  Keeping your followers engaged means staying responsive to feedback. That also means a lot of time spent copying and pasting, which is where this integration can help. Automatically send a message on a specified Discord channel whenever a new Google Forms response is recorded in a spreadsheet!

                  Post new and updated ClickFunnel leads to Microsoft Team channels

                  • ClickFunnels Classic logo
                  • Microsoft Teams logo
                  ClickFunnels Classic + Microsoft Teams
                  More details
                    Having trouble keeping your team informed while also managing marketing strategy and tracking leads? Make sure your marketing team stays up to date with everything you do! Whenever there's activity for a ClickFunnel contact, such as new contacts or edits to existing ones, this integration automatically posts messages to your team in Microsoft Teams. Let your team handle the rest from there.

                    Get notifications for meetings and events

                    Post to Microsoft Teams channels when new Google Calendar events start

                    • Google Calendar logo
                    • Microsoft Teams logo
                    Google Calendar + Microsoft Teams
                    More details
                      The more meetings you have on a growing team, the harder it can be to stay on top of them. Let us help bring everyone where they need to be by sending messages automatically to a channel in Microsoft Teams whenever new events start in Google Calendar. Now, everyone will be on time and prepared for whatever's on the calendar.

                      Create ChatWork message from Google Calendar events

                      • Google Calendar logo
                      • Chatwork logo
                      Google Calendar + Chatwork
                      More details
                        Instead of receiving email reminders for a calendar event, use Zapier to get notifications on ChatWork before the calendar event starts. Once you set up this Chatwork - Google Calendar integration, you will never scramble to prepare for meetings.

                        Post new approaching Google Calendar events to Google Chat

                        • Google Calendar logo
                        • Google Chat logo
                        Google Calendar + Google Chat
                        More details
                          This integration will effortlessly ensure that you and your team is ready for the next event. Once it's active, this Zap will automatically post a custom notification to Google Chat for each new approaching Google Calendar event.

                          You can build a bot for any scenario. Want to know when team members are on call? Or when your coworkers are out of the office? The possibilities are endless.

                          The original version of this article was published in March 2018 by Matthew Guay. It was most recently updated in October 2022 by Will Harris to add in new screenshots and instructions.

                          Get productivity tips delivered straight to your inbox

                          We’ll email you 1-3 times per week—and never share your information.

                          Related articles

                          Improve your productivity automatically. Use Zapier to get your apps working together.

                          A Zap with the trigger 'When I get a new lead from Facebook,' and the action 'Notify my team in Slack'