Message threading is a feature that allows users to ask questions, give feedback or add context to a specific message without disrupting the conversation flow. A message thread refers to a collection of messages grouped together, consisting of a parent message and its replies. It can have the following elements:
- A message can have a thread of replies.
- A message that has a thread of replies is a parent message.
- A parent message and its threaded replies are collectively called a message thread.
- Every message within a thread, whether it's parent or reply, is a threaded message.
- A message that doesn't have any replies is an unthreaded message.
Message threading can be widely used to help conversations flow smoothly while keeping users engaged. Message replies in a thread are common among popular messaging platforms, such as Slack and iMessage.
-
Conversation flow: Without message threading, it's hard to specify which message a channel member is responding to. Users would have to explain the context of their response, potentially confusing other channel members and distracting them from reading new messages. Message threads can help everyone stay engaged and carry on their conversation without any interferences.
-
In-depth discussions: By allowing users to reply to each other's messages in a thread, they can have more in-depth conversations on one topic. They're able to ask follow-up questions or provide more detailed explanations to a specific message without interrupting others in the channel. Message threads can encourage users to start topic-specific discussions separate from the main channel conversation.
Refer to the following limitations before using the message threading feature:
- SDK only supports 1-depth threads, meaning you can only add reply messages to non-reply messages. You can't add a reply to a reply message.
- You can only reply to text and file messages, not admin messages. However, you can add admin type messages as a reply to another message.
You can retrieve messages and their replies in a specific thread.
The load()
method of a PreviousMessageListQuery
instance returns a list of BaseMessage
objects. Using this method, you can retrieve previous messages in a specific channel. If you want to include the replies of the target messages in the results, change the value of properties in the PreviousMessageListQuery
instance.
The following table lists the properties of this class.
Property name | Type | Description |
---|---|---|
| int | Specifies the number of results to return per call. Acceptable values are 1 to 100, inclusive. The recommended value for this parameter is 30. |
| boolean | Determines whether to sort the retrieved messages in reverse order. If false, the results are in ascending order. |
| boolean | Determines whether to include the thread information of the messages in the results when the results contain parent messages. |
| string | Specifies the type of message to include in the results. |
| boolean | Determines whether to include the information of the parent messages in the result. (Default: false) |
The getMessagesByTimestamp()
method of a BaseChannel
instance returns a list of BaseMessage
objects. By using these methods, you can retrieve messages in a specific channel according to a MessageListParams
object.
The following table lists the properties of this class.
Property name | Type | Description |
---|---|---|
| int | Specifies the number of messages to retrieve that were sent before the specified timestamp or message ID. |
| int | Specifies the number of messages to retrieve that were sent after the specified timestamp or message ID. |
| boolean | Determines whether to include the messages with the matching timestamp or message ID in the results. |
| boolean | Determines whether to sort the retrieved messages in reverse order. If false, the results are in ascending order. |
| boolean | Determines whether to include the thread information of the messages in the results when the results contain parent messages. |
| string | Specifies the type of message to include in the results. |
| boolean | Determines whether to include the information of the parent messages in the result. (Default: false) |
| boolean | (Deprecated) Determines whether replies are included in the results. |
| boolean | (Deprecated) Determines whether to include the parent message text in the results when the messages are replies in a thread. If the type of the parent message is |
You can retrieve a set number of messages of previous and next messages on both sides of a specific timestamp in a channel by using the getMessagesByTimestamp()
method.
Argument | Type | Description |
---|---|---|
| long | Specifies the timestamp to be the reference point for messages to retrieve, in Unix milliseconds |
You can retrieve replies of a parent message if you can determine the parent message like the following. First, create a ThreadMessageListParams
object and set properties related to the thread where the target replies belong to.
Property name | Type | Description |
---|---|---|
| int | Specifies the number of messages to retrieve that were sent before the specified timestamp. |
| int | Specifies the number of messages to retrieve that were sent after the specified timestamp. |
| boolean | Determines whether to include the messages with the matching timestamp in the results. |
| boolean | Determines whether to sort the retrieved messages in reverse order. If false, the results are in ascending order. |
| boolean | Determines whether to include the information of the parent messages in the result. (Default: false) |
| boolean | (Deprecated) Determines whether to include the parent message text in the results when the messages are replies in a thread. If the type of the parent message is |
With the timestamp of the parent message, you can retrieve its replies by passing a TreadedMessageListParams
object as an argument to the parameter in the getThreadedMessages()
method.
Parameter name | Type | Description |
---|---|---|
| long | Specifies the timestamp to be the reference point of the retrieval, in Unix milliseconds |
You can retrieve a specific message by creating and passing the MessageRetrievalParams
object to the getMessage()
method as a parameter.
Property name | Description |
---|---|
| Type: long |
| Type: String |
| Type: String |
You can reply to a specific message in a channel through the sendUserMessage()
or sendFileMessage()
method. To do so, you should create a UserMessageCreateParams
or a FileMessageCreateParams
object and then specify the parentMessageId
property of the object. Sending reply messages works the same way as sending regular messages to a channel except replies have an additional parentMessageId
property.
When replying to a message through the sendUserMessage()
method, specify and pass a UserMessageCreateParams
object as an argument to a parameter in the method.
Property name | Type | Description |
---|---|---|
| long | Specifies the unique ID of a parent message. A parent message is a message that has a thread of replies. If the message sent through the |
When replying with a file message through the sendFileMessage()
method, specify and pass a FileMessageParams
object as an argument to a parameter in the method.
Argument | Type | Description |
---|---|---|
| string | Specifies the URL of the file to be attached to the message |
| long | Specifies the unique ID of a parent message. A parent message is a message that has a thread of replies. If the message sent through the |
You can retrieve message changelogs.
Each message changelog has distinct properties such as a timestamp of when a message was updated and a unique ID of a deleted message. Based on these two properties, you can retrieve message changelogs in two different ways: either by timestamp or by token. Both getMessageChangeLogsSinceToken()
and getMessageChangeLogsSinceTimestamp()
methods require a parameter MessageChangeLogsParams
object to determine what messages to return.
The following table lists the properties of this class.
Property | Type | Description |
---|---|---|
| boolean | Determines whether to include the thread information of the messages in the results when the results contain parent messages. |
| string | Specifies the type of message to include in the results. |
| boolean | Determines whether to include the information of the parent messages in the result. (Default: false) |
You can retrieve the message changelogs by specifying a timestamp. The results will include changelogs that were created after the specified timestamp.
Parameter name | Type | Description |
---|---|---|
| long | Specifies the timestamp to be the reference point for changelogs to retrieve in Unix milliseconds |
You can also retrieve message changelogs by specifying a token. The token is an opaque string that marks the starting point of the next page in the result set and it is included in the callback of the previous call. Based on the token, the next page will start with changelogs that were created after the specified token.
Once a reply is created or deleted from a thread, the onThreadInfoUpdated()
in GroupChannelHandler
or OpenChannelHandler
is invoked. The method returns a ThreadInfoUpdateEvent
object that has the latest information about the thread. This object needs to be applied to the parent message object.
Note: Like other messages, when a reply is created in a channel, the
onMessageReceived()
method of the channel event handler in client apps will be called.
Parameter name | Description |
---|---|
| Type: BaseChannel |
| Type: ThreadInfoUpdateEvent |
If a reply message is created, onMessageReceived()
will be called with that reply message. A user will have to find the parent message with the parentMessageID
property in that message object.
If the parent message is not in the message view stack and the user wants to get the parent message object, they can do so by calling
sb.message.getMessage(params, handler)
to retrieve the parent message object.
Once the reply message has been created, the onThreadInfoUpdated()
event handler will be called since the thread info has been changed. To update thread information, the user should find the matching parent message with targetMessageID
and use the parentMessage.applyThreadInfoUpdateEvent()
method.