slackslack-api

How to identify if a Slack message is a thread reply?


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?

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.


Solution

  • 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