AI Integration Quick Reference
AI Integration Quick Reference
Add a Reaction
CalladdReaction() with a message ID and an emoji string.
- Dart
Response
Response
On Success — A
BaseMessage object representing the message with the reaction added:BaseMessage Object:sender Object:receiver Object:Error
Error
Remove a Reaction
CallremoveReaction() with the same message ID and emoji.
- Dart
Response
Response
On Success — A
BaseMessage object representing the message with the reaction removed:BaseMessage Object:sender Object:receiver Object:Error
Error
addReaction() and removeReaction() return a BaseMessage object with the updated reactions.
Read Reaction Data from a Message
AnyBaseMessage exposes reaction data through its reactions property:
Get All Reactions
Use thereactions property to retrieve the list of reactions on a message. Returns a List<ReactionCount> containing the reactions, or an empty list if no one has reacted.
- Dart
Check if the Logged-in User Has Reacted
Use thereactedByMe property on any ReactionCount object to check whether the logged-in user has reacted with that particular emoji. Returns true if they have, false otherwise.
- Dart
Fetch Reactions for a Message
To get the full list of who reacted with what on a specific message, useReactionsRequestBuilder. You can paginate through results with fetchNext() and fetchPrevious() (max 100 per request).
Fetch Next
ThefetchNext() method fetches the next set of reactions for the message.
- Dart
fetchNext() method returns a List<Reaction> representing individual user reactions on the message.
Response
Response
On Success — A list of
Reaction objects for the message:Reaction Object (per item in list):reactedBy Object:Error
Error
Fetch Previous
ThefetchPrevious() method fetches the previous set of reactions for the message.
- Dart
Response
Response
On Success — A list of
Reaction objects for the message:Reaction Object (per item in list):reactedBy Object:Error
Error
Real-Time Reaction Events
Register aMessageListener to receive reaction events as they happen. This is how you keep your UI in sync when other users add or remove reactions.
- Dart
ReactionEvent object containing:
Remove the Listener
- Dart
Update a Message with Reaction Info
When you receive a real-time reaction event, you’ll want to update the corresponding message object so your UI reflects the change.CometChatHelper.updateMessageWithReactionInfo() does this — it takes the BaseMessage instance, the Reaction event data, and the action type, then returns the updated message.
- Dart
modifiedBaseMessage?.reactions to get the latest reactions and refresh your UI.
Next Steps
Send Messages
Send text, media, and custom messages to users and groups
Receive Messages
Listen for incoming messages in real-time and fetch missed messages
Threaded Messages
Create and manage message threads
Mentions
Mention users and groups in messages