Want to automate Chatbot replies in Slack while keeping everything organized in threads? With Zapier, you can build a workflow that monitors new messages, generates a Chatbot response, and posts the reply back to the right thread. Here’s how to set it up step by step.
Overview
This Zap does the following:
- Detects a new message in a Slack channel.
- Filters messages based on a specific condition (for example, keywords or triggers).
- Branches into two paths:
- If the message starts a new thread.
- If the message is part of an existing thread.
- Generates a Chatbot reply based on the message content.
- Posts the reply back to Slack:
- In the same thread for threaded messages.
- As a new thread for top-level messages.
Step-by-Step Guide
Step 1: Set Up the Slack Trigger
- In your Zap, select Slack as the trigger app.
- Choose the event New Message Posted to Channel.
- Connect your Slack workspace and select the specific channel you want to monitor.
- Disable bot-message triggers to avoid message loops.
Tip: This trigger captures every new message in the channel, so you’ll filter these in the next step.
Step 2: Add a Filter
- Insert a Filter step in Zapier.
- Define the condition that triggers the Chatbot response, such as:
- A specific keyword or phrase in the message text.
- A particular user sending the message.
You can skip this step if you want the Chatbot to respond to all messages.
Step 3: Branch the Workflow
Now, create two paths to handle whether the message is part of a thread or not.
- Path A: Message Has No Thread Ts (Top-Level Message)
- Add a condition to check if the message’s Thread Ts field does not exist.(view larger)
- For these top-level messages:
- Generate a Chatbot reply using the Generate Reply event of the Zapier Chatbots action and setting the Conversation Key to the value of Ts from the incoming Slack post.
- Use the message Text (Body) as input for the Chatbot.
(view larger) - Post the reply back to Slack, setting the Thread to the original message’s Ts value and the channel to the original channel.(view larger)
Result: The Chatbot starts a new thread by replying to the top-level message.
- Path B: Message Has a Thread Ts (Threaded Message)
- Add a condition to check if the message’s Thread Ts field exists.
- For these threaded messages:
- Generate a Chatbot reply using the same process as in Path A, but using the Thread Ts as a Conversation Key
(view larger) - Post the reply back to Slack, setting the Thread to the original message’s Thread Ts value and the channel to the original channel.(view larger)
Result: The Chatbot continues the conversation in the same thread.
- Generate a Chatbot reply using the same process as in Path A, but using the Thread Ts as a Conversation Key
What This Zap Does
- Top-Level Messages: The Chatbot replies in a new thread under the message.
- Threaded Messages: The Chatbot continues the conversation in the existing thread.
Why Use This Setup?
- Keeps your Slack conversations clean and organized.
- Ensures Chatbot replies are context-aware and relevant.
- Fully automates Slack message handling with minimal setup effort.
With this Zap, your Slack Chatbot will feel more natural and responsive, making it a valuable tool for your team or community.
Ready to build your Zap? Give it a try and let us know how you get on in the comments below. We'd love to hear from you!