AI Integration Quick Reference
AI Integration Quick Reference
Available from Chat SDK v5.0.7. These APIs require
cometchat_sdk v5.0.7 or later. See Setup to upgrade.pinnedAt timestamp and the pinnedBy UID.
This is separate from an admin (system) pin, which is applied from an admin surface such as the CometChat Dashboard and carries the
app_system sentinel in pinnedBy. System pins rank above the user’s own pins and cannot be created or removed from the SDK, only observed.Pin a Conversation
A conversation is addressed by its peer — the other user’s UID for a one-on-one conversation, or the GUID for a group — together with the conversation type.- Dart
onSuccess receives the full updated Conversation, with pinnedAt and pinnedBy set. Pinning is idempotent.
Addressing by peer rather than by
conversationId is deliberate: it lets you pin a conversation that has no messages yet.Unpin a Conversation
- Dart
Conversation carries its pin fields cleared to null. Only a pin the logged-in user placed can be removed — a system pin is rejected server-side, so hide or disable the unpin control for conversations whose pinnedBy is app_system.
Fetch Pinned Conversations
The default conversation list is already pin-ordered by the server: system pins first, then the user’s own pins, then everything else by latest activity. Fetch it with the regularConversationsRequest described in Retrieve Conversations — no extra filter is needed.
- Dart
Check if a Conversation is Pinned
As with messages, anull pinnedAt means the conversation is not pinned.
- Dart
Real-time Conversation Pin Events
Conversation pins arrive on a dedicatedConversationListener, not on MessageListener — the payload is a Conversation, not a message. Register it with addConversationListener() and override onConversationPinned() and onConversationUnpinned().
- Dart
- Dart
Pin Limit
- Dart
getPinnedConversationsLimit() is synchronous and returns null when the backend did not serve a limit. System pins do not count against the user’s allowance.
Error Handling
pinConversation() and unpinConversation() report failures through onError with a CometChatException. Branch on e.code rather than the message text:
Pins are per-user, so pinning a conversation never affects anyone else’s list. Both calls are idempotent: unpinning a conversation that was never pinned succeeds rather than erroring.
- Dart
Feature Availability
- Dart
isPinConversationEnabled() is synchronous and never throws. When neither the login payload nor the app settings carry the flag, it returns true, so the feature is not disabled on a backend that predates the flag.
Next Steps
Retrieve Conversations
Fetch and order the conversation list
Pin A Message
Highlight a message for everyone in a conversation
Save A Message
Bookmark a message privately, across conversations
All Real Time Listeners
Every listener the SDK exposes, in one place