Skip to main content

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.

// 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

Available via: SDK | REST API | UI Kits
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.
PropertyTypeDescription
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.

With User and Group Tags

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).

Set User Tags

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.

Set Group 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.

With Tags

Use withTags = true to include conversation tags in the response. Default is false.
ConversationsRequest conversationRequest = (ConversationsRequestBuilder()
  ..limit = 50
  ..withTags = true
).build();

Set Tags

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):
ParameterTypeDescriptionSample Value
conversationIdstringUnique conversation identifier"cometchat-uid-1_user_cometchat-uid-2"
conversationTypestringType of conversation"user"
conversationWithobjectUser or Group the conversation is withSee below ↓
lastMessageobjectLast message in the conversationSee below ↓
updatedAtnumberEpoch timestamp of last update1745554729
unreadMessageCountnumberCount of unread messages2
tagsarrayTags associated with the conversation[]
unreadMentionsCountnumberCount of unread mentions0
lastReadMessageIdnumberID of the last read message398
latestMessageIdnumberID of the latest message401

conversationWith Object (User):
ParameterTypeDescriptionSample Value
uidstringUnique identifier of the user"cometchat-uid-2"
namestringDisplay name of the user"George Alan"
linkstringProfile linknull
avatarstringAvatar URL"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"
metadataobjectCustom metadata{}
statusstringOnline status"offline"
rolestringUser role"default"
statusMessagestringStatus messagenull
tagsarrayUser tags[]
hasBlockedMebooleanWhether this user has blocked the current userfalse
blockedByMebooleanWhether the current user has blocked this userfalse
lastActiveAtnumberEpoch timestamp of last activity1745550000

conversationWith Object (Group):
ParameterTypeDescriptionSample Value
guidstringUnique identifier of the group"cometchat-guid-1"
namestringDisplay name of the group"Flutter Devs"
iconstringGroup icon URL"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp"
descriptionstringGroup description"A group for Flutter developers"
membersCountnumberNumber of members in the group5
metadataobjectCustom metadata{}
joinedAtnumberEpoch timestamp when the user joined1745500000
hasJoinedbooleanWhether the current user has joinedtrue
createdAtnumberEpoch timestamp when the group was created1745400000
ownerstringUID of the group owner"cometchat-uid-1"
updatedAtnumberEpoch timestamp of last update1745554729
tagsarrayGroup tags[]
typestringGroup type"public"
scopestringScope of the current user in the group"admin"
passwordstringGroup password (for password-protected groups)null
isBannedFromGroupbooleanWhether the current user is bannedfalse

lastMessage Object (TextMessage):
ParameterTypeDescriptionSample Value
idnumberUnique message ID401
metadataobjectCustom metadata attached to the message{}
receiverobjectReceiver user objectSee below ↓
editedBystringUID of the user who edited the messagenull
conversationIdstringUnique conversation identifier"cometchat-uid-1_user_cometchat-uid-2"
sentAtnumberEpoch timestamp when the message was sent1745554729
receiverUidstringUID of the receiver"cometchat-uid-2"
typestringType of the message"text"
readAtnumberEpoch timestamp when the message was read0
deletedBystringUID of the user who deleted the messagenull
deliveredAtnumberEpoch timestamp when the message was delivered1745554730
deletedAtnumberEpoch timestamp when the message was deleted0
replyCountnumberNumber of replies to this message0
senderobjectSender user objectSee below ↓
receiverTypestringType of the receiver"user"
editedAtnumberEpoch timestamp when the message was edited0
parentMessageIdnumberID of the parent message (for threads)-1
readByMeAtnumberEpoch timestamp when read by the current user0
categorystringMessage category"message"
deliveredToMeAtnumberEpoch timestamp when delivered to the current user1745554730
updatedAtnumberEpoch timestamp when the message was last updated1745554729
textstringThe text content of the message"Hey, are you available for a call?"
tagsarrayList of tags associated with the message[]
unreadRepliesCountnumberCount of unread replies0
mentionedUsersarrayList of mentioned users[]
hasMentionedMebooleanWhether the current user is mentionedfalse
reactionsarrayList of reactions on the message[]
moderationStatusstringModeration status of the messagenull
quotedMessageIdnumberID of the quoted messagenull

lastMessage.sender Object:
ParameterTypeDescriptionSample Value
uidstringUnique identifier of the sender"cometchat-uid-2"
namestringDisplay name of the sender"George Alan"
linkstringProfile linknull
avatarstringAvatar URL"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"
metadataobjectCustom metadata{}
statusstringOnline status"offline"
rolestringUser role"default"
statusMessagestringStatus messagenull
tagsarrayUser tags[]
hasBlockedMebooleanWhether this user has blocked the current userfalse
blockedByMebooleanWhether the current user has blocked this userfalse
lastActiveAtnumberEpoch timestamp of last activity1745550000

lastMessage.receiver Object:
ParameterTypeDescriptionSample Value
uidstringUnique identifier of the receiver"cometchat-uid-1"
namestringDisplay name of the receiver"Andrew Joseph"
linkstringProfile linknull
avatarstringAvatar URL"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp"
metadataobjectCustom metadata{}
statusstringOnline status"online"
rolestringUser role"default"
statusMessagestringStatus messagenull
tagsarrayUser tags[]
hasBlockedMebooleanWhether this user has blocked the current userfalse
blockedByMebooleanWhether the current user has blocked this userfalse
lastActiveAtnumberEpoch timestamp of last activity1745554700
ParameterTypeDescriptionSample Value
codestringError code identifier"ERR_CHAT_API_FAILURE"
messagestringHuman-readable error message"Failed to fetch the requested data."
detailsstringAdditional technical details"An unexpected error occurred while retrieving conversations."
The Conversation object consists of the below fields:
FieldInformation
conversationIdID of the conversation
conversationTypeType of conversation (user/group)
lastMessageLast message the conversation
conversationWithUser or Group object containing the details of the user or group
unreadMessageCountUnread 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.
ParameterDescription
conversationWithUID or GUID of the user/group
conversationTypeuser or group
tagsArray 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:
ParameterTypeDescriptionSample Value
conversationIdstringUnique conversation identifier"cometchat-uid-1_user_cometchat-uid-2"
conversationTypestringType of conversation"user"
conversationWithobjectUser or Group the conversation is withSee below ↓
lastMessageobjectLast message in the conversationSee below ↓
updatedAtnumberEpoch timestamp of last update1745554729
unreadMessageCountnumberCount of unread messages0
tagsarrayTags associated with the conversation["archived"]
unreadMentionsCountnumberCount of unread mentions0
lastReadMessageIdnumberID of the last read message398
latestMessageIdnumberID of the latest message401

conversationWith Object (User):
ParameterTypeDescriptionSample Value
uidstringUnique identifier of the user"cometchat-uid-1"
namestringDisplay name of the user"Andrew Joseph"
linkstringProfile linknull
avatarstringAvatar URL"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp"
metadataobjectCustom metadata{}
statusstringOnline status"online"
rolestringUser role"default"
statusMessagestringStatus messagenull
tagsarrayUser tags[]
hasBlockedMebooleanWhether this user has blocked the current userfalse
blockedByMebooleanWhether the current user has blocked this userfalse
lastActiveAtnumberEpoch timestamp of last activity1745554700

lastMessage Object (TextMessage):
ParameterTypeDescriptionSample Value
idnumberUnique message ID401
metadataobjectCustom metadata attached to the message{}
receiverobjectReceiver user objectSee below ↓
editedBystringUID of the user who edited the messagenull
conversationIdstringUnique conversation identifier"cometchat-uid-1_user_cometchat-uid-2"
sentAtnumberEpoch timestamp when the message was sent1745554729
receiverUidstringUID of the receiver"cometchat-uid-1"
typestringType of the message"text"
readAtnumberEpoch timestamp when the message was read0
deletedBystringUID of the user who deleted the messagenull
deliveredAtnumberEpoch timestamp when the message was delivered1745554730
deletedAtnumberEpoch timestamp when the message was deleted0
replyCountnumberNumber of replies to this message0
senderobjectSender user objectSee below ↓
receiverTypestringType of the receiver"user"
editedAtnumberEpoch timestamp when the message was edited0
parentMessageIdnumberID of the parent message (for threads)-1
readByMeAtnumberEpoch timestamp when read by the current user0
categorystringMessage category"message"
deliveredToMeAtnumberEpoch timestamp when delivered to the current user1745554730
updatedAtnumberEpoch timestamp when the message was last updated1745554729
textstringThe text content of the message"Hey, are you available for a call?"
tagsarrayList of tags associated with the message[]
unreadRepliesCountnumberCount of unread replies0
mentionedUsersarrayList of mentioned users[]
hasMentionedMebooleanWhether the current user is mentionedfalse
reactionsarrayList of reactions on the message[]
moderationStatusstringModeration status of the messagenull
quotedMessageIdnumberID of the quoted messagenull

lastMessage.sender Object:
ParameterTypeDescriptionSample Value
uidstringUnique identifier of the sender"cometchat-uid-1"
namestringDisplay name of the sender"Andrew Joseph"
linkstringProfile linknull
avatarstringAvatar URL"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp"
metadataobjectCustom metadata{}
statusstringOnline status"online"
rolestringUser role"default"
statusMessagestringStatus messagenull
tagsarrayUser tags[]
hasBlockedMebooleanWhether this user has blocked the current userfalse
blockedByMebooleanWhether the current user has blocked this userfalse
lastActiveAtnumberEpoch timestamp of last activity1745554700

lastMessage.receiver Object:
ParameterTypeDescriptionSample Value
uidstringUnique identifier of the receiver"cometchat-uid-1"
namestringDisplay name of the receiver"Andrew Joseph"
linkstringProfile linknull
avatarstringAvatar URL"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp"
metadataobjectCustom metadata{}
statusstringOnline status"online"
rolestringUser role"default"
statusMessagestringStatus messagenull
tagsarrayUser tags[]
hasBlockedMebooleanWhether this user has blocked the current userfalse
blockedByMebooleanWhether the current user has blocked this userfalse
lastActiveAtnumberEpoch timestamp of last activity1745554700
ParameterTypeDescriptionSample Value
codestringError code identifier"ERR_CHAT_API_FAILURE"
messagestringHuman-readable error message"Failed to tag the conversation."
detailsstringAdditional 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.
ParameterDescription
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:
ParameterTypeDescriptionSample Value
conversationIdstringUnique conversation identifier"cometchat-uid-1_user_cometchat-uid-2"
conversationTypestringType of conversation"user"
conversationWithobjectUser or Group the conversation is withSee below ↓
lastMessageobjectLast message in the conversationSee below ↓
updatedAtnumberEpoch timestamp of last update1745554729
unreadMessageCountnumberCount of unread messages0
tagsarrayTags associated with the conversation[]
unreadMentionsCountnumberCount of unread mentions0
lastReadMessageIdnumberID of the last read message398
latestMessageIdnumberID of the latest message401

conversationWith Object (User):
ParameterTypeDescriptionSample Value
uidstringUnique identifier of the user"cometchat-uid-1"
namestringDisplay name of the user"Andrew Joseph"
linkstringProfile linknull
avatarstringAvatar URL"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp"
metadataobjectCustom metadata{}
statusstringOnline status"online"
rolestringUser role"default"
statusMessagestringStatus messagenull
tagsarrayUser tags[]
hasBlockedMebooleanWhether this user has blocked the current userfalse
blockedByMebooleanWhether the current user has blocked this userfalse
lastActiveAtnumberEpoch timestamp of last activity1745554700

lastMessage Object (TextMessage):
ParameterTypeDescriptionSample Value
idnumberUnique message ID401
metadataobjectCustom metadata attached to the message{}
receiverobjectReceiver user objectSee below ↓
editedBystringUID of the user who edited the messagenull
conversationIdstringUnique conversation identifier"cometchat-uid-1_user_cometchat-uid-2"
sentAtnumberEpoch timestamp when the message was sent1745554729
receiverUidstringUID of the receiver"cometchat-uid-1"
typestringType of the message"text"
readAtnumberEpoch timestamp when the message was read0
deletedBystringUID of the user who deleted the messagenull
deliveredAtnumberEpoch timestamp when the message was delivered1745554730
deletedAtnumberEpoch timestamp when the message was deleted0
replyCountnumberNumber of replies to this message0
senderobjectSender user objectSee below ↓
receiverTypestringType of the receiver"user"
editedAtnumberEpoch timestamp when the message was edited0
parentMessageIdnumberID of the parent message (for threads)-1
readByMeAtnumberEpoch timestamp when read by the current user0
categorystringMessage category"message"
deliveredToMeAtnumberEpoch timestamp when delivered to the current user1745554730
updatedAtnumberEpoch timestamp when the message was last updated1745554729
textstringThe text content of the message"Hey, are you available for a call?"
tagsarrayList of tags associated with the message[]
unreadRepliesCountnumberCount of unread replies0
mentionedUsersarrayList of mentioned users[]
hasMentionedMebooleanWhether the current user is mentionedfalse
reactionsarrayList of reactions on the message[]
moderationStatusstringModeration status of the messagenull
quotedMessageIdnumberID of the quoted messagenull

lastMessage.sender Object:
ParameterTypeDescriptionSample Value
uidstringUnique identifier of the sender"cometchat-uid-1"
namestringDisplay name of the sender"Andrew Joseph"
linkstringProfile linknull
avatarstringAvatar URL"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp"
metadataobjectCustom metadata{}
statusstringOnline status"online"
rolestringUser role"default"
statusMessagestringStatus messagenull
tagsarrayUser tags[]
hasBlockedMebooleanWhether this user has blocked the current userfalse
blockedByMebooleanWhether the current user has blocked this userfalse
lastActiveAtnumberEpoch timestamp of last activity1745554700

lastMessage.receiver Object:
ParameterTypeDescriptionSample Value
uidstringUnique identifier of the receiver"cometchat-uid-1"
namestringDisplay name of the receiver"Andrew Joseph"
linkstringProfile linknull
avatarstringAvatar URL"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp"
metadataobjectCustom metadata{}
statusstringOnline status"online"
rolestringUser role"default"
statusMessagestringStatus messagenull
tagsarrayUser tags[]
hasBlockedMebooleanWhether this user has blocked the current userfalse
blockedByMebooleanWhether the current user has blocked this userfalse
lastActiveAtnumberEpoch timestamp of last activity1745554700
ParameterTypeDescriptionSample Value
codestringError code identifier"ERR_CHAT_API_FAILURE"
messagestringHuman-readable error message"Failed to fetch the requested data."
detailsstringAdditional 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