AI Integration Quick Reference
AI Integration Quick Reference
Send Message in a Thread
Any message type (Text, Media, or Custom) can be sent in a thread. Set theparentMessageId using setParentMessageId() to indicate which thread the message belongs to.
- User
- TypeScript
parentMessageId 100. Media and Custom messages can also be sent in threads using setParentMessageId().
Receiving Real-Time Messages
UseMessageListener to receive real-time thread messages. Check if the received message belongs to the active thread using getParentMessageId().
- Message Listener
- TypeScript
Fetch all the messages for any particular thread.
UseMessagesRequestBuilder with setParentMessageId() to fetch messages belonging to a specific thread. Call fetchPrevious() to get messages (max 100 per request).
- Fetch all message for a thread
- TypeScript
fetchPrevious() method returns an array of BaseMessage objects representing thread replies. Access the data using getter methods:
| Field | Getter | Return Type | Description |
|---|---|---|---|
| id | getId() | number | Unique message ID |
| sender | getSender() | User | The user who sent the message |
| type | getType() | string | Message type (text, image, custom, etc.) |
| sentAt | getSentAt() | number | Timestamp when the message was sent |
| parentMessageId | getParentMessageId() | number | ID of the parent message this reply belongs to |
| replyCount | getReplyCount() | number | Number of replies on the parent message |
Avoid Threaded Messages in User/Group Conversations
UsehideReplies(true) to exclude threaded messages when fetching messages for a conversation.
- User
- Group
- TypeScript (User)
- TypeScript (Group)
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