> ## Documentation Index
> Fetch the complete documentation index at: https://www.text.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Events

> Reference of Events methods for the Agent Chat RTM API v3.6.

## Send event preview

Sends an event that isn't saved in the chat. Use this method when you're preparing a longer response and want to send a partial update before sending the final message with [send\_event](#send_event). Only the `message` type is supported. Visibility must be set to `all` or skipped. The user must be added to the chat before they can send an event.

**Specifics**

|                     |                                                                                                                                                                                                                                                                                                                              |
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Action**          | `send_event_preview`                                                                                                                                                                                                                                                                                                         |
| **Required scopes** | <Tooltip tip="To send an event to a chat taking place in any group.">`chats--all:rw`</Tooltip> or <Tooltip tip="To send an event to a chat taking place in groups that the requester is a member of. The agent groups and the chat groups must overlap — at least one group must be in common.">`chats--access:rw`</Tooltip> |
| **Push message**    | —                                                                                                                                                                                                                                                                                                                            |

**Request**

| Parameter | Required | Type     | Notes                                               |
| --------- | -------- | -------- | --------------------------------------------------- |
| `chat_id` | Yes      | `string` | The ID of the chat you want to send the message to. |
| `event`   | Yes      | `object` | An event object. Supports only the `message` type.  |

No response payload.

```json title="Request" theme={null}
{
  "action": "send_event_preview",
  "payload": {
    "chat_id": "PW94SJTGW6",
    "event": {
      "type": "message",
      "text": "Preview of a longer response...",
      "visibility": "all",
      "custom_id": "31-0C-1C-07-DB-16"
    }
  }
}
```

```json title="Response" theme={null}
{
  "request_id": "<request_id>",
  "action": "send_event_preview",
  "type": "response",
  "success": true,
  "payload": {}
}
```

***

## Send event

Sends an [event object](/api/agent-chat/v3.6/rtm/data-structures#events). Use this method to send a message by specifying the `message` event type in the request.

The user must be added to the chat before they can send an event. Events with `visibility:agents` are sent to agents only, and with `visibility:all` to all users. Users with `visibility:agents` cannot send events with `visibility:all`.

The method updates the requester's `events_seen_up_to` as if they've seen all chat events.

**Specifics**

|                     |                                                                                                                                                                                                                                                                                                                              |
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Action**          | `send_event`                                                                                                                                                                                                                                                                                                                 |
| **Required scopes** | <Tooltip tip="To send an event to a chat taking place in any group.">`chats--all:rw`</Tooltip> or <Tooltip tip="To send an event to a chat taking place in groups that the requester is a member of. The agent groups and the chat groups must overlap — at least one group must be in common.">`chats--access:rw`</Tooltip> |
| **Push message**    | `incoming_event`                                                                                                                                                                                                                                                                                                             |

**Request**

| Parameter | Required | Type     | Notes                                                            |
| --------- | -------- | -------- | ---------------------------------------------------------------- |
| `chat_id` | Yes      | `string` | The ID of the chat you want to send the message to.              |
| `event`   | Yes      | `object` | An event object. Does not support the `form` type event in Text. |

**Response**

| Field      | Type     | Notes |
| ---------- | -------- | ----- |
| `event_id` | `string` |       |

```json title="Request" theme={null}
{
  "action": "send_event",
  "payload": {
    "chat_id": "PW94SJTGW6",
    "event": {
      "type": "message",
      "text": "hello world",
      "visibility": "all"
    }
  }
}
```

```json title="Response" theme={null}
{
  "request_id": "<request_id>",
  "action": "send_event",
  "type": "response",
  "success": true,
  "payload": {
    "event_id": "K600PKZON8"
  }
}
```

***

## Send rich message postback

**Specifics**

|                     |                                                                                                                                                                                                                                                                                                                                  |
| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Action**          | `send_rich_message_postback`                                                                                                                                                                                                                                                                                                     |
| **Required scopes** | <Tooltip tip="To send a postback to a chat taking place in any group.">`chats--all:rw`</Tooltip> or <Tooltip tip="To send a postback to a chat taking place in groups that the requester is a member of. The agent groups and the chat groups must overlap — at least one group must be in common.">`chats--access:rw`</Tooltip> |
| **Push message**    | `incoming_rich_message_postback`\*                                                                                                                                                                                                                                                                                               |

\* `incoming_rich_message_postback` is sent only for active threads.

**Request**

| Parameter                       | Required | Type     | Notes                                       |
| ------------------------------- | -------- | -------- | ------------------------------------------- |
| `chat_id`                       | Yes      | `string` |                                             |
| `event_id`                      | Yes      | `string` |                                             |
| `postback`                      | Yes      | `object` |                                             |
| `postback.id`                   | Yes      | `string` | The postback name of the button.            |
| `postback.toggled`              | Yes      | `bool`   | Whether the postback is toggled.            |
| `postback.button_type`          | No       | `string` |                                             |
| `postback.button_value`         | No       | `string` |                                             |
| `postback.ecommerce`            | No       | `object` |                                             |
| `postback.ecommerce.product_id` | No       | `string` | Required when sending `postback.ecommerce`. |
| `postback.ecommerce.option_id`  | No       | `string` |                                             |
| `postback.ecommerce.quantity`   | No       | `number` |                                             |
| `thread_id`                     | Yes      | `string` |                                             |

No response payload.

```json title="Request" theme={null}
{
  "action": "send_rich_message_postback",
  "payload": {
    "chat_id": "PJ0MRSHTDG",
    "thread_id": "K600PKZON8",
    "event_id": "a0c22fdd-fb71-40b5-bfc6-a8a0bc3117f7",
    "postback": {
      "id": "Method URL_yes",
      "toggled": true,
      "button_type": "url",
      "button_value": "https://www.example.com",
      "ecommerce": {
        "product_id": "12345",
        "option_id": "red-xl",
        "quantity": 1
      }
    }
  }
}
```

```json title="Response" theme={null}
{
  "request_id": "<request_id>",
  "action": "send_rich_message_postback",
  "type": "response",
  "success": true,
  "payload": {}
}
```
