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.
AI Integration Quick Reference
AI Integration Quick Reference
| Field | Value |
|---|---|
| Key Classes | InteractiveMessage, InteractionGoal, Interaction, InteractionReceipt |
| Key Methods | CometChat.sendInteractiveMessage(), CometChat.markAsInteracted() |
| Key Constants | InteractionGoalType.anyAction, InteractionGoalType.anyOf, InteractionGoalType.allOf, InteractionGoalType.none |
| Listener Events | onInteractiveMessageReceived, onInteractionGoalCompleted |
| Prerequisites | SDK initialized, user logged in |
InteractiveMessage
TheInteractiveMessage class extends BaseMessage and represents a message with embedded interactive content.
| Parameter | Type | Description | Required |
|---|---|---|---|
receiverUid | String | The UID of the user or GUID of the group | Yes |
receiverType | String | CometChatReceiverType.user or CometChatReceiverType.group | Yes |
type | String | Type identifier (e.g., "form", "card") | Yes |
interactiveData | Map<String, dynamic> | JSON structure defining the interactive elements | Yes |
allowSenderInteraction | bool | Whether sender can interact with the message | No (default: false) |
interactionGoal | InteractionGoal | Defines when the interaction is considered complete | No (default: none) |
tags | List<String> | Tags associated with the message | No |
muid | String | Unique message identifier for deduplication | No |
parentMessageId | int | ID of the parent message (for threads) | No |
metadata | Map<String, dynamic> | Custom metadata attached to the message | No |
Send an Interactive Message
UseCometChat.sendInteractiveMessage() to send an interactive message.
- Dart
sendInteractiveMessage() method returns an InteractiveMessage object on success.
Response
Response
On Success — An
InteractiveMessage object containing all details of the sent interactive message:InteractiveMessage Object:| Parameter | Type | Description | Sample Value |
|---|---|---|---|
id | number | Unique message ID | 501 |
metadata | object | Custom metadata attached to the message | {} |
receiver | object | Receiver user object | See below ↓ |
editedBy | string | UID of the user who edited the message | null |
conversationId | string | Unique conversation identifier | "cometchat-uid-1_user_cometchat-uid-3" |
sentAt | number | Epoch timestamp when the message was sent | 1745554729 |
receiverUid | string | UID of the receiver | "cometchat-uid-3" |
type | string | Type of the message | "form" |
readAt | number | Epoch timestamp when the message was read | 0 |
deletedBy | string | UID of the user who deleted the message | null |
deliveredAt | number | Epoch timestamp when the message was delivered | 0 |
deletedAt | number | Epoch timestamp when the message was deleted | 0 |
replyCount | number | Number of replies to this message | 0 |
sender | object | Sender user object | See below ↓ |
receiverType | string | Type of the receiver | "user" |
editedAt | number | Epoch timestamp when the message was edited | 0 |
parentMessageId | number | ID of the parent message (for threads) | 0 |
readByMeAt | number | Epoch timestamp when read by the current user | 0 |
category | string | Message category | "interactive" |
deliveredToMeAt | number | Epoch timestamp when delivered to the current user | 0 |
updatedAt | number | Epoch timestamp when the message was last updated | 1745554729 |
interactiveData | object | Structured data for the interactive element | {"title": "Survey", "formFields": [...]} |
interactions | array | List of user interactions with the message | [] |
interactionGoal | object | Intended outcome of interacting with the message | {"type": "none", "elementIds": []} |
tags | array | List of tags associated with the message | [] |
allowSenderInteraction | boolean | Whether the sender can interact with the message | true |
unreadRepliesCount | number | Count of unread replies | 0 |
quotedMessageId | number | ID of the quoted message | null |
sender Object:| Parameter | Type | Description | Sample Value |
|---|---|---|---|
uid | string | Unique identifier of the sender | "cometchat-uid-1" |
name | string | Display name of the sender | "Andrew Joseph" |
link | string | Profile link | null |
avatar | string | Avatar URL | "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp" |
metadata | object | Custom metadata | {} |
status | string | Online status | "online" |
role | string | User role | "default" |
statusMessage | string | Status message | null |
tags | array | User tags | [] |
hasBlockedMe | boolean | Whether this user has blocked the current user | false |
blockedByMe | boolean | Whether the current user has blocked this user | false |
lastActiveAt | number | Epoch timestamp of last activity | 1745554700 |
receiver Object:| Parameter | Type | Description | Sample Value |
|---|---|---|---|
uid | string | Unique identifier of the receiver | "cometchat-uid-3" |
name | string | Display name of the receiver | "Kevin Hart" |
link | string | Profile link | null |
avatar | string | Avatar URL | "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp" |
metadata | object | Custom metadata | {} |
status | string | Online status | "offline" |
role | string | User role | "default" |
statusMessage | string | Status message | null |
tags | array | User tags | [] |
hasBlockedMe | boolean | Whether this user has blocked the current user | false |
blockedByMe | boolean | Whether the current user has blocked this user | false |
lastActiveAt | number | Epoch timestamp of last activity | 1745550000 |
Error
Error
| Parameter | Type | Description | Sample Value |
|---|---|---|---|
code | string | Error code identifier | "ERR_CHAT_API_FAILURE" |
message | string | Human-readable error message | "Failed to send the interactive message." |
details | string | Additional technical details | "An unexpected error occurred while processing the request." |
Interactive Elements
TheinteractiveData map defines the UI elements. Common element types:
| Element Type | Description |
|---|---|
textInput | Single or multi-line text field |
dropdown | Single-select dropdown menu |
Select | Multi-select checkbox group |
button | Clickable button with action |
Text Input
Dropdown (Single Select)
Checkbox (Multi Select)
Submit Button
Interaction Goals
AnInteractionGoal defines when the user’s interaction with the message is considered complete. Use this to track engagement and trigger follow-up actions.
InteractionGoal Parameters:
| Parameter | Type | Description | Required |
|---|---|---|---|
type | String | The type of interaction goal (see goal types below) | Yes |
elementIds | List<String> | List of element IDs associated with this goal | No (default: []) |
| Goal Type | Constant | Description |
|---|---|---|
| Any Interaction | InteractionGoalType.anyAction | Complete when any element is interacted with |
| Any of Specific | InteractionGoalType.anyOf | Complete when any of the specified elements is interacted with |
| All of Specific | InteractionGoalType.allOf | Complete when all specified elements are interacted with |
| None | InteractionGoalType.none | Never considered complete (default) |
Set an Interaction Goal
- Dart
InteractiveMessage (captured as Interaction objects) and comparing those with the defined InteractionGoal. The completion of a goal can vary depending on the goal type.
This user interaction tracking mechanism provides a flexible and efficient way to monitor user engagement within an interactive chat session. By defining clear interaction goals and checking user interactions against these goals, you can manage user engagement and improve the overall chat experience in your CometChat-enabled application.
Interactions
AnInteraction represents a single user action on an interactive element.
| Property | Type | Description |
|---|---|---|
elementId | String | Identifier of the interacted element |
interactedAt | DateTime | Timestamp indicating when the interaction occurred |
Mark as Interacted
UseCometChat.markAsInteracted() to record when a user interacts with an element. This method marks a message as interacted by identifying it with the provided ID and logs the interactive element associated with the interaction.
- Dart
| Parameter | Type | Description | Required |
|---|---|---|---|
messageId | int | The ID of the interactive message | Yes |
interactedElementId | String | The element ID that was interacted with | Yes |
Response
Response
On Success — A
String message confirming the interaction was recorded:| Parameter | Type | Description | Sample Value |
|---|---|---|---|
message | string | Success confirmation message | "Message marked as interacted successfully." |
Error
Error
| Parameter | Type | Description | Sample Value |
|---|---|---|---|
code | string | Error code identifier | "ERR_CHAT_API_FAILURE" |
message | string | Human-readable error message | "Failed to mark the message as interacted." |
details | string | Additional technical details | "An unexpected error occurred while processing the request." |
Real-Time Events
Register aMessageListener to receive interactive message events.
Receive Interactive Messages
TheonInteractiveMessageReceived event listener is triggered when an InteractiveMessage is received.
- Dart
Interaction Goal Completed
TheonInteractionGoalCompleted event listener is invoked when an interaction goal is achieved.
InteractionReceipt Properties:
| Property | Type | Description |
|---|---|---|
messageId | int | The ID of the interactive message |
sender | User | The user who completed the interaction |
receiverType | String | Type of the receiver ("user" or "group") |
receiverId | String | UID or GUID of the receiver |
interactions | List<Interaction> | List of interactions that satisfied the goal |
- Dart
Allow Sender Interaction
By default, the sender cannot interact with their own interactive message. SetallowSenderInteraction to true to enable sender interaction:
- Dart
Next Steps
Send Messages
Send text, media, and custom messages
Receive Messages
Listen for incoming messages in real time
Transient Messages
Send ephemeral messages that aren’t stored
Message Structure
Understand message types and hierarchy