AI Integration Quick Reference
AI Integration Quick Reference
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.
The ConversationsRequestBuilder to fetch conversations with various filters.
Set Limit
Set the number of conversations to fetch per request.- TypeScript
- JavaScript
Set Conversation Type
Filter by conversation type:user for one-on-one or group for group conversations. If not set, both types are returned.
- TypeScript
- JavaScript
- JavaScript
- JavaScript
- JavaScript
- JavaScript
- JavaScript
- JavaScript
blockedByMe, blockedByMeAt, blockedAt), set withBlockedInfo to true.
With Blocked Info
UsesetWithBlockedInfo(true) to include blocked user information in the response.
- TypeScript
- JavaScript
Search Conversations
With offline support on, this filter is answered by the server only; the cached page is empty.
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)- TypeScript
- JavaScript
Unread Conversations
UsesetUnread(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)- TypeScript
- JavaScript
unreadMessageCount > 0).
Unread counts in large groups: Unread message counts are calculated only for groups with up to 300 members. See Properties and Constraints.
Hide Agentic Conversations
UsesetHideAgentic(true) to exclude AI agent conversations from the list.
- TypeScript
- JavaScript
Only Agentic Conversations
UsesetOnlyAgentic(true) to fetch only AI agent conversations.
- TypeScript
- JavaScript
- JavaScript
fetchNext() method returns an array of Conversation objects.
Tag Conversation
UsetagConversation() to add tags to a conversation.
- TypeScript
- JavaScript
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.
Conversation object (not an array) with the tags field included.
The tagConversation() method returns a Conversation object with the tags field populated.
Relevant fields to access on returned conversation:
Retrieve Single Conversation
UsegetConversation() to fetch a specific conversation.
- TypeScript
- JavaScript
Conversation object (not an array).
The getConversation() method returns a single Conversation object.
With offline support enabled, pass a ConversationDetailsListener as the third argument: onCachedConversation first delivers the cached copy when there is one, then onServerConversation delivers the server copy. Offline, the read then ends with onError with code FAILED_TO_FETCH; when nothing is cached, onError is the only callback.
Convert Messages to Conversations
UseCometChatHelper.getConversationFromMessage() to convert a received message into a Conversation object. Useful for updating your Recent Chats list when receiving real-time messages.
- TypeScript
- JavaScript
When converting a message to a conversation,
unreadMessageCount and tags
won’t be available. Manage unread counts in your client-side code.getConversationFromMessage() method returns a Conversation object.
Offline Behaviour
With offline support enabled,fetchNext() accepts a ConversationFetchListener and delivers a cached page first (onCachedConversations, even when empty) and then the server list (onServerConversations). Offline, the read ends with onError with code FAILED_TO_FETCH after the cached page. The cached page is answered only when every builder filter on the request is locally computable: a single server-only filter blanks the cached page while the server phase still answers in full.
Next Steps
Delete Conversation
Remove conversations from the logged-in user’s list
Receive Messages
Listen for incoming messages to update conversation lists in real time
Typing Indicators
Show real-time typing status in conversations
Delivery & Read Receipts
Track message delivery and read status per conversation