AI Integration Quick Reference
AI Integration Quick Reference
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 theConversationsRequest 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
TheConversationsRequestBuilder to fetch conversations with various filters.
Set Limit
Set the number of conversations to fetch per request.- Dart
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.
- Dart
Conversation objects filtered by the specified type.
With User and Group Tags
UsewithUserAndGroupTags = true to include user/group tags in the Conversation object. Default is false.
- Dart
tags arrays on the conversationWith objects (user or group).
Set User Tags
Fetch user conversations where the user has specific tags.- Dart
Set Group Tags
Fetch group conversations where the group has specific tags.- Dart
With Tags
UsewithTags = true to include conversation tags in the response. Default is false.
- Dart
Set Tags
Fetch conversations that have specific tags.- Dart
Include Blocked Users
UseincludeBlockedUsers = true to include conversations with users you’ve blocked.
- Dart
blockedByMe, hasBlockedMe), set withBlockedInfo to true.
With Blocked Info
UsewithBlockedInfo = true to include blocked user information in the response.
- Dart
Search Conversations
UsesearchKeyword 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)- Dart
Unread Conversations
Useunread = 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)- Dart
unreadMessageCount > 0).
Hide Agentic Conversations
UsehideAgentic = true to exclude AI agent conversations from the list.
- Dart
Only Agentic Conversations
UseonlyAgentic = true to fetch only AI agent conversations.
- Dart
hideAgentic and onlyAgentic are mutually exclusive — use only one per request.role: "@agentic" and include agent-specific metadata.
Fetch Conversations
After configuring the builder, callbuild() to create the request, then fetchNext() to retrieve conversations. Maximum 50 per request. Call fetchNext() repeatedly on the same object to paginate.
- Dart
Response
Response
On Success — A
List<Conversation> containing conversation objects with their associated user/group and last message details:Conversation Object (per item in list):conversationWith Object (User):conversationWith Object (Group):lastMessage Object (TextMessage):lastMessage.sender Object:lastMessage.receiver Object:Error
Error
Conversation object consists of the below fields:
Tag Conversation
In other words, as a logged-in user, how do I tag a conversation? UsetagConversation() to add tags to a conversation.
- Dart
Response
Response
On Success — A
Conversation object containing the updated conversation with the applied tags:Conversation Object:conversationWith Object (User):lastMessage Object (TextMessage):lastMessage.sender Object:lastMessage.receiver Object:Error
Error
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? UsegetConversation() to fetch a specific conversation.
- Dart
Response
Response
On Success — A
Conversation object containing the details of the requested conversation:Conversation Object:conversationWith Object (User):lastMessage Object (TextMessage):lastMessage.sender Object:lastMessage.receiver Object:Error
Error
Convert Messages to Conversations
As per our Receive Messages guide, for real-time messages, you will always receiveMessage 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.
- Dart
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