Documentation Index Fetch the complete documentation index at: https://cometchat-22654f5b-docs-android-v6-beta2.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
AI Integration Quick Reference
// Fetch conversations list
ConversationsRequest request = ( ConversationsRequestBuilder ()
..limit = 30
). build ();
await request. fetchNext (
onSuccess : ( List < Conversation > conversations) {
for ( Conversation conv in conversations) {
debugPrint ( "Conversation: ${ conv . conversationId } " );
}
},
onError : ( CometChatException e) => debugPrint ( "Error: ${ e . message } " ),
);
// Get a specific conversation
CometChat . getConversation ( "UID" , "user" ,
onSuccess : ( Conversation conv) => debugPrint ( "Got: ${ conv . conversationId } " ),
onError : ( CometChatException e) => debugPrint ( "Error: ${ e . message } " ),
);
// Tag a conversation
CometChat . tagConversation ( "UID" , "user" , [ "archived" ],
onSuccess : ( Conversation conv) => debugPrint ( "Tagged: ${ conv . conversationId } " ),
onError : ( CometChatException e) => debugPrint ( "Error: ${ e . message } " ),
);
// Convert message to conversation
Conversation conversation = CometChat . getConversationFromMessage (message);
Conversations provide the last message for every one-on-one and group conversation the logged-in user is part of. Each Conversation object includes the other participant (user or group), the last message, unread counts, and optional tags. Use this to build a Recent Chats list.
Retrieve List of Conversations
In other words, as a logged-in user, how do I retrieve the latest conversations that I’ve been a part of?
To fetch the list of conversations, you can use the ConversationsRequest class. To use this class i.e. to create an object of the ConversationsRequest class, you need to use the ConversationsRequestBuilder class. The ConversationsRequestBuilder class allows you to set the parameters based on which the conversations are to be fetched.
Fetching using this builder will return Conversation objects.
ConversationsRequestBuilder Parameters
The ConversationsRequestBuilder to fetch conversations with various filters.
Property Type Description limitint?Number of conversations to fetch per request. Default is 30, max is 50. conversationTypeString?Filter by CometChatConversationType.user or CometChatConversationType.group. If not set, both types are returned. withUserAndGroupTagsbool?Include user/group tags in the response. Default is false. withTagsbool?Include conversation tags in the response. Default is false. tagsList<String>?Fetch only conversations matching the specified tags. userTagsList<String>?Fetch only user conversations where the user has the specified tags. groupTagsList<String>?Fetch only group conversations where the group has the specified tags. includeBlockedUsersbool?Include conversations with blocked users. Default is false. withBlockedInfobool?Include blocked user information (hasBlockedMe, blockedByMe). Default is false. searchKeywordString?Search conversations by user or group name. Requires Conversation & Advanced Search. unreadbool?Fetch only conversations with unread messages. Requires Conversation & Advanced Search. Default is false. setPageint?Fetch conversations from a particular page. hideAgenticbool?Exclude AI agent conversations from results. Default is false. onlyAgenticbool?Fetch only AI agent conversations. Default is false.
Set Limit
Set the number of conversations to fetch per request.
ConversationsRequest conversationRequest = ( ConversationsRequestBuilder ()
..limit = 50
). build ();
The default value for limit is 30 and the max value is 50.
Set Conversation Type
Filter by conversation type: user for one-on-one or group for group conversations. If not set, both types are returned.
ConversationsRequest conversationRequest = ( ConversationsRequestBuilder ()
..limit = 50
..conversationType = CometChatConversationType .user
). build ();
When conversations are fetched successfully, the response will include an array of Conversation objects filtered by the specified type.
Use withUserAndGroupTags = true to include user/group tags in the Conversation object. Default is false.
ConversationsRequest conversationRequest = ( ConversationsRequestBuilder ()
..limit = 50
..withUserAndGroupTags = true
). build ();
When conversations are fetched successfully, the response will include tags arrays on the conversationWith objects (user or group).
Fetch user conversations where the user has specific tags.
ConversationsRequest conversationRequest = ( ConversationsRequestBuilder ()
..limit = 50
..userTags = [ "tag1" ]
). build ();
When conversations are fetched successfully, the response will include only user conversations where the user has the specified tags.
Fetch group conversations where the group has specific tags.
ConversationsRequest conversationRequest = ( ConversationsRequestBuilder ()
..limit = 50
..groupTags = [ "tag1" ]
). build ();
When conversations are fetched successfully, the response will include only group conversations where the group has the specified tags.
Use withTags = true to include conversation tags in the response. Default is false.
ConversationsRequest conversationRequest = ( ConversationsRequestBuilder ()
..limit = 50
..withTags = true
). build ();
Fetch conversations that have specific tags.
List < String > tags = [];
tags. add ( "archived" );
ConversationsRequest conversationRequest = ( ConversationsRequestBuilder ()
..limit = 50
..tags = tags
). build ();
Include Blocked Users
Use includeBlockedUsers = true to include conversations with users you’ve blocked.
ConversationsRequest conversationRequest = ( ConversationsRequestBuilder ()
..limit = 50
..includeBlockedUsers = true
). build ();
When conversations are fetched successfully, the response includes conversations with blocked users. To also get blocked info details (blockedByMe, hasBlockedMe), set withBlockedInfo to true.
With Blocked Info
Use withBlockedInfo = true to include blocked user information in the response.
ConversationsRequest conversationRequest = ( ConversationsRequestBuilder ()
..limit = 50
..withBlockedInfo = true
). build ();
Search Conversations
Use searchKeyword to search conversations by user or group name.
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)
ConversationsRequest conversationRequest = ( ConversationsRequestBuilder ()
..limit = 50
..searchKeyword = "Hiking"
). build ();
When conversations are fetched successfully, the response includes conversations where the user or group name matches the search keyword.
Unread Conversations
Use unread = true to fetch only conversations with unread messages.
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)
ConversationsRequest conversationRequest = ( ConversationsRequestBuilder ()
..limit = 50
..unread = true
). build ();
When conversations are fetched successfully, the response includes only conversations with unread messages (unreadMessageCount > 0).
Hide Agentic Conversations
Use hideAgentic = true to exclude AI agent conversations from the list.
ConversationsRequest conversationRequest = ( ConversationsRequestBuilder ()
..limit = 50
..hideAgentic = true
). build ();
Only Agentic Conversations
Use onlyAgentic = true to fetch only AI agent conversations.
ConversationsRequest conversationRequest = ( ConversationsRequestBuilder ()
..limit = 50
..onlyAgentic = true
). build ();
hideAgentic and onlyAgentic are mutually exclusive — use only one per request.
When conversations are fetched successfully, the response will include only conversations with AI agents. Agent users have role: "@agentic" and include agent-specific metadata.
Fetch Conversations
After configuring the builder, call build() to create the request, then fetchNext() to retrieve conversations. Maximum 50 per request. Call fetchNext() repeatedly on the same object to paginate.
ConversationsRequest conversationRequest = ( ConversationsRequestBuilder ()
..limit = 50
). build ();
conversationRequest. fetchNext (
onSuccess : ( List < Conversation > conversations){
}, onError : ( CometChatException e){
});
On Success — A List<Conversation> containing conversation objects with their associated user/group and last message details:Conversation Object (per item in list): Parameter Type Description Sample Value conversationIdstring Unique conversation identifier "cometchat-uid-1_user_cometchat-uid-2"conversationTypestring Type of conversation "user"conversationWithobject User or Group the conversation is with See below ↓ lastMessageobject Last message in the conversation See below ↓ updatedAtnumber Epoch timestamp of last update 1745554729unreadMessageCountnumber Count of unread messages 2tagsarray Tags associated with the conversation []unreadMentionsCountnumber Count of unread mentions 0lastReadMessageIdnumber ID of the last read message 398latestMessageIdnumber ID of the latest message 401
conversationWith Object (User):Parameter Type Description Sample Value uidstring Unique identifier of the user "cometchat-uid-2"namestring Display name of the user "George Alan"linkstring Profile link nullavatarstring Avatar URL "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"metadataobject Custom metadata {}statusstring Online status "offline"rolestring User role "default"statusMessagestring Status message nulltagsarray User tags []hasBlockedMeboolean Whether this user has blocked the current user falseblockedByMeboolean Whether the current user has blocked this user falselastActiveAtnumber Epoch timestamp of last activity 1745550000
conversationWith Object (Group):Parameter Type Description Sample Value guidstring Unique identifier of the group "cometchat-guid-1"namestring Display name of the group "Flutter Devs"iconstring Group icon URL "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp"descriptionstring Group description "A group for Flutter developers"membersCountnumber Number of members in the group 5metadataobject Custom metadata {}joinedAtnumber Epoch timestamp when the user joined 1745500000hasJoinedboolean Whether the current user has joined truecreatedAtnumber Epoch timestamp when the group was created 1745400000ownerstring UID of the group owner "cometchat-uid-1"updatedAtnumber Epoch timestamp of last update 1745554729tagsarray Group tags []typestring Group type "public"scopestring Scope of the current user in the group "admin"passwordstring Group password (for password-protected groups) nullisBannedFromGroupboolean Whether the current user is banned false
lastMessage Object (TextMessage):Parameter Type Description Sample Value idnumber Unique message ID 401metadataobject Custom metadata attached to the message {}receiverobject Receiver user object See below ↓ editedBystring UID of the user who edited the message nullconversationIdstring Unique conversation identifier "cometchat-uid-1_user_cometchat-uid-2"sentAtnumber Epoch timestamp when the message was sent 1745554729receiverUidstring UID of the receiver "cometchat-uid-2"typestring Type of the message "text"readAtnumber Epoch timestamp when the message was read 0deletedBystring UID of the user who deleted the message nulldeliveredAtnumber Epoch timestamp when the message was delivered 1745554730deletedAtnumber Epoch timestamp when the message was deleted 0replyCountnumber Number of replies to this message 0senderobject Sender user object See below ↓ receiverTypestring Type of the receiver "user"editedAtnumber Epoch timestamp when the message was edited 0parentMessageIdnumber ID of the parent message (for threads) -1readByMeAtnumber Epoch timestamp when read by the current user 0categorystring Message category "message"deliveredToMeAtnumber Epoch timestamp when delivered to the current user 1745554730updatedAtnumber Epoch timestamp when the message was last updated 1745554729textstring The text content of the message "Hey, are you available for a call?"tagsarray List of tags associated with the message []unreadRepliesCountnumber Count of unread replies 0mentionedUsersarray List of mentioned users []hasMentionedMeboolean Whether the current user is mentioned falsereactionsarray List of reactions on the message []moderationStatusstring Moderation status of the message nullquotedMessageIdnumber ID of the quoted message null
lastMessage.sender Object:Parameter Type Description Sample Value uidstring Unique identifier of the sender "cometchat-uid-2"namestring Display name of the sender "George Alan"linkstring Profile link nullavatarstring Avatar URL "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"metadataobject Custom metadata {}statusstring Online status "offline"rolestring User role "default"statusMessagestring Status message nulltagsarray User tags []hasBlockedMeboolean Whether this user has blocked the current user falseblockedByMeboolean Whether the current user has blocked this user falselastActiveAtnumber Epoch timestamp of last activity 1745550000
lastMessage.receiver Object:Parameter Type Description Sample Value uidstring Unique identifier of the receiver "cometchat-uid-1"namestring Display name of the receiver "Andrew Joseph"linkstring Profile link nullavatarstring Avatar URL "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp"metadataobject Custom metadata {}statusstring Online status "online"rolestring User role "default"statusMessagestring Status message nulltagsarray User tags []hasBlockedMeboolean Whether this user has blocked the current user falseblockedByMeboolean Whether the current user has blocked this user falselastActiveAtnumber Epoch timestamp of last activity 1745554700
Parameter Type Description Sample Value codestring Error code identifier "ERR_CHAT_API_FAILURE"messagestring Human-readable error message "Failed to fetch the requested data."detailsstring Additional technical details "An unexpected error occurred while retrieving conversations."
The Conversation object consists of the below fields:
Field Information conversationIdID of the conversation conversationTypeType of conversation (user/group) lastMessageLast message the conversation conversationWithUser or Group object containing the details of the user or groupunreadMessageCountUnread message count for the conversation unreadMentionsCountthe count of unread mentions in the conversation. lastReadMessageIdthe ID of the last read message in the conversation.
Tag Conversation
In other words, as a logged-in user, how do I tag a conversation?
Use tagConversation() to add tags to a conversation.
Parameter Description conversationWithUID or GUID of the user/group conversationTypeuser or grouptagsArray of tags to add
String conversationWith = "cometchat-uid-1" ; //id of the user/group
String conversationType = "user" ;
List < String > tags = [];
tags. add ( "archived" );
CometChat . tagConversation (conversationWith, conversationType, tags,
onSuccess : ( Conversation conversation) {
debugPrint ( "Conversation tagged Successfully : $ conversation " );
}, onError : ( CometChatException e) {
debugPrint ( "Conversation tagging failed : ${ e . message } " );
}
);
On Success — A Conversation object containing the updated conversation with the applied tags:Conversation Object: Parameter Type Description Sample Value conversationIdstring Unique conversation identifier "cometchat-uid-1_user_cometchat-uid-2"conversationTypestring Type of conversation "user"conversationWithobject User or Group the conversation is with See below ↓ lastMessageobject Last message in the conversation See below ↓ updatedAtnumber Epoch timestamp of last update 1745554729unreadMessageCountnumber Count of unread messages 0tagsarray Tags associated with the conversation ["archived"]unreadMentionsCountnumber Count of unread mentions 0lastReadMessageIdnumber ID of the last read message 398latestMessageIdnumber ID of the latest message 401
conversationWith Object (User):Parameter Type Description Sample Value uidstring Unique identifier of the user "cometchat-uid-1"namestring Display name of the user "Andrew Joseph"linkstring Profile link nullavatarstring Avatar URL "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp"metadataobject Custom metadata {}statusstring Online status "online"rolestring User role "default"statusMessagestring Status message nulltagsarray User tags []hasBlockedMeboolean Whether this user has blocked the current user falseblockedByMeboolean Whether the current user has blocked this user falselastActiveAtnumber Epoch timestamp of last activity 1745554700
lastMessage Object (TextMessage):Parameter Type Description Sample Value idnumber Unique message ID 401metadataobject Custom metadata attached to the message {}receiverobject Receiver user object See below ↓ editedBystring UID of the user who edited the message nullconversationIdstring Unique conversation identifier "cometchat-uid-1_user_cometchat-uid-2"sentAtnumber Epoch timestamp when the message was sent 1745554729receiverUidstring UID of the receiver "cometchat-uid-1"typestring Type of the message "text"readAtnumber Epoch timestamp when the message was read 0deletedBystring UID of the user who deleted the message nulldeliveredAtnumber Epoch timestamp when the message was delivered 1745554730deletedAtnumber Epoch timestamp when the message was deleted 0replyCountnumber Number of replies to this message 0senderobject Sender user object See below ↓ receiverTypestring Type of the receiver "user"editedAtnumber Epoch timestamp when the message was edited 0parentMessageIdnumber ID of the parent message (for threads) -1readByMeAtnumber Epoch timestamp when read by the current user 0categorystring Message category "message"deliveredToMeAtnumber Epoch timestamp when delivered to the current user 1745554730updatedAtnumber Epoch timestamp when the message was last updated 1745554729textstring The text content of the message "Hey, are you available for a call?"tagsarray List of tags associated with the message []unreadRepliesCountnumber Count of unread replies 0mentionedUsersarray List of mentioned users []hasMentionedMeboolean Whether the current user is mentioned falsereactionsarray List of reactions on the message []moderationStatusstring Moderation status of the message nullquotedMessageIdnumber ID of the quoted message null
lastMessage.sender Object:Parameter Type Description Sample Value uidstring Unique identifier of the sender "cometchat-uid-1"namestring Display name of the sender "Andrew Joseph"linkstring Profile link nullavatarstring Avatar URL "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp"metadataobject Custom metadata {}statusstring Online status "online"rolestring User role "default"statusMessagestring Status message nulltagsarray User tags []hasBlockedMeboolean Whether this user has blocked the current user falseblockedByMeboolean Whether the current user has blocked this user falselastActiveAtnumber Epoch timestamp of last activity 1745554700
lastMessage.receiver Object:Parameter Type Description Sample Value uidstring Unique identifier of the receiver "cometchat-uid-1"namestring Display name of the receiver "Andrew Joseph"linkstring Profile link nullavatarstring Avatar URL "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp"metadataobject Custom metadata {}statusstring Online status "online"rolestring User role "default"statusMessagestring Status message nulltagsarray User tags []hasBlockedMeboolean Whether this user has blocked the current user falseblockedByMeboolean Whether the current user has blocked this user falselastActiveAtnumber Epoch timestamp of last activity 1745554700
Parameter Type Description Sample Value codestring Error code identifier "ERR_CHAT_API_FAILURE"messagestring Human-readable error message "Failed to tag the conversation."detailsstring Additional technical details "An unexpected error occurred while tagging the conversation."
The tags for conversations are one-way. This means that if user A tags a conversation with user B, that tag will be applied to that conversation only for user A.
Retrieve Single Conversation
In other words, as a logged-in user, how do I retrieve a specific conversation?
Use getConversation() to fetch a specific conversation.
Parameter Description conversationWithUID or GUID of the user/group conversationTypeuser or group
String conversationWith = "cometchat-uid-1" ; //id of the user/group
String conversationType = "user" ;
CometChat . getConversation (conversationWith, conversationType,
onSuccess : ( Conversation conversation) {
debugPrint ( "Fetch Conversation Successfully : $ conversation " );
}, onError : ( CometChatException e) {
debugPrint ( "Fetch Conversation failed : ${ e . message } " );
}
);
On Success — A Conversation object containing the details of the requested conversation:Conversation Object: Parameter Type Description Sample Value conversationIdstring Unique conversation identifier "cometchat-uid-1_user_cometchat-uid-2"conversationTypestring Type of conversation "user"conversationWithobject User or Group the conversation is with See below ↓ lastMessageobject Last message in the conversation See below ↓ updatedAtnumber Epoch timestamp of last update 1745554729unreadMessageCountnumber Count of unread messages 0tagsarray Tags associated with the conversation []unreadMentionsCountnumber Count of unread mentions 0lastReadMessageIdnumber ID of the last read message 398latestMessageIdnumber ID of the latest message 401
conversationWith Object (User):Parameter Type Description Sample Value uidstring Unique identifier of the user "cometchat-uid-1"namestring Display name of the user "Andrew Joseph"linkstring Profile link nullavatarstring Avatar URL "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp"metadataobject Custom metadata {}statusstring Online status "online"rolestring User role "default"statusMessagestring Status message nulltagsarray User tags []hasBlockedMeboolean Whether this user has blocked the current user falseblockedByMeboolean Whether the current user has blocked this user falselastActiveAtnumber Epoch timestamp of last activity 1745554700
lastMessage Object (TextMessage):Parameter Type Description Sample Value idnumber Unique message ID 401metadataobject Custom metadata attached to the message {}receiverobject Receiver user object See below ↓ editedBystring UID of the user who edited the message nullconversationIdstring Unique conversation identifier "cometchat-uid-1_user_cometchat-uid-2"sentAtnumber Epoch timestamp when the message was sent 1745554729receiverUidstring UID of the receiver "cometchat-uid-1"typestring Type of the message "text"readAtnumber Epoch timestamp when the message was read 0deletedBystring UID of the user who deleted the message nulldeliveredAtnumber Epoch timestamp when the message was delivered 1745554730deletedAtnumber Epoch timestamp when the message was deleted 0replyCountnumber Number of replies to this message 0senderobject Sender user object See below ↓ receiverTypestring Type of the receiver "user"editedAtnumber Epoch timestamp when the message was edited 0parentMessageIdnumber ID of the parent message (for threads) -1readByMeAtnumber Epoch timestamp when read by the current user 0categorystring Message category "message"deliveredToMeAtnumber Epoch timestamp when delivered to the current user 1745554730updatedAtnumber Epoch timestamp when the message was last updated 1745554729textstring The text content of the message "Hey, are you available for a call?"tagsarray List of tags associated with the message []unreadRepliesCountnumber Count of unread replies 0mentionedUsersarray List of mentioned users []hasMentionedMeboolean Whether the current user is mentioned falsereactionsarray List of reactions on the message []moderationStatusstring Moderation status of the message nullquotedMessageIdnumber ID of the quoted message null
lastMessage.sender Object:Parameter Type Description Sample Value uidstring Unique identifier of the sender "cometchat-uid-1"namestring Display name of the sender "Andrew Joseph"linkstring Profile link nullavatarstring Avatar URL "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp"metadataobject Custom metadata {}statusstring Online status "online"rolestring User role "default"statusMessagestring Status message nulltagsarray User tags []hasBlockedMeboolean Whether this user has blocked the current user falseblockedByMeboolean Whether the current user has blocked this user falselastActiveAtnumber Epoch timestamp of last activity 1745554700
lastMessage.receiver Object:Parameter Type Description Sample Value uidstring Unique identifier of the receiver "cometchat-uid-1"namestring Display name of the receiver "Andrew Joseph"linkstring Profile link nullavatarstring Avatar URL "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp"metadataobject Custom metadata {}statusstring Online status "online"rolestring User role "default"statusMessagestring Status message nulltagsarray User tags []hasBlockedMeboolean Whether this user has blocked the current user falseblockedByMeboolean Whether the current user has blocked this user falselastActiveAtnumber Epoch timestamp of last activity 1745554700
Parameter Type Description Sample Value codestring Error code identifier "ERR_CHAT_API_FAILURE"messagestring Human-readable error message "Failed to fetch the requested data."detailsstring Additional technical details "An unexpected error occurred while retrieving the conversation."
Convert Messages to Conversations
As per our Receive Messages guide, for real-time messages, you will always receive Message objects and not Conversation objects. Thus, you will need a mechanism to convert the Message object to a Conversation object. You can use the getConversationFromMessage method for this purpose.
Conversation conversation = CometChat . getConversationFromMessage (message);
While converting a Message object to a Conversation object, the unreadMessageCount & tags will not be available in the Conversation object. The unread message count needs to be managed in your client-side code.
Next Steps
Delete Conversation Remove conversations from the logged-in user’s list
Typing Indicators Show real-time typing status in conversations
Read Receipts Track message delivery and read status
Receive Messages Listen for incoming messages in real-time