Skip to main content

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:

  1. Detects a new message in a Slack channel.
  2. Filters messages based on a specific condition (for example, keywords or triggers).
  3. Branches into two paths:
    • If the message starts a new thread.
    • If the message is part of an existing thread.
  4. Generates a Chatbot reply based on the message content.
  5. Posts the reply back to Slack:
    • In the same thread for threaded messages.
    • As a new thread for top-level messages.

AD_4nXd6oi2k4INPic4gwzZiBjc0rBickdUC_qMB8hx4hKuPY_zlXAfpsEYsgd9mhbe6JLwMOSK4u5-JWJyug0ev281EmYuO7ilb4wu4Fan3I-9eG61uwhK5R_x31vB_ji9JaO1T9NrS?key=xr7nKBP_CJ30tKBy59pMLr-g

(view larger)

Step-by-Step Guide

Step 1: Set Up the Slack Trigger

  1. In your Zap, select Slack as the trigger app.
  2. Choose the event New Message Posted to Channel.
  3. Connect your Slack workspace and select the specific channel you want to monitor.
  4. 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.

AD_4nXfLyc20Pzvt5-BEHx1di3rSEhkvwFaev9PZi4Tpx_VtKn-RitxMsbWp8z2BKqv3jvhJHy_bdxrYLOiNyOfrBQ3O_MA-O7ssSN47eVwnD7-VsAl8nuVZLqMhMaSXkgH-3cWSIdfy?key=xr7nKBP_CJ30tKBy59pMLr-g

(view larger)

Step 2: Add a Filter

  1. Insert a Filter step in Zapier.
  2. 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.

AD_4nXde6P029eNOThMxT6A1HBpffIxVXZMmIMX_yjJcJ_xU-zfezrD9pNiybRu3KGvK8z1C68z2RDWgrEYRZWEVSzkfOMbpkedkUMCcDPJL5mQtspayO1gblMksMjIP7zg910c5alpE?key=xr7nKBP_CJ30tKBy59pMLr-g

(view larger)

Step 3: Branch the Workflow

Now, create two paths to handle whether the message is part of a thread or not.

  1. 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.AD_4nXfrt9xV0gXN6mfx1IUBYDfNZ0aQ1Go5FhTWdZOFZdNd3h-iFWCLBkWUT1YJlrUt0U8ECK91fXlPREPgEMaVRBC3v94489AHoqzll94gng4hUMTmo38FlinbiJ7bt7Ib4kQ0yo800A?key=xr7nKBP_CJ30tKBy59pMLr-g(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.

        AD_4nXcKj-9JH4Ufiyzo6nayh1wpbgUvddfaZPQwRBlTgINwARmZz2XCfLBxF6V8_VyJAW_TY52XXovGoy5cL77G24P6i2iXVHHdOjFZiVELxQ40CvUWNxvgpjMOLTk6m7noEqFu4RWF6Q?key=xr7nKBP_CJ30tKBy59pMLr-g(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.AD_4nXevHqLCYTifXLwrNhA-EMjHwioMXkrq7kBp8BWB572cloXFH2VIs0ibGIsuOQox2pNAFNr8CzvCLVlp1okDuLkQvvc38y68eDtpWMZsdWIo79COOc2Sg5H0oL4AP70-8EmdzCR6ZA?key=xr7nKBP_CJ30tKBy59pMLr-g(view larger)

        Result: The Chatbot starts a new thread by replying to the top-level message.
  2. 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
        AD_4nXdST8cE-4xZNAqtaEW2t_7QqysdVDwYtxFaKQIryrk29tEVI2fmnUHXdwVItV-Br6tkDMRgl6IaZ4XYv1pqCvGZUimvze8LIkvTQL8OUuD6RyCSsjniyjkC7-W0pp8Z2qLCZ7N_lw?key=xr7nKBP_CJ30tKBy59pMLr-g(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.AD_4nXcS6D31KD7-sxCu005HjOimmulCiSYpGGZ52k0oz4Kj4vBdmgtF0LNfc6iuRRltVanZ-p4rmp93xU9P79eEwX4rcU9PShIusYxCdUvJOMKhZQm4Z0wpwsrSsTk0MoaqSjVvlnQuOg?key=xr7nKBP_CJ30tKBy59pMLr-g(view larger)

        Result: The Chatbot continues the conversation in the same thread.

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! 🙂

Be the first to reply!

Reply