Skip to main content
Quick Reference for AI Agents & DevelopersMessage 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
The below diagram helps you better understand the various message categories and types that a CometChat message can belong to.

Checking Message Category and Type

You can determine the category and type of any received message using the following methods:
// Check message category
const category = message.getCategory(); // "message", "custom", "action", "call", "interactive"

// Check message type
const type = message.getType(); // "text", "image", "video", "audio", "file", etc.

// Example: Handle different message categories
switch (category) {
  case CometChat.CATEGORY_MESSAGE:
    if (type === CometChat.MESSAGE_TYPE.TEXT) {
      console.log("Text message:", message.getText());
    } else if (type === CometChat.MESSAGE_TYPE.IMAGE) {
      console.log("Image URL:", message.getData().url);
    }
    break;
  case CometChat.CATEGORY_CUSTOM:
    console.log("Custom message 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;
}
As you can see in the above diagram, every message belongs to a particular category. A message can belong to either one of the 4 categories
  1. Message
  2. Custom
  3. Action
  4. Call
Each category can be further be classified into types. A message belonging to the category message can be classified into either 1 of the below types:
  1. text - A plain text message
  2. image- An image message
  3. video- A video message
  4. audio- An audio message
  5. file- A file message

Custom

In the case of messages that belong to the custom category, there are no predefined types. Custom messages can be used by developers to send messages that do not fit in the default category and types provided by CometChat. For messages with the category custom, the developers can set their own type to uniquely identify the custom message. A very good example of a custom message would be the sharing of location co-ordinates. In this case, the developer can decide to use the custom message with type set to location. For sending custom messages, see Send Message → Custom Messages.

Interactive

An InteractiveMessage is a specialized object that encapsulates an interactive unit within a chat message, such as an embedded form that users can fill out directly within the chat interface. Messages belonging to the interactive category can further be classified into one of the below types:
  1. form- for interactive form
  2. card- for interactive card
  3. customInteractive- for custom interaction messages
to know about Interactive messages please click here

Action

Action messages are system-generated messages. Messages belonging to the action category can further be classified into one of the below types:
  1. groupMember - action performed on a group member.
  2. message - action performed on a message.
Action messages hold another property called action which actually determine the action that has been performed For the type groupMember the action can be either one of the below:
  1. joined - when a group member joins a group
  2. left - when a group member leaves a group
  3. kicked - when a group member is kicked from the group
  4. banned - when a group member is banned from the group
  5. unbanned - when a group member is unbanned from the group
  6. added - when a user is added to the group
  7. scopeChanged - When the scope of a group member is changed.
For the type message, the action can be either one of the below:
  1. edited - when a message is edited.
  2. deleted - when a message is deleted.

Call

Messages with the category call are Calling related messages. These can belong to either one of the 2 types
  1. audio
  2. video
For implementing calling, see Default Calling or Direct Calling. The call messages have a property called status that helps you figure out the status of the call. The status can be either one of the below values:
  1. initiated - when a is initiated to a user/group
  2. ongoing - when the receiver of the call has accepted the call
  3. canceled - when the call has been canceled by the initiator of the call
  4. rejected - when the call has been rejected by the receiver of the call
  5. unanswered - when the call was not answered by the receiver.
  6. busy - when the receiver of the call was busy on another call.
  7. ended - when the call was successfully completed and ended by either the initiator or receiver.

Next Steps