Using the ts of a Slack message (e.g. 1234567890.123456), how can I know if that message is reply in a thread or a regular message in a channel?
- If if is in a thread, I want to reply to the thread.
- Otherwise, I want to start a thread (post a first reply).
This is not about how to post a message in a thread, which is easy. It is about how to identify whether a specific message is a regular message or a thread reply (because surprisingly, the Slack API documentation makes this extremely confusing).
More specifically, Slack mentions in multiple places to use the conversation.history endpoint in order to retrieve a single message, but that method is unable to retrieve messages from threads.
See more details in this GitHub issue.
-
This question is similar to: How to make my slackbot reply in a thread, instead of to entire channel in Slack. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem.devlin carnate– devlin carnate2025年10月23日 22:26:08 +00:00Commented Oct 23 at 22:26
-
Also, heredevlin carnate– devlin carnate2025年10月23日 22:35:44 +00:00Commented Oct 23 at 22:35
-
Yeah, I saw those. It is not the same problem. I'll clarify the question.Marco Roy– Marco Roy2025年10月24日 00:18:55 +00:00Commented Oct 24 at 0:18
1 Answer 1
The conversations.replies API endpoint is the way to go.
It's very simple, using the ts of any message:
https://slack.com/api/conversations.replies?channel=C1C1C1C1C1&ts=1234567890.123456
If the message is a regular message without thread/replies, the response will only contain
tsand nothread_ts.- You can then use the
tsas thethread_tsto post the first reply.
- You can then use the
If the message is a regular message with a thread/replies, the response will contain
tsas well asthread_ts, and both values will be the same (along with other things likereply_count,reply_users_count, andlatest_reply).- You can then use the
ts/thread_tsto add a new reply.
- You can then use the
If the message is a reply within a thread, the response will contain
tsas well asthread_ts, and the values will be different (and there won't be any other things likereply_count,reply_users_count, andlatest_reply).- You can then use the
thread_tsto add a new reply.
- You can then use the