0

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.

asked Oct 23 at 21:50
3
  • 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. Commented Oct 23 at 22:26
  • Also, here Commented Oct 23 at 22:35
  • Yeah, I saw those. It is not the same problem. I'll clarify the question. Commented Oct 24 at 0:18

1 Answer 1

0

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 ts and no thread_ts.

    • You can then use the ts as the thread_ts to post the first reply.
  • If the message is a regular message with a thread/replies, the response will contain ts as well as thread_ts, and both values will be the same (along with other things like reply_count, reply_users_count, and latest_reply).

    • You can then use the ts / thread_ts to add a new reply.
  • If the message is a reply within a thread, the response will contain ts as well as thread_ts, and the values will be different (and there won't be any other things like reply_count, reply_users_count, and latest_reply).

    • You can then use the thread_ts to add a new reply.
answered Oct 23 at 21:50
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.