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
├── InteractiveMessage
└── 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

InteractiveMessage

InteractiveMessage extends BaseMessage and represents a message with interactive UI elements such as forms, cards, or buttons. It inherits all properties from BaseMessage and adds the following.

Properties

PropertyGetterReturn TypeDescription
interactiveDatagetInteractiveData()ObjectThe interactive element data (form fields, buttons, etc.)
interactionGoalgetInteractionGoal()InteractionGoalThe goal that defines when the interaction is considered complete
interactionsgetInteractions()Interaction[]Array of interactions that have occurred on this message
allowSenderInteractiongetIsSenderInteractionAllowed()booleanWhether the sender is allowed to interact with the 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