How to Respond to a Slack Action in a Thread: Slack Interactive Messages API
I’ve been trying to wrap my head around sending a reaction message not as a separate channel message, but as a threaded reply to the original message.
Slack seems to have a quite disorganized documentation repository with at least 4 different places where API for responding to Slack interactions.
- Interactivity Api Doc
- Bolt Javascript Doc
- Legacy Interactive Messages Doc
- Slack Node SDK Documentation (Looks like an early Bolt)
Funnily, all of the above describe the same API, yet none of them have full documentation for the response_url
HTTP endpoint that is being sent as a webhook for reacting to a Slack Action.
Answer from the Support
Thanks to the support it was revealed, that there is, indeed, a way to send the response message as a threaded reply:
If you want to respond in the thread, you need to set the
response_type
toin_channel
and thethread_ts
value to be thets
value sent with the interaction payload.
The code for such integration should look similar to the below:
const slackReply = await request({
url: payload.response_url,
method: "POST",
json: {
thread_ts: payload.container.message_ts,
text: "Hello World!",
response_type: "in_channel",
replace_original: false
}
})
Make sure to also add replace_original: false
to the updated request, as otherwise, you will get the original message replaced.
After some additional investigation, I also found the documentation for this field in some archives. It looks like Slack docs have overlooked this important parameter.
Follow my Twitter account for more dev, entrepreneurial and #BuildInPublic advice.