---
related_nodes: ["telegram_message_trigger", "telegram_send", "telegram_form_callback"]
---

# Telegram Action

Runs Telegram bot actions from one node. The `send_message` operation shares the same send semantics as [Telegram Send](telegram_send.md), including attachment support.

## Configuration

**connection** — Telegram bot connection (ULID). Use the returned connection ID. Must be a `telegram_bot` connection type. Empty or malformed values fail validation: `Telegram bot connection is required` or `expected ULID connection id`.

**operation** — action to run:

- `send_message`
- `send_chat_action`
- `answer_callback_query`
- `edit_message_text`
- `edit_message_reply_markup`
- `delete_message`
- `set_message_reaction`

String fields support workflow interpolation such as `{{ input.chat_id }}`.

**retry** — Whether a request is sent again after a failure that passes: a rate limit, a busy server, a dropped connection. Off by default; see [Retries](http_get.md#retries) for how attempts and waits work. Every operation is a write, sent again only when Telegram refused it before acting: the connection never opened, or Telegram answered 425 or 429. `send_message` uploads of photos, voice and documents go once.

## Operations

### send_message

Fields:

- `chat_id` — Chat ID (`TextBlock`). Resolves to a numeric chat ID. Must parse as an integer: `chat_id must be an integer`.
- `text` — Message text (`TextBlock`). Supports Telegram markdown and interpolation. Required for text-only sends: `text is required when attachments are empty`. Optional when attachments are present.
- `reply_to_message_id` — Optional message ID to reply to (literal integer).
- `reply_markup` — Optional Telegram reply markup JSON object (`TextBlock`). Supports interpolation. Only valid for text-only sends; attachments plus reply_markup fails with `reply_markup cannot be used with Telegram attachments`.
- `attachments` — Attachment binding expression (`TextBlock`). Interpolates exactly to a direct runtime binary, binary wrapper `{ binary, filename?, content_type?, caption? }`, media reference wrapper `{ object_id, filename?, caption? }`, or a flat array of those. JSON string config accepts media references only. Wrapper/media-reference `caption` is retained for that attachment and overrides `text`.

Attachment send behavior mirrors `telegram_send`:
- Text is optional when attachments are present.
- Text becomes the first attachment's caption unless that attachment has its own `caption`.
- `image/*` content type → photo; `audio/ogg` or `.ogg` filename → voice; everything else → document.
- `reply_markup` plus attachments is rejected before sending.

### send_chat_action

Fields:

- `chat_id`
- `action`

Actions:

- `typing`
- `upload_photo`
- `record_video`
- `upload_video`
- `record_voice`
- `upload_voice`
- `upload_document`
- `choose_sticker`

### answer_callback_query

Fields:

- `callback_query_id`
- `text`
- `show_alert`

### edit_message_text

Fields:

- `chat_id`
- `message_id`
- `text`
- `reply_markup`

### edit_message_reply_markup

Fields:

- `chat_id`
- `message_id`
- `reply_markup`

Empty `reply_markup` clears the message reply markup.

### delete_message

Fields:

- `chat_id`
- `message_id`

### set_message_reaction

Fields:

- `chat_id`
- `message_id`
- `reaction`
- `is_big`

Reaction kinds:

- `emoji` with `emoji`
- `custom_emoji` with `custom_emoji_id`
- `paid`
- `clear`

## Inputs

`input` is any upstream JSON payload used for interpolation.

Examples:

- `{{ input.chat_id }}`
- `{{ input.message.message_id }}`
- `{{ input.callback_query.id }}`

## Outputs

`output` wraps the operation result:

```json
{
  "success": true,
  "operation": "delete_message",
  "result": { "ok": true }
}
```

`send_message` returns sent message details under `result`:

```json
{
  "success": true,
  "operation": "send_message",
  "result": {
    "message_id": 123,
    "chat_id": -100123,
    "text": "Hello",
    "sent_at": 1704067200,
    "attachments": [],
    "messages": []
  }
}
```

When attachments are present, `send_message` result includes `attachments` and `messages` arrays:

```json
{
  "success": true,
  "operation": "send_message",
  "result": {
    "message_id": 123,
    "chat_id": -100123,
    "text": "",
    "sent_at": 1704067200,
    "attachments": [
      { "message_id": 123, "chat_id": -100123, "attachment_type": "photo", "filename": "chart.png" }
    ],
    "messages": [
      { "provider": "telegram", "message_id": 123, "chat_id": -100123, "filename": "chart.png", "attachment_type": "photo" }
    ]
  }
}
```

Fields in `result`:
- `message_id` — Telegram message ID of the first message sent
- `chat_id` — Chat where message was sent
- `text` — Message text or resolved caption
- `sent_at` — Unix timestamp when sent
- `attachments` — Array of sent attachment summaries. Each has `message_id`, `chat_id`, `attachment_type` (one of `photo`, `voice`, `document`), `filename`, and optional `content_type`.
- `messages` — Array of per-message Telegram results. Each has `provider`, `message_id`, `chat_id`, optional `filename`, and optional `attachment_type`.

## Runtime Errors

| Error | Cause | Remediation |
|-------|-------|-------------|
| `Telegram bot connection is required` | Connection field is empty | Select a Telegram bot connection from Settings → Connections |
| `expected ULID connection id` | Connection field contains a malformed value | Select a valid connection from Settings → Connections |
| `chat_id must be an integer` | Chat ID resolved to a non-integer value | Ensure chat_id config resolves to a numeric chat ID |
| `text is required when attachments are empty` | Text is empty and no attachments configured on send_message | Provide text or configure attachments |
| `reply_markup cannot be used with Telegram attachments` | Both reply_markup and attachments configured on send_message | Send a text keyboard message separately or omit reply_markup |
| `expected ULID media object id` | A `object_id` in the attachment value is not a valid ULID | Check the media object ID came from a media-producing node |
| `Failed to resolve media object` | `object_id` does not exist or is inaccessible | Check the media object ID came from the same workspace |
| Telegram API error | Bot lacks permission, chat not found, or API error | Check bot permissions and chat membership |
