Skip to main content
Message categories and types:
  • messagetext, image, video, audio, file
  • custom → Developer-defined types (e.g., location, poll)
  • interactiveform, card, customInteractive
  • actiongroupMember (joined/left/kicked/banned), message (edited/deleted)
  • callaudio, video
Every message in CometChat belongs to a category and has a specific type. Understanding this hierarchy helps you handle different message types correctly in your application.

Message Hierarchy

Categories Overview

CategoryTypesDescription
messagetext, image, video, audio, fileStandard user messages
customDeveloper-definedCustom data (location, polls, etc.)
interactiveform, card, customInteractiveMessages with actionable UI elements
actiongroupMember, messageSystem-generated events
callaudio, videoCall-related messages

Checking Message Category and Type

Use getCategory() and getType() to determine how to handle a received message:
const category = message.getCategory();
const type = message.getType();

switch (category) {
  case CometChat.CATEGORY_MESSAGE:
    if (type === CometChat.MESSAGE_TYPE.TEXT) {
      console.log("Text:", message.getText());
    } else if (type === CometChat.MESSAGE_TYPE.IMAGE) {
      console.log("Image URL:", message.getData().url);
    }
    break;
  case CometChat.CATEGORY_CUSTOM:
    console.log("Custom type:", type, "data:", message.getData());
    break;
  case CometChat.CATEGORY_ACTION:
    console.log("Action:", message.getAction());
    break;
  case CometChat.CATEGORY_CALL:
    console.log("Call status:", message.getStatus());
    break;
}

Message Category

Messages with category message are standard user-sent messages:
TypeDescription
textPlain text message
imageImage attachment
videoVideo attachment
audioAudio attachment
fileFile attachment

Custom Category

Custom messages allow you to send data that doesn’t fit the default categories. You define your own type to identify the message (e.g., location, poll, sticker).
// Example: Sending a location as a custom message
const customMessage = new CometChat.CustomMessage(
  receiverID,
  CometChat.RECEIVER_TYPE.USER,
  "location",
  { latitude: 37.7749, longitude: -122.4194 }
);
See Send Message → Custom Messages for details.

Interactive Category

Interactive messages contain actionable UI elements that users can interact with directly in the chat:
TypeDescription
formEmbedded form with input fields
cardCard with buttons and actions
customInteractiveCustom interactive elements
See Interactive Messages for implementation details.

Action Category

Action messages are system-generated events. They have a type and an action property: Type: groupMember — Actions on group members:
  • joined — Member joined the group
  • left — Member left the group
  • kicked — Member was kicked
  • banned — Member was banned
  • unbanned — Member was unbanned
  • added — Member was added
  • scopeChanged — Member’s scope was changed
Type: message — Actions on messages:
  • edited — Message was edited
  • deleted — Message was deleted

Call Category

Call messages track call events with types audio or video. The status property indicates the call state:
StatusDescription
initiatedCall started
ongoingCall accepted and in progress
canceledCaller canceled
rejectedReceiver rejected
unansweredNo answer
busyReceiver on another call
endedCall completed
See Default Calling or Direct Calling for implementation.

Next Steps

Send Messages

Send text, media, and custom messages

Receive Messages

Listen for incoming messages in real time

Interactive Messages

Send messages with embedded forms and buttons

Additional Filtering

Advanced message filtering with RequestBuilder