AI Integration Quick Reference
AI Integration Quick Reference
InteractiveMessage
TheInteractiveMessage class extends BaseMessage and represents a message with embedded interactive content.
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:sender Object:receiver Object:Error
Error
Interactive Elements
TheinteractiveData map defines the UI elements. Common element types:
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:
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.
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
Response
Response
On Success — A
String message confirming the interaction was recorded:Error
Error
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:
- 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