InteractiveMessage
InteractiveMessage is a chat message with embedded interactive content. It can contain various properties:
Interaction
AnInteraction represents a user action involved with an InteractiveMessage. It includes:
elementId: An identifier for a specific interactive element.interactedAt: A timestamp indicating when the interaction occurred.
Goal Completion
A key feature ofInteractiveMessage is checking whether a user’s interactions with the message meet the defined InteractionGoal
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.
InteractionGoal
TheInteractionGoal represents the desired outcome of an interaction with an InteractiveMessage. It includes:
elementIds: A list of identifiers for the interactive elements.type: The type of interaction goal from theCometChatConstants.
Sending InteractiveMessages
TheInteractiveMessage can be sent using the sendInteractiveMessage method of the CometChat class. The method requires an InteractiveMessage object and a CallbackListener for handling the response.
Here is an example of how to use it:
- JavaScript
Event Listeners
CometChat SDK provides event listeners to handle real-time events related toInteractiveMessage.
On InteractiveMessage Received
TheonInteractiveMessageReceived event listener is triggered when an InteractiveMessage is received.
Here is an example:
- JavaScript
onInteractionGoalCompleted event listener is invoked when an interaction goal is achieved.
Here is an example:
- JavaScript