Skip to main content
CometChat supports three types of messages: You can also send Interactive Messages for forms, cards, and custom UI elements.

Text Message

Send a text message using sendMessage() with a TextMessage object.
The TextMessage class constructor takes the following parameters: On success, sendMessage() returns a TextMessage object containing all information about the sent message.

Add Metadata

Attach custom JSON data to the message:

Add Tags

Tag messages for easy filtering later:

Quote a Message

Reply to a specific message by setting its ID:

Media Message

Send images, videos, audio, or files using sendMediaMessage(). There are two ways to send media messages:
  1. Upload a file — Pass a File object and CometChat uploads it automatically
  2. Send a URL — Provide a URL to media hosted on your server or cloud storage

Add Metadata

Add Caption

Add text along with the media:

Add Tags

Upload a File

Pass a File object directly. CometChat uploads it to its servers and returns the URL in the success response.
The MediaMessage class constructor takes the following parameters:

Send a URL

Send media hosted on your server or cloud storage using the Attachment class:
On success, sendMediaMessage() returns a MediaMessage object.

Multiple Attachments

Starting version 3.0.9, the SDK supports sending multiple attachments in a single media message.

Upload Multiple Files

The MediaMessage class constructor takes the following parameters:

Send Multiple URLs

When a media message is sent successfully, the response will include a MediaMessage object which includes all information related to the sent message. You can use the setMetadata(), setCaption() & setTags() methods to add metadata, caption and tags in the same way as a single attachment.

Custom Message

Send custom data that doesn’t fit text or media using sendCustomMessage().
You can also set a subtype using setSubtype() to further classify the custom message.

Add Tags

Once the message object is ready, call sendCustomMessage().
On success, sendCustomMessage() returns a CustomMessage object.

Control Conversation Update

By default, a custom message updates the conversation’s last message. To prevent this:

Custom Notification Text

Set custom text for push, email, and SMS notifications:
It is also possible to send interactive messages from CometChat, to know more click here

Next Steps

Receive Messages

Listen for incoming messages in real time

Edit Message

Modify sent messages after delivery

Delete Message

Remove messages from conversations

Interactive Messages

Send messages with embedded forms and buttons

Message Payload Structure

The BaseMessage object returned by SDK methods contains the following fields. TextMessage, MediaMessage, and CustomMessage extend this base structure with additional type-specific fields.Sample BaseMessage Object:
The nested User object (used in sender, receiver, mentionedUsers) contains:
The nested Group object (used in receiver for group messages) contains:
The nested ReactionCount object (used in reactions array) contains: