Create a message thread
When a user replies to a message in a channel, it creates a message thread, which refers to a collection of messages consisting of a parent message and its replies. Message threading lets users ask questions, give feedback, or add context to a specific message without disrupting the flow of conversation. 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 has the following limitations.
-
Only 1-depth threads are supported, meaning you can only add reply messages to non-reply messages. You can't add a reply to a reply message.
-
Message threading is limited to text and file messages. You can't send admin messages as replies or add replies to admin messages.
You can reply to a 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 that replies have an additional parentMessageId
property.
Reply with a text message
When replying to a message through the sendUserMessage()
method, you should specify and pass a UserMessageCreateParams
object to the method as a parameter. The UserMessageCreateParams
class is derived from the BaseMessageCreateParams
class and can access all the methods and properties of BaseMessageCreateParams
.
UserMessageCreateParams
To see the comprehensive list of all available methods and properties, see UserMessageCreateParams
.
Property name | Type | Description |
---|---|---|
parentMessageId | Long | Specifies the unique ID of a parent message which has a thread of replies. If the message sent through the |
message | String | Specifies the message to send. |
replyToChannel | Boolean | Determines whether to send the message to the channel as well. To use this property, the value of |
Reply with a file message
When replying with a file message through the sendFileMessage()
method, you should specify and pass a FileMessageCreateParams
object to the method as a parameter. The FileMessageCreateParams
class is derived from the BaseMessageCreateParams
class and can access all the methods and properties of BaseMessageCreateParams
.
FileMessageCreateParams
To see the comprehensive list of all available methods and properties, see FileMessageCreateParams
.
Property name | Type | Description |
---|---|---|
parentMessageId | Long | Specifies the unique ID of a parent message which has a thread of replies. If the message sent through the |
file | File | Specifies the binary file data. When the value of |
fileName | String | Specifies the file name. (Default: |
mimeType | String | Specifies the file MIME type. (Default: |
fileSize | Int | Specifies the file size. (Default: |
When replying with more than two images or videos through the sendMultipleFilesMessage()
method, you should specify and pass a MultipleFilesMessageCreateParams
object to the method as a parameter. Just like FileMessageCreateParams
, the MultipleFilesMessageCreateParams
class is derived from the BaseMessageCreateParams
class and can access all the methods and properties of BaseMessageCreateParams
. To learn more about how to send a multiple file message, see the Send a message page.
Event handler for message threading
When a reply is created in a channel, the onMessageReceived()
and onThreadInfoUpdated()
methods of the channel event handler in client apps are called. When a reply is deleted from a thread, the onThreadInfoUpdated()
event handler is invoked. In both cases, onThreadInfoUpdated()
takes a ThreadInfoUpdateEvent
object as an argument that has the latest information about the thread. Apply the object to the parent message object through the parentMessage.applyThreadInfoUpdateEvent()
method.
List of parameters
Parameter name | Type | Description |
---|---|---|
channel | BaseChannel | Specifies the channel that has the message thread. |
threadInfoUpdateEvent | ThreadInfoUpdateEvent | Specifies a |