AI Integration Quick Reference
AI Integration Quick Reference
Send Message in a Thread
As mentioned in the Send a Message section, you can send a message to a User or a Group by mentioning the receiver (uid/guid) andreceiverType(user/group).
A message can be categorized as:
- Text Message
- Media Message
- Custom Message
- Interactive Message
parentMessageId on the message object to indicate which thread the message belongs to. The id specified in the parentMessageId parameter maps the message sent to the particular thread. Any message type — TextMessage, MediaMessage, CustomMessage, or Interactive Message — can be sent in a thread.
- User
- Group
TextMessage Parameters:
Response
Response
On Success — A
TextMessage object containing all details of the sent threaded message:TextMessage Object:sender Object:receiver Object:Error
Error
parentMessageId 103.
Similarly, using the parentMessageId parameter, Media and Custom Messages can be sent in threads too.
Receiving Real-Time Messages
The procedure to receive real-time messages is exactly the same as mentioned in the Receive Messages section. Use theMessageListener class to listen for incoming thread messages. Check if the received message belongs to the active thread using the parentMessageId field.
- Dart
Fetch all the messages for any particular thread.
UseMessagesRequestBuilder with parentMessageId to fetch messages belonging to a specific thread. Call fetchPrevious() to get messages (max 100 per request), returned as BaseMessage objects. Call fetchPrevious() again on the same object to get the next set.
MessagesRequestBuilder Parameters:
- Dart
Response
Response
On Success — A
List<BaseMessage> containing the fetched thread messages (each item is a BaseMessage object):BaseMessage Object:sender Object:receiver Object:Error
Error
Avoid Threaded Messages in User/Group Conversations
While fetching messages for normal user/group conversations using theMessagesRequest, the threaded messages by default will be a part of the list of messages received. Use hideReplies = true on the MessagesRequestBuilder to exclude threaded messages from the list.
- User
- Group
Response
Response
On Success — A
List<BaseMessage> containing the fetched messages excluding threaded replies (each item is a BaseMessage object):BaseMessage Object:sender Object:receiver Object:Error
Error
BaseMessage objects, excluding any messages that are replies within a thread. Only top-level messages in the conversation are returned.
Next Steps
Send Messages
Learn how to send text, media, and custom messages
Receive Messages
Handle incoming messages in real-time
Reactions
Add emoji reactions to messages
Message Structure
Understand message types and hierarchy