> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-22654f5b-docs-agent-in-group-react-v6.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Message Structure and Hierarchy

> Understand the message categories, types, and hierarchy in the CometChat React Native SDK including text, media, custom, action, call, and interactive messages.

<Accordion title="AI Integration Quick Reference">
  Message categories and types:

  * **message** → `text`, `image`, `video`, `audio`, `file`
  * **custom** → Developer-defined types (e.g., `location`, `poll`)
  * **action** → `groupMember` (joined/left/kicked/banned), `message` (edited/deleted)
  * **call** → `audio`, `video`
  * **interactive** → `form`, `card`, `customInteractive`
</Accordion>

Every message in CometChat belongs to a category (`message`, `custom`, `action`, `call`, `interactive`) and has a specific type within that category.

## Message Hierarchy

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b-docs-agent-in-group-react-v6/-aV5rjAnFmfmGI_M/images/826e0908-chatsdk-12bedefdc00fab14fcf19611607bd064.jpg?fit=max&auto=format&n=-aV5rjAnFmfmGI_M&q=85&s=1657fe52e4549ea7dda351c8d5693389" width="3552" height="2456" data-path="images/826e0908-chatsdk-12bedefdc00fab14fcf19611607bd064.jpg" />
</Frame>

## Categories Overview

| Category      | Types                                     | Description                         |
| ------------- | ----------------------------------------- | ----------------------------------- |
| `message`     | `text`, `image`, `video`, `audio`, `file` | Standard user messages              |
| `custom`      | Developer-defined                         | Custom data (location, polls, etc.) |
| `action`      | `groupMember`, `message`                  | System-generated events             |
| `call`        | `audio`, `video`                          | Call-related messages               |
| `interactive` | `form`, `card`, `customInteractive`       | Interactive messages (forms, cards) |

## Checking Message Category and Type

Use `getCategory()` and `getType()` to determine how to handle a received message:

<Tabs>
  <Tab title="TypeScript">
    ```typescript theme={null}
    const category: string = message.getCategory();
    const type: string = message.getType();

    switch (category) {
      case CometChat.CATEGORY_MESSAGE:
        if (type === CometChat.MESSAGE_TYPE.TEXT) {
          const textMsg = message as CometChat.TextMessage;
          console.log("Text:", textMsg.getText());
        } else if (type === CometChat.MESSAGE_TYPE.IMAGE) {
          const mediaMsg = message as CometChat.MediaMessage;
          console.log("Image URL:", mediaMsg.getData().url);
        }
        break;
      case CometChat.CATEGORY_CUSTOM:
        const customMsg = message as CometChat.CustomMessage;
        console.log("Custom type:", type, "data:", customMsg.getData());
        break;
      case CometChat.CATEGORY_ACTION:
        console.log("Action:", message.getAction());
        break;
      case CometChat.CATEGORY_CALL:
        console.log("Call status:", message.getStatus());
        break;
    }
    ```
  </Tab>

  <Tab title="JavaScript">
    ```javascript theme={null}
    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;
    }
    ```
  </Tab>
</Tabs>

## Standard Messages (`message` Category)

Messages with category `message` are standard user-sent messages:

| Type    | Description        |
| ------- | ------------------ |
| `text`  | Plain text message |
| `image` | Image attachment   |
| `video` | Video attachment   |
| `audio` | Audio attachment   |
| `file`  | File attachment    |

## Custom Messages (`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`).

```javascript theme={null}
// 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](/sdk/react-native/send-message#custom-message) for details.

## Interactive Messages (`interactive` Category)

An InteractiveMessage encapsulates an interactive unit within a chat message, such as an embedded form that users can fill out directly within the chat interface.

| Type                | Description                 |
| ------------------- | --------------------------- |
| `form`              | Interactive form messages   |
| `card`              | Interactive card messages   |
| `customInteractive` | Custom interaction messages |

See [Interactive Messages](/sdk/react-native/interactive-messages) for details.

## Action Messages (`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 Messages (`call` Category)

Call messages track call events with types `audio` or `video`. The `status` property indicates the call state:

| Status       | Description                   |
| ------------ | ----------------------------- |
| `initiated`  | Call started                  |
| `ongoing`    | Call accepted and in progress |
| `canceled`   | Caller canceled               |
| `rejected`   | Receiver rejected             |
| `unanswered` | No answer                     |
| `busy`       | Receiver on another call      |
| `ended`      | Call completed                |

See [Default Calling](/sdk/react-native/default-call) or [Direct Calling](/sdk/react-native/direct-call) for implementation.

***

## Next Steps

<CardGroup cols={2}>
  <Card title="Send Messages" icon="paper-plane" href="/sdk/react-native/send-message">
    Send text, media, and custom messages
  </Card>

  <Card title="Receive Messages" icon="envelope-open" href="/sdk/react-native/receive-messages">
    Listen for incoming messages in real time
  </Card>

  <Card title="Interactive Messages" icon="hand-pointer" href="/sdk/react-native/interactive-messages">
    Build forms, cards, and custom interactive messages
  </Card>

  <Card title="Message Filtering" icon="filter" href="/sdk/react-native/additional-message-filtering">
    Advanced message filtering with RequestBuilder
  </Card>
</CardGroup>
