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 with filters
val conversationsRequest = ConversationsRequestBuilder()
    .setLimit(50)
    .setConversationType(CometChatConstants.CONVERSATION_TYPE_USER)
    .build()

conversationsRequest.fetchNext(object : CallbackListener<List<Conversation>>() {
    override fun onSuccess(conversations: List<Conversation>) { }
    override fun onError(e: CometChatException) { }
})

// Get specific conversation
CometChat.getConversation("UID_or_GUID", "user", callback)
Conversations provide the last messages for every one-on-one and group conversation the logged-in user is a part of. This makes it easy for you to build a Recent Chat list.

Retrieve List of Conversations

Use ConversationsRequestBuilder to configure filters, then call fetchNext() to retrieve up to 50 conversations per request.

Set Limit

Set the number of conversations to fetch per request.
ConversationsRequest conversationRequest = new ConversationsRequest.ConversationsRequestBuilder()
  .setLimit(100)
  .build();

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 conversationsRequest = new ConversationsRequest.ConversationsRequestBuilder()
  .setLimit(50)
  .setConversationType(CometChatConstants.CONVERSATION_TYPE_USER)
  .build();

With User and Group Tags

Use withUserAndGroupTags(true) to include user/group tags in the response. Default is false.
ConversationsRequest conversationsRequest = new ConversationsRequest.ConversationsRequestBuilder()
  .setLimit(50)
  .withUserAndGroupTags(true)
  .build();

Set User Tags

Fetch user conversations where the user has specific tags.
List<String> tags = new ArrayList<>();
tags.add("tag_1");
conversationsRequest = new ConversationsRequest.ConversationsRequestBuilder()
  .setLimit(10)
  .setUserTags(tags)
  .build();

Set Group Tags

Fetch group conversations where the group has specific tags.
List<String> tags = new ArrayList<>();
tags.add("tag_1");
conversationsRequest = new ConversationsRequest.ConversationsRequestBuilder()
  .setLimit(10)
  .setGroupTags(tags)
  .build();
This method fetches group conversations that have the specified tags.

With Tags

Use withTags(true) to include conversation tags in the response. Default is false. When withTags(true) is set, each conversation’s tags field will be populated. Access tags using getTags().
Additional FieldGetterReturn TypeDescription
tagsgetTags()List<String>Tags associated with the conversation
ConversationsRequest conversationsRequest = new ConversationsRequest.ConversationsRequestBuilder()
  .setLimit(50)
  .withTags(true)
  .build();

Set Tags

Fetch conversations that have specific tags.
List<String> tags = new ArrayList<>();
tags.add("archived");
ConversationsRequest conversationsRequest = new ConversationsRequest.ConversationsRequestBuilder()
  .setLimit(50)
  .setTags(tags)
  .build();

Include Blocked Users

Use includeBlockedUsers(true) to include conversations with users you’ve blocked.
ConversationsRequest conversationsRequest = new ConversationsRequest.ConversationsRequestBuilder()
  .setLimit(50)
  .includeBlockedUsers(true)
  .build();

With Blocked Info

Use withBlockedInfo(true) to include blocked user information in the response.
ConversationsRequest conversationsRequest = new ConversationsRequest.ConversationsRequestBuilder()
  .setLimit(50)
  .withBlockedInfo(true)
  .build();

Search Conversations

Use setSearchKeyword() 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 conversationsRequest = new ConversationsRequest.ConversationsRequestBuilder()
  .setLimit(50)
  .setSearchKeyword("Hiking")
  .build();

Unread Conversations

Use setUnread(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 conversationsRequest = new ConversationsRequest.ConversationsRequestBuilder()
  .setLimit(50)
  .setUnread(true)
  .build();

Hide Agentic Conversations

Use hideAgentic(true) to exclude AI agent conversations from the list.
ConversationsRequest conversationsRequest = new ConversationsRequest.ConversationsRequestBuilder()
  .setLimit(50)
  .hideAgentic(true)
  .build();

Only Agentic Conversations

Use onlyAgentic(true) to fetch only AI agent conversations.
ConversationsRequest conversationsRequest = new ConversationsRequest.ConversationsRequestBuilder()
  .setLimit(50)
  .onlyAgentic(true)
  .build();
hideAgentic() and onlyAgentic() are mutually exclusive — use only one per request.

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 conversationsRequest = new ConversationsRequest.ConversationsRequestBuilder().setLimit(50).build();

conversationsRequest.fetchNext(new CometChat.CallbackListener<List<Conversation>>() {
  @Override
  public void onSuccess(List<Conversation> conversations) {
    // Handle list of conversations
  }

  @Override
  public void onError(CometChatException e) {
    // Handle failure
  }
});
The Conversation object consists of the following 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

Tag Conversation

Use tagConversation() to add tags to a Conversation.
ParameterDescription
conversationWithUID or GUID of the user/group
conversationTypeuser or group
tagsList of tags to add
String id = "cometchat-uid-1"; //id of the user/group
String conversationType = "user";
List<String> tags = new ArrayList<>();
tags.add("archived");

CometChat.tagConversation(id, conversationType, tags, new CometChat.CallbackListener<Conversation>() {
  @Override
  public void onSuccess(Conversation conversation) {
    Log.d(TAG, conversation.toString());
  }

  @Override
  public void onError(CometChatException e) {
    Log.d(TAG, e.getMessage());
  }
});
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

Use getConversation() to fetch a specific Conversation.
ParameterDescription
conversationWithUID or GUID of the user/group
conversationTypeuser or group
CometChat.getConversation(conversationWith, conversationType, new CometChat.CallbackListener<Conversation>() {
  @Override
  public void onSuccess(Conversation conversation) {
    // Handle getConversation success
  }

  @Override
  public void onError(CometChatException e) {
    // Handle getConversation error
  }
});

Convert Messages to Conversations

Use CometChatHelper.getConversationFromMessage() to convert a received message into a Conversation object. Useful for updating your Recent Chats list when receiving real-time messages.
Conversation conversation = CometChatHelper.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.

Conversation Payload Structure

The Conversation object returned by SDK methods contains the following fields:
ParameterTypeDescription
conversationIdStringUnique conversation identifier
conversationTypeStringType of conversation. Values: "user", "group"
conversationWithAppEntityThe User or Group in the conversation
lastMessageBaseMessageLast message in the conversation
unreadMessageCountintNumber of unread messages in the conversation
unreadMentionsCountintNumber of unread mentions in the conversation
updatedAtlongUnix timestamp of last conversation update
tagsArray<String>List of tags for conversation organization
lastReadMessageIdlongID of the last read message
latestMessageIdlongID of the latest message
Sample Conversation Object:
{
  "conversationId": "user_123_user_456",
  "conversationType": "user",
  "conversationWith": {
    "uid": "user_456",
    "name": "John Doe",
    "avatar": "https://example.com/avatar.png",
    "status": "online",
    "role": "default",
    "lastActiveAt": 1699900000,
    "tags": ["premium", "verified"]
  },
  "lastMessage": {
    "id": 12345,
    "muid": "msg_abc123",
    "type": "text",
    "receiverType": "user",
    "category": "message",
    "sentAt": 1699900000,
    "deliveredAt": 1699900001,
    "readAt": 1699900002,
    "metadata": {"priority": "high"},
    "conversationId": "user_123_user_456"
  },
  "unreadMessageCount": 3,
  "unreadMentionsCount": 1,
  "updatedAt": 1699900000,
  "tags": ["important", "work"],
  "lastReadMessageId": 12340,
  "latestMessageId": 12345
}
When conversationType is "user", the conversationWith field contains a User object:
ParameterTypeDescription
uidStringUnique identifier of the user
nameStringDisplay name of the user
avatarStringURL to user’s profile picture
linkStringURL to user’s profile page
roleStringUser role for access control
metadataJSONObjectCustom data set by developer
statusStringUser online status. Values: "online", "offline"
statusMessageStringCustom status message
lastActiveAtlongUnix timestamp of last activity
hasBlockedMebooleanWhether this user has blocked the logged-in user
blockedByMebooleanWhether the logged-in user has blocked this user
tagsArray<String>List of tags for user identification
deactivatedAtlongUnix timestamp when user was deactivated (0 if active)
When conversationType is "group", the conversationWith field contains a Group object:
ParameterTypeDescription
guidStringUnique identifier of the group
nameStringDisplay name of the group
typeStringGroup type. Values: "public", "private", "password"
iconStringURL to group icon
descriptionStringGroup description
ownerStringUID of group owner
metadataJSONObjectCustom data set by developer
membersCountintNumber of group members
tagsArray<String>List of tags for group identification
hasJoinedbooleanWhether logged-in user has joined
scopeStringUser’s scope in group. Values: "admin", "moderator", "participant"
createdAtlongUnix timestamp when group was created
updatedAtlongUnix timestamp of last group update
The lastMessage field contains a BaseMessage object with key fields:
ParameterTypeDescription
idlongUnique message identifier
muidStringDeveloper-defined message ID
typeStringMessage type. Values: "text", "image", "video", "audio", "file", "custom"
receiverTypeStringType of receiver. Values: "user", "group"
categoryStringMessage category. Values: "message", "action", "call"
sentAtlongUnix timestamp when message was sent
deliveredAtlongUnix timestamp when message was delivered
readAtlongUnix timestamp when message was read
metadataJSONObjectCustom message metadata
conversationIdStringAssociated conversation identifier
senderUserUser who sent the message

Next Steps

Delete Conversation

Remove conversations from the list

Typing Indicators

Show when users are typing

Read Receipts

Track message delivery and read status

Send Messages

Start sending messages in conversations