Skip to main content
Threaded messages (or threads) are messages started from a particular parent message. Each thread is attached to a parent message.

Send Message in a Thread

Any message type (Text, Media, or Custom) can be sent in a thread. Set the parentMessageId using setParentMessageId() to indicate which thread the message belongs to.
The parentMessageId is dynamic and corresponds to the actual id of the parent message you want to reply to. In the code examples below, we use placeholder values like 100 or 1, but in practice, you’ll use the actual message ID obtained from your message list or real-time listener.
The above snippet sends “Hello” in the thread with parentMessageId 100. Media and Custom messages can also be sent in threads using setParentMessageId().

Receiving Real-Time Messages

Use MessageListener to receive real-time thread messages. Check if the received message belongs to the active thread using getParentMessageId().

Fetch all the messages for any particular thread.

Use MessagesRequestBuilder with setParentMessageId() to fetch messages belonging to a specific thread. Call fetchPrevious() to get messages (max 100 per request).
The fetchPrevious() method returns an array of BaseMessage objects representing thread replies.

Avoid Threaded Messages in User/Group Conversations

Use hideReplies(true) to exclude threaded messages when fetching messages for a conversation.
The response is an array of BaseMessage objects, excluding any messages that are replies within a thread. Only top-level messages in the conversation are returned.
Always remove message listeners when they’re no longer needed (e.g., on component unmount or page navigation). Failing to remove listeners can cause memory leaks and duplicate event handling.

Next Steps

Send Messages

Send text, media, and custom messages to users and groups

Receive Messages

Listen for incoming messages in real-time and fetch missed messages

Reactions

Add emoji reactions to messages

Message Filtering

Advanced message filtering with RequestBuilder