Best answer

Respond to a message in a Slack channel in a thread

  • 21 September 2020
  • 6 replies
  • 3909 views

Userlevel 1

Hi there!

Here’s what I’m trying to do:
 

When someone sends a message in a channel (any message), I would like to trigger a response in a thread with a canned message. I know it’s possible to send a dm or to reply in the channel, but it would be ideal if it could happen in a thread on the person’s message so the channel doesn’t get too noisy. 

 

Thanks!

icon

Best answer by squibler 23 September 2020, 22:11

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

6 replies

Userlevel 3
Badge +1

Hi @jverb8 ,

This is certainly possible. It will require a Zapier account with multisteps, starter will do.

  • Use the “New Message posted to channel” slack trigger,  
  • then filter out BOTS, otherwise the reply will hit an infinite loop 😞
  • Then “Send Channel Message” making sure to use the Trigger thread timestamp in the Thread field.

 

I created a sample zap for you and shared it for you to copy.

https://zapier.com/shared/28ad5ecd691dcb034fc4367f321c29dca0020e9d

 

Daniel

Userlevel 1

I got it working! Thank you squibler!

Userlevel 1

I got it working so that when someone sends a message in the specified channel the bot autoreplies to them with a canned message in a thread. 

The issue I am running into now is that when I respond to the thread, the bot sends me the message as well. Do you know if it’s possible to only have the bot respond to a channel message, not a reply on a thread? 

Thank you!

Userlevel 3
Badge +1

Ok that can be done too, but this is a little more complicated.

What needs to happen is to determine if the message is in a thread or not.

Among the data available from Slack, there are two ts fields, one is the message timestamp, and the other the thread timestamp thread_ts.

When these both have exactly the same value then it is channel message, and when they are different it is a thread message.

So now in Zapier, we need some way to determine if they are the same or not and if they are send the canned message.

Since both the values are Numbers, we can use a Formatter step with a spreadsheet-style formula to do a comparison.
 


So Now the steps look like:
 

  • Use the “New Message posted to channel” slack trigger,  
  • Compare if the TS field value is the same as the THREAD_TS field value
  • then filter out BOTS AND Thread messages
  • Then “Send Channel Message” making sure to use the Trigger thread timestamp in the Thread field.

 

I have updated my shared ZAP with this extra requirement as an example: https://zapier.com/shared/28ad5ecd691dcb034fc4367f321c29dca0020e9d

Userlevel 1

Wow thank you so much for taking the time to look into this and explain it so thoroughly! I really appreciate it :)

Userlevel 1

For some reason, @squibler your zap doesn’t work for me:

  • If I remove the “Ts Is true” condition, then the message gets sent just fine (but I have the message duplication error mentioned above
  • If I keep the “Ts Is true” condition, then the message never gets sent.

Any idea why? Note: I’m sending the message as a user, not bot.