AI Integration Quick Reference
AI Integration Quick Reference
MessagesRequest class fetches messages based on various parameters using the Builder design pattern.
To fetch messages:
- Create a
MessagesRequestBuilderobject - Set your desired parameters
- Call
build()to get aMessagesRequestobject - Call
fetchNext()orfetchPrevious()to retrieve messages
| Method | Description |
|---|---|
fetchNext() | Returns messages after the specified parameters |
fetchPrevious() | Returns messages before the specified parameters |
fetchPrevious()/fetchNext() repeatedly on the same object to get subsequent pages.
Filter Reference
| Method | Description | Default |
|---|---|---|
setUID(uid) | Fetch messages for a one-on-one conversation | — |
setGUID(guid) | Fetch messages for a group conversation | — |
setLimit(n) | Number of messages per request (max 100) | — |
setMessageId(id) | Fetch messages before/after a message ID | — |
setTimestamp(ts) | Fetch messages before/after a Unix timestamp | — |
setUnread(bool) | Fetch only unread messages | false |
setCategories(list) | Filter by message categories | all |
setTypes(list) | Filter by message types | all |
setParentMessageId(id) | Fetch messages in a specific thread | — |
hideReplies(bool) | Exclude threaded messages | false |
hideDeletedMessages(bool) | Exclude deleted messages | false |
hideQuotedMessages(bool) | Exclude quoted messages | false |
hideMessagesFromBlockedUsers(bool) | Exclude messages from blocked users | false |
setUpdatedAfter(ts) | Fetch messages updated after a timestamp | — |
updatesOnly(bool) | Only updated messages (use with setUpdatedAfter) | false |
setTags(list) | Filter by message tags | — |
withTags(bool) | Include tag data in response | false |
hasLinks(bool) | Only messages with links (Advanced Search) | false |
hasAttachments(bool) | Only messages with attachments (Advanced Search) | false |
hasReactions(bool) | Only messages with reactions (Advanced Search) | false |
hasMentions(bool) | Only messages with mentions (Advanced Search) | false |
setMentionedUIDs(list) | Only messages mentioning specific users (Advanced Search) | — |
setAttachmentTypes(list) | Only messages with specific attachment types (Advanced Search) | — |
Number of messages fetched
Set the number of messages to fetch per request usingsetLimit(). Maximum is 100.
- Java (User)
- Java (Group)
- Kotlin (User)
- Kotlin (Group)
Messages for a user conversation
UsesetUID() to fetch messages between the logged-in user and a specific user.
- Java
- Kotlin
Messages for a group conversation
UsesetGUID() to fetch messages from a group. The logged-in user must be a member of the group.
- Java
- Kotlin
Messages before/after a message
UsesetMessageId() to fetch messages before or after a specific message ID. Use fetchNext() to get messages after, or fetchPrevious() to get messages before.
- Java (User)
- Java (Group)
- Kotlin (User)
- Kotlin (Group)
setUID() or setGUID() to fetch messages around a specific message in a conversation.
Messages before/after a given time
UsesetTimestamp() with a Unix timestamp to fetch messages before or after a specific time.
- Java (User)
- Java (Group)
- Kotlin (User)
- Kotlin (Group)
setUID() or setGUID() to fetch messages around a specific time in a conversation.
Unread messages
UsesetUnread(true) to fetch only unread messages.
- Java (User)
- Java (Group)
- Kotlin (User)
- Kotlin (Group)
setGUID() or setUID() can be used to fetch unread messages for a particular group or user conversation respectively.
Exclude messages from blocked users
UsehideMessagesFromBlockedUsers(true) to exclude messages from users you’ve blocked. Default is false.
- Java (User)
- Java (Group)
- Kotlin (User)
- Kotlin (Group)
Updated and received messages
UsesetUpdatedAfter() with a Unix timestamp to fetch messages that were sent or updated after a specific time. Updated messages include those marked as read/delivered, edited, or deleted.
- Java (User)
- Java (Group)
- Kotlin (User)
- Kotlin (Group)
Updated messages only
UseupdatesOnly(true) with setUpdatedAfter() to fetch only updated messages (not newly received ones). This method must be used together with setUpdatedAfter().
- Java (User)
- Java (Group)
- Kotlin (User)
- Kotlin (Group)
Messages for multiple categories
UsesetCategories() with a list of category names to filter by message category. See Message structure and hierarchy for available categories.
- Java (User)
- Java (Group)
- Kotlin (User)
- Kotlin (Group)
message and custom categories. Use this to exclude categories like call and action.
Messages for multiple types
UsesetTypes() with a list of type names to filter by message type. See Message structure and hierarchy for available types.
- Java (User)
- Java (Group)
- Kotlin (User)
- Kotlin (Group)
Messages for a specific thread
UsesetParentMessageId() to fetch messages belonging to a specific thread.
- Java (User)
- Java (Group)
- Kotlin (User)
- Kotlin (Group)
Hide threaded messages in user/group conversations
UsehideReplies(true) to exclude threaded messages from the main conversation. Default is false.
- Java (User)
- Java (Group)
- Kotlin (User)
- Kotlin (Group)
Hide deleted messages in user/group conversations
UsehideDeletedMessages(true) to exclude deleted messages. Default is false.
- Java (User)
- Java (Group)
- Kotlin (User)
- Kotlin (Group)
Hide quoted messages in user/group conversations
UsehideQuotedMessages(true) to exclude quoted messages. Default is false.
- Java (User)
- Java (Group)
- Kotlin (User)
- Kotlin (Group)
Messages by tags
UsesetTags() with a list of tag names to fetch only messages with those tags.
- Java
- Kotlin
Messages with tags
UsewithTags(true) to include tag information in the response. Default is false.
When withTags(true) is set, each message’s tags field will be populated. Access tags using getTags().
| Additional Field | Getter | Return Type | Description |
|---|---|---|---|
| tags | getTags() | List<String> | Tags associated with the message |
- Java
- Kotlin
Messages with links
UsehasLinks(true) to fetch only messages containing links. Default is false.
This feature is only available with
Conversation & Advanced Search. The Conversation & Advanced Search is only available in Advanced & Custom plans. If you’re already on one of these plans, please enable the Conversation & Advanced Search from CometChat Dashboard (Open your app, navigate to Chats -> Settings -> General Configuration)- Java
- Kotlin
Messages with attachments
UsehasAttachments(true) to fetch only messages with attachments (image, audio, video, or file). Default is false.
This feature is only available with
Conversation & Advanced Search. The Conversation & Advanced Search is only available in Advanced & Custom plans. If you’re already on one of these plans, please enable the Conversation & Advanced Search from CometChat Dashboard (Open your app, navigate to Chats -> Settings -> General Configuration)- Java
- Kotlin
Messages with reactions
UsehasReactions(true) to fetch only messages that have reactions. Default is false.
This feature is only available with
Conversation & Advanced Search. The Conversation & Advanced Search is only available in Advanced & Custom plans. If you’re already on one of these plans, please enable the Conversation & Advanced Search from CometChat Dashboard (Open your app, navigate to Chats -> Settings -> General Configuration)- Java
- Kotlin
Messages with mentions
UsehasMentions(true) to fetch only messages that contain mentions. Default is false.
This feature is only available with
Conversation & Advanced Search. The Conversation & Advanced Search is only available in Advanced & Custom plans. If you’re already on one of these plans, please enable the Conversation & Advanced Search from CometChat Dashboard (Open your app, navigate to Chats -> Settings -> General Configuration)- Java
- Kotlin
Messages with particular user mentions
UsesetMentionedUIDs() with a list of UIDs to fetch only messages that mention those specific users.
This feature is only available with
Conversation & Advanced Search. The Conversation & Advanced Search is only available in Advanced & Custom plans. If you’re already on one of these plans, please enable the Conversation & Advanced Search from CometChat Dashboard (Open your app, navigate to Chats -> Settings -> General Configuration)- Java
- Kotlin
Messages with specific attachment types
UsesetAttachmentTypes() with a list of AttachmentType enum values to fetch only messages with specific attachment types.
This feature is only available with
Conversation & Advanced Search. The Conversation & Advanced Search is only available in Advanced & Custom plans. If you’re already on one of these plans, please enable the Conversation & Advanced Search from CometChat Dashboard (Open your app, navigate to Chats -> Settings -> General Configuration)- Java
- Kotlin
Next Steps
Receive Messages
Handle incoming messages with message listeners
Message Structure
Understand message categories and types
Threaded Messages
Implement threaded conversations with parent messages
Retrieve Conversations
Fetch conversation list with unread counts