Threads & Replies

LAST EDIT Jul 25 2024

Threads and replies provide your users with a way to go into more detail about a specific topic.

This can be very helpful to keep the conversation organized and reduce noise. To create a thread you simply send a message with a parent_id. Have a look at the example below:

If you specify show_in_channel, the message will be visible both in a thread of replies as well as the main channel.

Messages inside a thread can also have reactions, attachments and mention as any other message.

Thread Pagination

Copied!

When you read a channel you do not receive messages inside threads. The parent message includes the count of replies which it is usually what apps show as the link to the thread screen. Reading a thread and paginating its messages works in a very similar way as paginating a channel.

Quote Message

Copied!

Instead of replying in a thread, it's also possible to quote a message. Quoting a message doesn't result in the creation of a thread; the message is quoted inline.

To quote a message, simply provide the quoted_message_id field when sending a message:

Based on the provided quoted_message_id, the quoted_message field is automatically enriched when querying channels with messages. Example response:

Quoted messages are only available one level deep. If you want to access deeply quoted messages you will have to fetch them directly either finding the message in response of channel.query() or querying message by its ID. Example: Message A quotes Message B and Message B quotes Message C. In this case it's not possible to access Message C through Message A directly. You have to fetch Message B from API in order to access it

Thread List

Copied!
SDK support for this feature is only available on javascript sdk at the moment. Other SDKs will add support for following endpoint soon.

Query Threads

Copied!

It is possible to query the list of threads that current user is participant of. This is useful to create thread list similar to what slack or discord has. Response will include threads with unread replies first, sorted by the latest reply timestamp in descending order. Threads with no unread replies will follow, also sorted by the latest reply timestamp in descending order.

You can also paginate over the thread list or request specific number of latest replies per thread.

Following is the list of supported options for querying threads:

nametypedescriptiondefaultoptional
reply_limitnumberNumber of latest replies to fetch per thread2
participant_limitnumberNumber of thread participants to request per thread100
limitnumberMaximum number of threads to return in response10
watchbooleanIf true, all the channels corresponding to threads returned in response will be watchedtrue
member_limitnumberNumber of members to request per thread channel100

Event Handling Of Thread List

Copied!

Only participants of the thread receive an event whenever there is a new reply on the thread - notification.thread_message_new. The content of this event is similar to message.new event.

Updates to the thread messages should be handled as usual via message.updated and message.deleted event

Minimalistic React JS example of how to use threads and update the UI when a new message is added to a thread can be found in the linked gist

Get Thread By ID

Copied!

This endpoint returns a thread by the given threadId.

Update Thread Title and Custom Data

Copied!

You can assign a title and any additional custom data to each thread.

Similarly to remove any custom property from thread:

Threads Unread Count

Copied!

Total number of unread threads is available in response of connectUser endpoint

If you would like to mark specific thread as read or unread, you can do that as following

To get unread count per thread for a current user, you can use the getUnreadCount endpoint as following