Skip to main content
This page documents the message classes used across all CometChat SDKs. All message objects share the same structure regardless of platform. All properties are accessed via getter methods.

Class Hierarchy

BaseMessage
├── TextMessage
├── MediaMessage
├── CustomMessage
└── Action

BaseMessage

BaseMessage is the base class for all message types. Every message object — whether it’s a text message, media message, or custom message — extends this class.

Properties

PropertyGetterReturn TypeDescription
idgetId()numberUnique message ID
conversationIdgetConversationId()stringID of the conversation this message belongs to
parentMessageIdgetParentMessageId()numberID of the parent message (for threaded messages)
muidgetMuid()stringClient-generated unique message ID
sendergetSender()UserSender of the message
receivergetReceiver()User | GroupReceiver of the message
receiverIdgetReceiverId()stringUID/GUID of the receiver
typegetType()stringMessage type (e.g., "text", "image", "file", "custom")
receiverTypegetReceiverType()stringReceiver type ("user" or "group")
categorygetCategory()MessageCategoryMessage category (e.g., "message", "action", "call", "custom")
sentAtgetSentAt()numberTimestamp when the message was sent (epoch seconds)
deliveredAtgetDeliveredAt()numberTimestamp when the message was delivered
readAtgetReadAt()numberTimestamp when the message was read
deliveredToMeAtgetDeliveredToMeAt()numberTimestamp when the message was delivered to the logged-in user
readByMeAtgetReadByMeAt()numberTimestamp when the message was read by the logged-in user
editedAtgetEditedAt()numberTimestamp when the message was edited
editedBygetEditedBy()stringUID of the user who edited the message
deletedAtgetDeletedAt()numberTimestamp when the message was deleted
deletedBygetDeletedBy()stringUID of the user who deleted the message
replyCountgetReplyCount()numberNumber of replies to this message
unreadRepliesCountgetUnreadRepliesCount()numberNumber of unread replies
datagetData()ObjectRaw data payload of the message
metadatagetMetadata()ObjectCustom metadata attached to the message
rawMessagegetRawMessage()ObjectRaw JSON of the message as received from the server

Conditional Properties

These properties may or may not be populated depending on the method or request configuration used to fetch the message.
PropertyGetterReturn TypeDescription
reactionsgetReactions()ReactionCount[]Array of reaction counts on the message
mentionedUsersgetMentionedUsers()User[]Array of users mentioned in the message
hasMentionedMehasMentionedMe()booleanWhether the logged-in user was mentioned in the message
quotedMessageIdgetQuotedMessageId()numberID of the quoted message (if this is a reply)
quotedMessagegetQuotedMessage()BaseMessageThe quoted message object (if this is a reply)

TextMessage

TextMessage extends BaseMessage and represents a text-based chat message. It inherits all properties from BaseMessage and adds the following.

Properties

PropertyGetterReturn TypeDescription
textgetText()stringThe text content of the message
metadatagetMetadata()ObjectCustom metadata attached to the message (includes extension data like data masking, link preview, etc.)
datagetData()ObjectRaw data payload including text, resource, metadata, moderation, and entities
moderationStatusgetModerationStatus()ModerationStatusModeration status of the message. Returns "unmoderated" if not moderated.

Conditional Properties

These properties may or may not be populated depending on the method or request configuration used to fetch the message.
PropertyGetterReturn TypeDescription
tagsgetTags()string[]Tags associated with the message

MediaMessage

MediaMessage extends BaseMessage and represents a message with media attachments such as images, videos, audio files, or documents. It inherits all properties from BaseMessage and adds the following.

Properties

PropertyGetterReturn TypeDescription
captiongetCaption()stringCaption text for the media message
attachmentgetAttachment()AttachmentThe primary attachment of the media message
attachmentsgetAttachments()Attachment[]All attachments of the media message
urlgetURL()stringURL of the media file
metadatagetMetadata()ObjectCustom metadata attached to the message
datagetData()ObjectRaw data payload of the message
moderationStatusgetModerationStatus()ModerationStatusModeration status of the message. Returns "unmoderated" if not moderated.

Conditional Properties

These properties may or may not be populated depending on the method or request configuration used to fetch the message.
PropertyGetterReturn TypeDescription
tagsgetTags()string[]Tags associated with the message

CustomMessage

CustomMessage extends BaseMessage and represents a developer-defined message with a custom data payload. It inherits all properties from BaseMessage and adds the following.

Properties

PropertyGetterReturn TypeDescription
customDatagetCustomData()ObjectThe custom data payload set by the developer
subTypegetSubType()stringSub type of the custom message
conversationTextgetConversationText()stringPreview text displayed in the conversation list
updateConversationwillUpdateConversation()booleanWhether this message updates the conversation’s last message
sendNotificationwillSendNotification()booleanWhether a push notification is sent for this message
metadatagetMetadata()ObjectCustom metadata attached to the message
datagetData()ObjectRaw data payload of the message

Conditional Properties

These properties may or may not be populated depending on the method or request configuration used to fetch the message.
PropertyGetterReturn TypeDescription
tagsgetTags()string[]Tags associated with the message

Action

Action extends BaseMessage and represents a system-generated action message such as a member joining, leaving, or being banned from a group. It inherits all properties from BaseMessage and adds the following.

Properties

PropertyGetterReturn TypeDescription
actiongetAction()stringThe action being performed (e.g., "joined", "left", "kicked", "banned")
messagegetMessage()stringThe default human-readable action message
actionBygetActionBy()User | Group | BaseMessageThe entity that performed the action
actionOngetActionOn()User | Group | BaseMessageThe entity on which the action was performed
actionForgetActionFor()User | Group | BaseMessageThe entity for whom the action was performed
oldScopegetOldScope()stringPrevious scope of the member (for scope change actions)
newScopegetNewScope()stringNew scope of the member (for scope change actions)
rawDatagetRawData()ObjectRaw JSON data of the action message
metadatagetMetadata()ObjectCustom metadata attached to the action message

Call

Call extends BaseMessage and represents a voice or video call message. It inherits all properties from BaseMessage and adds the following.

Properties

PropertyGetterReturn TypeDescription
sessionIdgetSessionId()stringUnique session ID of the call
callInitiatorgetCallInitiator()UserThe user who initiated the call
callReceivergetCallReceiver()User | GroupThe user or group receiving the call
actiongetAction()stringThe call action (e.g., "initiated", "ongoing", "ended", "cancelled", "rejected")
initiatedAtgetInitiatedAt()numberTimestamp when the call was initiated
joinedAtgetJoinedAt()numberTimestamp when the call was joined
rawDatagetRawData()ObjectRaw JSON data of the call message
metadatagetMetadata()ObjectCustom metadata attached to the call message

AIAssistantMessage

AIAssistantMessage extends BaseMessage and represents the full assistant reply persisted after an AI Agent run completes. It is received via the onAIAssistantMessageReceived callback of the MessageListener. It inherits all properties from BaseMessage and adds the following.

Properties

PropertyGetterReturn TypeDescription
assistantMessageDatagetAssistantMessageData()AIAssistantMessageDataThe assistant message data containing runId, threadId, and text

AIAssistantMessageData

PropertyGetterReturn TypeDescription
runIdgetRunId()stringThe run ID of the agent execution
threadIdgetThreadId()stringThe thread ID of the conversation
textgetText()stringThe full text of the assistant’s reply

AIToolResultMessage

AIToolResultMessage extends BaseMessage and represents the output of a tool call made during an AI Agent run. It is received via the onAIToolResultReceived callback of the MessageListener. It inherits all properties from BaseMessage and adds the following.

Properties

PropertyGetterReturn TypeDescription
toolResultMessageDatagetToolResultMessageData()AIToolResultMessageDataThe tool result data containing runId, threadId, text, and toolCallId

AIToolResultMessageData

PropertyGetterReturn TypeDescription
runIdgetRunId()stringThe run ID of the agent execution
threadIdgetThreadId()stringThe thread ID of the conversation
textgetText()stringThe text output of the tool
toolCallIdgetToolCallId()stringThe ID of the tool call this result belongs to

AIToolArgumentMessage

AIToolArgumentMessage extends BaseMessage and represents the arguments passed to a tool during an AI Agent run. It is received via the onAIToolArgumentsReceived callback of the MessageListener. It inherits all properties from BaseMessage and adds the following.

Properties

PropertyGetterReturn TypeDescription
toolArgumentMessageDatagetToolArgumentMessageData()AIToolArgumentMessageDataThe tool argument data containing runId, threadId, and toolCalls

AIToolArgumentMessageData

PropertyGetterReturn TypeDescription
runIdgetRunId()stringThe run ID of the agent execution
threadIdgetThreadId()stringThe thread ID of the conversation
toolCallsgetToolCalls()AIToolCall[]Array of tool calls with their arguments

AIToolCall

PropertyGetterReturn TypeDescription
idgetId()stringUnique tool call ID
typegetType()stringType of the tool call
displayNamegetDisplayName()stringDisplay name of the tool
executionTextgetExecutionText()stringExecution text for the tool
functiongetFunction()AIToolCallFunctionThe function details (name and arguments)

AIToolCallFunction

PropertyGetterReturn TypeDescription
namegetName()stringName of the function being called
argumentsgetArguments()stringJSON string of the arguments passed to the function

AIAssistantBaseEvent

AIAssistantBaseEvent is the base class for all real-time streaming events from an AI Agent run. It is received via the onAIAssistantEventReceived callback of the AIAssistantListener. The type field identifies the specific event (e.g., "run_started", "tool_call_started", "text_message_content", "run_finished").

Properties

PropertyGetterReturn TypeDescription
typegetType()stringThe event type identifier
conversationIdgetConversationId()stringThe conversation ID associated with the event
messageIdgetMessageId()stringThe message ID associated with the event
parentMessageIdgetParentMessageId()stringThe parent message ID (if in a thread)
datagetData()objectAdditional event-specific data
data.timestampgetTimestamp()numberTimestamp of the event
data.runIdgetRunId()stringThe run ID of the agent execution
data.threadIdgetThreadId()stringThe thread ID of the conversation