Skip to main content
Interactive messages embed UI elements like forms, buttons, and dropdowns directly within chat messages. Users can interact with these elements without leaving the conversation, enabling surveys, quick actions, and data collection.
Available via: SDK | REST API | UI Kits

InteractiveMessage

The InteractiveMessage class extends BaseMessage and represents a message with embedded interactive content.

Send an Interactive Message

Use CometChat.sendInteractiveMessage() to send an interactive message.
The sendInteractiveMessage() method returns an InteractiveMessage object on success.
On Success — An InteractiveMessage object containing all details of the sent interactive message:InteractiveMessage Object:
sender Object:
receiver Object:

Interactive Elements

The interactiveData map defines the UI elements. Common element types:

Text Input

Checkbox (Multi Select)

Submit Button

Interaction Goals

An InteractionGoal 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

You would be tracking every interaction users perform on an 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

An Interaction represents a single user action on an interactive element.

Mark as Interacted

Use CometChat.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.
On Success — A String message confirming the interaction was recorded:

Real-Time Events

Register a MessageListener to receive interactive message events.

Receive Interactive Messages

The onInteractiveMessageReceived event listener is triggered when an InteractiveMessage is received.

Interaction Goal Completed

The onInteractionGoalCompleted event listener is invoked when an interaction goal is achieved. InteractionReceipt Properties:
These event listeners offer your application a way to provide real-time updates in response to incoming interactive messages and goal completions, contributing to a more dynamic and responsive user chat experience.
Always remove listeners when they’re no longer needed to prevent memory leaks.

Allow Sender Interaction

By default, the sender cannot interact with their own interactive message. Set allowSenderInteraction to true to enable sender interaction:

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