Quick Reference
| Type | Method | Use Case |
|---|---|---|
| Text | sendMessage() | Standard chat messages |
| Media | sendMediaMessage() | Images, videos, audio, files |
| Custom | sendCustomMessage() | Location, polls, custom data |
| Interactive | sendInteractiveMessage() | Forms, cards, buttons |
Text Message
Send plain text messages to users or groups.- To User
- To Group
- TypeScript
- Async/Await
TextMessage Parameters
| Parameter | Type | Description |
|---|---|---|
receiverID | string | UID of user or GUID of group |
messageText | string | The text content |
receiverType | string | CometChat.RECEIVER_TYPE.USER or GROUP |
Optional: Add Metadata
Attach custom data (like location) to any message:Optional: Add Tags
Tag messages for filtering or categorization:Optional: Quote a Message
Reply to a specific message:Media Message
Send images, videos, audio files, and documents.Send File from Input
Upload files directly from a file input:- To User
- To Group
Message Types
| Type | Constant | File Types |
|---|---|---|
| Image | CometChat.MESSAGE_TYPE.IMAGE | jpg, png, gif, etc. |
| Video | CometChat.MESSAGE_TYPE.VIDEO | mp4, mov, etc. |
| Audio | CometChat.MESSAGE_TYPE.AUDIO | mp3, wav, etc. |
| File | CometChat.MESSAGE_TYPE.FILE | pdf, doc, etc. |
Send File from URL
Send media hosted on your server or cloud storage:Send Multiple Attachments
Send multiple files in a single message:- From File Input
- From URLs
Optional: Add Caption
Add text description to media:Optional: Add Metadata & Tags
Custom Message
Send structured data like location coordinates, polls, or any custom payload.- To User
- To Group
CustomMessage Parameters
| Parameter | Type | Description |
|---|---|---|
receiverID | string | UID of user or GUID of group |
receiverType | string | USER or GROUP |
customType | string | Your custom type (e.g., “location”, “poll”) |
customData | object | JSON payload with your data |
Control Conversation Update
By default, custom messages update the conversation’s last message. To prevent this:Custom Notification Text
Set custom text for push/email/SMS notifications:Common Options
These options work with all message types:Quote a Message (Reply)
Add Metadata
Add Tags
Message Response
On success, you receive a message object with:| Property | Description |
|---|---|
id | Unique message ID |
sender | User object of sender |
receiver | User/Group object of receiver |
sentAt | Timestamp when sent |
type | Message type (text, image, etc.) |
category | Message category |
data | Message content/payload |
- JavaScript
- Async/Await