Quick Reference for AI Agents & Developers
- Create interactive:
InteractiveMessage()— setreceiverUid,receiverType,type,interactiveData - Send interactive:
CometChat.sendInteractiveMessage(message:onSuccess:onError:) - Types: Form, Card, Scheduler, Custom Interactive
- Interaction goal: Set
interactionGoalto define completion criteria - Related: Send Message · Messaging Overview
InteractiveMessage Properties
| Property | Type | Description |
|---|---|---|
| receiverUid | String | UID or GUID of recipient |
| receiverType | ReceiverType | .user or .group |
| type | String | form, card, scheduler, or custom |
| interactiveData | [String: Any] | JSON structure for content |
| allowSenderInteraction | Bool | Can sender interact (default: false) |
| interactionGoal | InteractionGoal | Completion criteria |
| messageCategory | MessageCategory | .interactive |
Interaction Goal Types
| Type | Description | Value |
|---|---|---|
| Any Action | Goal completed if any interaction occurs | .anyAction |
| Any Of | Goal achieved if any specified interaction occurs | .anyOf |
| All Of | Goal completed when all specified interactions occur | .allOf |
| None | Goal is never completed | .none |
Form Element Types
| Element Type | Description |
|---|---|
| textInput | Single or multi-line text input |
| dropdown | Dropdown select with options |
| checkbox | Multiple selection checkboxes |
| radio | Single selection radio buttons |
| singleSelect | Single selection list |
| button | Action button (submit, navigate) |
Button Action Types
| Action Type | Description |
|---|---|
| urlNavigation | Opens a URL in browser |
| apiAction | Makes an API call with specified parameters |
| customAction | Custom action handled by app |
Send Form Interactive Message
- Swift
Sample Payloads - Form Message
Sample Payloads - Form Message
- Request
- Success Response
- Error Response
Method:
Interaction Goal:
CometChat.sendInteractiveMessage(message:)Message Parameters:| Parameter | Type | Value |
|---|---|---|
| receiverUid | String | "cometchat-uid-2" |
| receiverType | CometChat.ReceiverType | .user |
| type | String | "form" |
| messageCategory | CometChat.MessageCategory | .interactive |
| allowSenderInteraction | Bool | true |
| Parameter | Type | Value |
|---|---|---|
| elementIds | [String] | ["submit_btn"] |
| interactionType | InteractionGoalType | .anyOf |
Send Card Interactive Message
- Swift
Sample Payloads - Card Message
Sample Payloads - Card Message
- Request
- Success Response
Message Parameters:
| Parameter | Type | Value |
|---|---|---|
| receiverUid | String | "cometchat-uid-2" |
| receiverType | CometChat.ReceiverType | .user |
| type | String | "card" |
| messageCategory | CometChat.MessageCategory | .interactive |
| allowSenderInteraction | Bool | true |
Send Scheduler Interactive Message
- Swift
Sample Payloads - Scheduler Message
Sample Payloads - Scheduler Message
- Request
- Error Response
Message Parameters:
Scheduler Data:
| Parameter | Type | Value |
|---|---|---|
| receiverUid | String | "cometchat-uid-2" |
| receiverType | CometChat.ReceiverType | .user |
| type | String | "scheduler" |
| messageCategory | CometChat.MessageCategory | .interactive |
| allowSenderInteraction | Bool | true |
| Parameter | Type | Value |
|---|---|---|
| title | String | "Schedule a Meeting" |
| duration | Int | 30 |
| bufferTime | Int | 5 |
Send Form to Group
- Swift
Sample Payloads - Group Form
Sample Payloads - Group Form
- Request
- Success Response
Message Parameters:
| Parameter | Type | Value |
|---|---|---|
| receiverUid | String | "cometchat-guid-1" |
| receiverType | CometChat.ReceiverType | .group |
| type | String | "form" |
| messageCategory | CometChat.MessageCategory | .interactive |
Interaction Object Properties
| Property | Type | Description |
|---|---|---|
| elementId | String | ID of interacted element |
| interactedAt | Double | Timestamp of interaction |
InteractionGoal Object Properties
| Property | Type | Description |
|---|---|---|
| elementIds | [String] | IDs of target elements |
| interactionType | InteractionGoalType | .anyAction, .anyOf, .allOf, .none |
Real-time Interactive Message Events
To receive interactive message events, implementCometChatMessageDelegate:
- Swift
Sample Payloads - Event Listeners
Sample Payloads - Event Listeners
- onInteractiveMessageReceived
- onInteractionGoalCompleted
Method:
onInteractiveMessageReceived(_ message: InteractiveMessage)| Parameter | Type | Description |
|---|---|---|
| message | InteractiveMessage | The interactive message object |
| message.type | String? | form, card, scheduler, or custom |
| message.interactiveData | [String: Any]? | JSON structure of content |
| message.interactionGoal | InteractionGoal? | Goal definition |