How to Make Slash Command Slack Bot Work in Threads?

This topic was automatically generated from Slack. You can find the original thread here.

:wave: I’ve implemented slash command / slack bot and it was fairly simple through some tuts here and there. Kudos to !But I’m having trouble figuring out how to make it work in threads. I keep getting warning in slack that bot doesn’t work on threads. Anyone has some tips?

HI ,

But I’m having trouble figuring out how to make it work in threads
you’ll need to use the parent message timestamp to make it a reply, as stated in the Thread Timestamp prop:

Provide another message's ts value to make this message a reply (e.g., if triggering on new Slack messages, enter {{event.ts}}). Avoid using a reply's ts value; use its parent instead.

To get the Parent message timestamp, you will need to use Pipedream slack trigger. If you’re building a bot, they way Pipedream currently do it is to ping the bot (.i.e Mario) into the thread, then set up a New Mention trigger and get the parent message timestamp there

Thank you but this is what I don’t understand.

• This is not to be instant, it should be triggered by slash command in thread when needed
• I’ve added a message to the channel (common user)
• Pointed workflow to such message
• When using reply_to_a_message :
◦ I’ve pointed to {{steps.trigger.event.headers["x-slack-request-timestamp"]}} (also tried before to use {{steps.trigger.context.ts}} but I got An API error occurred: invalid_thread_ts)
◦ Also pointed to {{steps.trigger.event.body.channel_name}} ( before, because i saw Select a public or private channel, or a user or group , I tried pointing to {{steps.trigger.event.body.user_name}} but I got An API error occurred: channel_not_found )
◦ When clicking Test it adds a new message to channel, not to the thread
◦ When trying to run slash command in thread I get that the bot is not compatible in threads

you can not use slash bot command into the thread, though you can ping it like this

how to setup a bot like you that answer questions when got mentioned in a thread

To set up a bot that responds when mentioned in a thread, you can follow these steps: 1. Create a new Pipedream workflow. 2. Add a “New Mention” trigger from the Slack app. 3. Add a code step or action to process the mention and generate a response. 4. Use the “Post a Message” action from the Slack app to send the response back to the thread. Make sure to connect your Slack account and configure the necessary permissions for the bot. For more details on using Slack triggers and actions, you can visit the Pipedream documentation: https://pipedream.com/docs/components/quickstarts/slack/

but the bot is not mentioned. It’s just triggered with slash command. Is that the same?

it’s not the same. For now you will need to mention the bot. See Pipedream’s Mario bot

Ok so in theory I would have to change the approach and trigger the bot on mention instead of using slash command :confused: ok, I will try to re-think things and see what I can do. Thank you for the clarification