
## Keyboard

Interactive buttons attached to a message via the `fields.keyboard` field. Each button is an object in the array.

## Button fields

| Field | Type | Default | Description |
|------|-----|-----------|---------|
| `TEXT` | string | — | Button text. Required for all buttons except `TYPE: "NEWLINE"` |
| `TYPE` | string | — | Special type: `NEWLINE` (move to a new line) |
| `LINK` | string | — | URL — the button becomes a link |
| `COMMAND` | string | — | Bot command (triggers the `ONIMBOTV2COMMANDADD` event) |
| `COMMAND_PARAMS` | string | — | Command parameters |
| `ACTION` | string | — | Action on click: `PUT` (insert into the input field), `SEND` (send text), `COPY` (copy), `CALL` (call), `DIALOG` (open chat) |
| `ACTION_VALUE` | string | — | Value for `ACTION` (text, phone number, chat ID) |
| `BG_COLOR` | string | — | Background color in HEX format (`#ff6600`) |
| `BG_COLOR_TOKEN` | string | `base` | Color token (see [the table below](#color-tokens)) |
| `TEXT_COLOR` | string | — | Text color in HEX format |
| `DISPLAY` | string | `BLOCK` | Display: `LINE` (in line with others) or `BLOCK` (full width) |
| `DISABLED` | string | `N` | Inactive button: `Y` or `N` |
| `BLOCK` | string | `N` | Lock after click: `Y` (deactivated after click) or `N` |
| `WIDTH` | integer | — | Button width in pixels |
| `CONTEXT` | string | `ALL` | Context: `MOBILE`, `DESKTOP`, `ALL` |
| `OFF_BG_COLOR` | string | — | Background color in the inactive state (after click when `BLOCK: "Y"`) |
| `OFF_TEXT_COLOR` | string | — | Text color in the inactive state |

## Color tokens

| Token | Color | Purpose |
|-------|------|-----------|
| `primary` | Blue | Primary action |
| `secondary` | Gray | Secondary action |
| `alert` | Red | Destructive action |
| `base` | White | Neutral button (default) |

## Example

```json
{
  "dialogId": "chat123",
  "fields": {
    "message": "Confirm the action:",
    "keyboard": [
      {
        "TEXT": "Approve",
        "BG_COLOR_TOKEN": "primary",
        "ACTION": "SEND",
        "ACTION_VALUE": "/approve",
        "BLOCK": "Y"
      },
      {
        "TEXT": "Reject",
        "BG_COLOR_TOKEN": "alert",
        "ACTION": "SEND",
        "ACTION_VALUE": "/reject",
        "BLOCK": "Y"
      },
      { "TYPE": "NEWLINE" },
      {
        "TEXT": "Details",
        "LINK": "https://portal.bitrix24.com/tasks/42/",
        "BG_COLOR_TOKEN": "secondary",
        "DISPLAY": "LINE"
      },
      {
        "TEXT": "Call the manager",
        "ACTION": "CALL",
        "ACTION_VALUE": "+12025550123",
        "DISPLAY": "LINE",
        "CONTEXT": "MOBILE"
      }
    ]
  }
}
```

## See also

- [Send message](/docs/bots/messages/send)
- [Update message](/docs/bots/messages/update)
- [Text formatting](/docs/bots/messages/formatting)
- [ATTACH blocks](/docs/bots/messages/attach)
