---
related_nodes: ["discord_bot", "webhook_trigger", "webhook_response"]
---

# Discord Action

Performs stateless Discord HTTP actions using either a Discord bot-token connection or a Discord webhook connection.

## When to Use

- Send or edit Discord messages through a Discord bot-token connection
- List Discord channels, members, or messages without a gateway trigger
- Respond to or defer Discord interactions when you already have `interaction_id` and `token`
- Send channel-scoped messages through a Discord webhook credential

Discord Action covers the operations listed below, not the entire Discord REST API. For an operation that is not represented here, use `HTTP Request` with the same Discord bot connection. Keep the bot token in the connection rather than adding an `Authorization` header to the workflow.

## Configuration

### credential_kind

Choose which credential family this node should use:

- `connection` — Discord token connection (`discord_bot`)
- `webhook` — Discord webhook connection (`discord_webhook`)

### connection

Shown when `credential_kind = connection`.

Select a Discord api token connection from **Settings → Connections**.

Agent discovery: call `list_connections` with `provider_name: "discord_bot"` before asking the user for a Discord token. Use this credential kind for Discord API operations, including `list_channels`.

### webhook_connection

Shown when `credential_kind = webhook`.

Select a Discord webhook connection from **Settings → Connections**.

Agent discovery: call `list_connections` with `provider_name: "discord_webhook"` before asking the user for a webhook. Webhook credentials are channel-scoped and only support webhook `send_message` in this node.

### 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. `defer_update`, `update_message`, `show_modal` and webhook `send_message` are writes, sent again only when Discord refused them before acting: the connection never opened, or Discord answered 425 or 429. `edit_original_response` with `components` first looks up the bot's application, a read sent again freely. Uploads, meaning anything with `attachments` or with `components` on `send_message`, `edit_message`, `respond_to_interaction` and `edit_original_response`, go once. The other operations go through Discord's own client, which handles Discord's rate limits itself, and Retry does not apply to them.

### Operations

Connection operations:

- `send_message`
- `reply`
- `react`
- `edit_message`
- `delete_message`
- `send_typing`
- `list_channels`
- `list_members`
- `list_messages`
- `respond_to_interaction`
- `defer_interaction`
- `defer_update`
- `update_message`
- `show_modal`
- `edit_original_response`
- `set_presence`

### Bot presence

`set_presence` sets the bot's online status and activity:

- `status`: `online`, `idle`, `dnd` (Do Not Disturb), or `invisible`
- `activity`: tagged by `kind`
  - `none`
  - `custom` with `state`, a custom status message
  - `playing`, `listening`, `watching`, `competing` with `name`
  - `streaming` with `name` and `url`; the url must be a twitch.tv or youtube.com link

Activity text is interpolated and must be at most 128 characters once rendered.

Presence is a gateway feature with no HTTP endpoint, so this operation needs a running listener: a `Discord Bot` trigger installed on the same connection. Without one the run fails with "No listener is configured for this Discord bot". The operation never connects the gateway itself. The presence lasts until the next change, the last listener on the connection going away, or a Verdalia restart. A `Discord Bot` trigger's `initial_presence` replaces it when that trigger is installed or its workflow is saved.

Output: `{ "status": "idle", "activity": { "kind": "custom", "state": "Shipping" } }`, with `activity` null for `none`.

### Discord listing behavior

- Use `list_channels` with `credential_kind = connection` and a `discord_bot` connection to discover numeric channel IDs.
- Message operations that take `channel_id` require a Discord numeric channel snowflake, not a channel name such as `#general`.
- `list_members` paginates internally to return the requested total, even past Discord's per-request cap.
- `list_messages` in `latest` mode fetches the N most recent messages and can paginate internally.
- `before` pages backward from a message ID.
- `after` uses Discord's single-request window.
- `around` uses Discord's single-request window.
- Cursor values are Discord message IDs (snowflakes), not timestamps.
- Supported cursor modes are `latest`, `before`, `after`, and `around`.

### Message-content limit

Discord content is limited to **2,000 UTF-16 code units**. Discord Action sends exactly one request: it does not split, truncate, or iterate array input.

For text that can exceed the limit, use the explicit sequential graph for message-creating operations (`send_message`, `reply`, and webhook `send_message`):

```text
Split Text.output → Loop.input
Loop.loop → Discord Action.input
```

Set the Discord Action `content` field to `{{ input }}`. `Split Text.output` is one array value; Loop is required to send one ordered chunk per Discord request.

Do **not** loop `edit_message`, `edit_original_response`, `update_message`, or an initial `respond_to_interaction`. Repeated edits overwrite the same message and repeated initial interaction responses fail. Those operations require content under 2,000 units; shorten it, attach a file when the operation supports attachments, or use an appropriate deferred/follow-up flow.

Webhook operations:

- `send_message`

For message and response operations, `embeds` is one JSON text block.

Accepted shapes:
- one embed object
- an array of embed objects

The field is interpolated before parsing.

Single embed example:

```json
{"title":"Build failed","url":"https://example.com/build/123"}
```

Multiple embeds example:

```json
[
  {"title":"Leaderboard","description":"Top 10"},
  {"image":{"url":"https://example.com/chart.png"}}
]
```

Pass-through from upstream payload:

```text
{{ input.embeds }}
```

`input.embeds` can be either an object or array.

For message and response operations, `attachments` is interpolated exactly from the
workflow input and accepts a direct runtime binary, a binary wrapper
`{ "binary": ..., "filename"?, "content_type"? }`, a media reference wrapper
`{ "object_id": ... }`, or a flat array of those
values. The legacy JSON attachment format remains accepted: an object or array of
objects with `url` (HTTP/HTTPS) or `base64`. A `url` must reach a public address, under the same
rules as HTTP Request.

Examples:

```json
{"url":"https://example.com/image.png"}
```

For message and interaction operations, `components` is one JSON text block containing a raw Discord components array.

Supported here:
- `send_message` without attachments
- `edit_message` without attachments
- `respond_to_interaction` without attachments
- `update_message`
- `show_modal`
- `edit_original_response` without attachments

Empty means no components. Non-empty input must parse as a JSON array. Raw components cannot be combined with attachments for `send_message`, `edit_message`, `respond_to_interaction`, or `edit_original_response`; use no attachments or omit components.

Button response example:

```json
[
  {
    "type": 1,
    "components": [
      {"type": 2, "style": 1, "custom_id": "approve", "label": "Approve"}
    ]
  }
]
```

Modal example:

```json
[
  {
    "type": 1,
    "components": [
      {
        "type": 4,
        "custom_id": "summary",
        "label": "Summary",
        "style": 2,
        "required": true
      }
    ]
  }
]
```

```json
[
  {"url":"https://example.com/chart.png","filename":"chart.png"},
  {"base64":"{{ input.output.base64 }}","filename":"snapshot.png","content_type":"image/png"}
]
```

This example expects `Read Media` with `output_format = base64` upstream. HTTP Request returns binary responses as runtime binary, not as a `body_base64` field; persist or transform that binary explicitly before using a base64-only attachment input.

## Inputs

`input` is any upstream JSON payload.

Workflow templates are keyed by input socket name. For object-shaped standard input, use `{{ input.message.channel_id }}`. If the standard input socket contains an array, use numeric path segments such as `{{ input.0.message.channel_id }}`. To render the entire standard input socket, use `{{ input }}`.

Exact template paths such as `{{ input.embeds }}` can pass through a whole JSON object or array for fields that accept JSON.

If an interpolation error says `Available inputs: input: array(len=1)`, the `input` socket is an array. Add a numeric segment to the path. Example: change `{{ input.message.channel_id }}` to `{{ input.0.message.channel_id }}`.

Examples:

Object-shaped input:

- `{{ input.message.channel_id }}`
- `{{ input.message.id }}`
- `{{ input.interaction.id }}`
- `{{ input.interaction.token }}`
- `{{ input.body.id }}`
- `{{ input.body.token }}`

Array-shaped input:

- `{{ input.0.message.channel_id }}`
- `{{ input.0.message.id }}`

## Outputs

`output` is the raw operation result.

- Message mutations usually return `{ "success": true }` plus `message_id` when Discord creates a message
- Interaction mutations return `{ "success": true }`
- List operations return arrays of channels, members, or messages

## Important Contract Notes

- This node is **stateless only**. It does not subscribe to the Discord gateway; `set_presence` uses the gateway a `Discord Bot` trigger already holds.
- This node does **not** inspect `input.provenance`.
- `edit_original_response` does **not** require `application_id` in node config or input.
- Initial interaction callbacks must reach Discord within Discord's 3-second deadline.
- `show_modal` sends callback type 9 and must be the initial callback; it cannot run after `defer_interaction`/`defer_update`.
- `show_modal` cannot respond to a modal submit interaction. Use `respond_to_interaction`, `update_message`, or `defer_update` for modal submit handling.

## Examples

### Reply to a slash command from Discord Bot

Use `Discord Bot` with `event_kind = slash_command`, then configure `Discord Action` with:

- `credential_kind`: `connection`
- `connection`: selected Discord bot-token connection
- `operation`: `respond_to_interaction`
- `interaction_id`: `{{ input.interaction.id }}`
- `token`: `{{ input.interaction.token }}`

### Defer, then edit the original interaction response

1. `Discord Action` with `defer_interaction`
   - `interaction_id`: `{{ input.interaction.id }}`
   - `token`: `{{ input.interaction.token }}`
2. Later, another `Discord Action` with `edit_original_response`
   - `token`: `{{ input.interaction.token }}`
    - `content`: bounded text (at most 2,000 UTF-16 code units); this edit cannot be looped to create multiple messages
   - optional `embeds`: Discord embed JSON (object or array)
   - optional `attachments`: Discord attachment JSON (object or array)

### Send a webhook message

Use `credential_kind = webhook` with:

- `webhook_connection`: selected Discord webhook connection
- `operation`: `send_message`
- `content`: message text
- optional `username` and `avatar_url` overrides
- optional `embeds`: Discord embed JSON (object or array)
- optional `attachments`: Discord attachment JSON (object or array)

### Show typing indicator in a channel

Use `credential_kind = connection` with:

- `connection`: selected Discord bot-token connection
- `operation`: `send_typing`
- `channel_id`: `{{ input.message.channel_id }}` for object-shaped input, `{{ input.0.message.channel_id }}` for array-shaped input, or another channel snowflake

### Send to a named Discord channel

Do not put a channel name in `channel_id`. Discord API sends require the numeric channel ID.

1. Use `list_connections` with `provider_name: "discord_bot"` to find a bot-token connection.
2. Run `Discord Action` with `credential_kind = connection`, that bot connection, and `operation = list_channels`.
3. Select the returned channel object by `name`.
4. Use its numeric `id` as `channel_id` for `send_message`, `reply`, `react`, `edit_message`, `delete_message`, `send_typing`, or `list_messages`.

### Follow up from a generic Webhook Trigger

If a generic webhook workflow receives a Discord interaction payload, you can still use this node.

- Initial HTTP response goes through `Webhook Response`
- Later Discord API calls use `Discord Action`
- For interaction follow-up fields, interpolate from the webhook payload, for example:
  - `interaction_id`: `{{ input.body.id }}`
  - `token`: `{{ input.body.token }}`

## Tips

- Use `connection` for general Discord HTTP APIs.
- Use `list_connections` with `provider_name: "discord_bot"` for bot-token connections.
- Use `list_connections` with `provider_name: "discord_webhook"` for channel webhook connections.
- Use `send_typing` to emit Discord's channel typing indicator before a delayed response.
- Use `webhook_connection` only for channel-scoped webhook sends.
- Use numeric Discord channel IDs, not channel names, in `channel_id` fields.
- `send_message`, `reply`, `edit_message`, `respond_to_interaction`, and `edit_original_response` all support `embeds` and `attachments` JSON.
- For unbounded text in `send_message`, `reply`, or webhook `send_message`, use `Split Text → Loop → Discord Action` with `content: {{ input }}`. Discord Action does not split automatically.
- `send_message`, `edit_message`, `respond_to_interaction`, `update_message`, `show_modal`, and `edit_original_response` support raw Discord `components` JSON arrays; attachments cannot be combined with raw components except on operations that do not support attachments.
- For gateway slash-command workflows, `Discord Bot` provides `input.interaction.*` values directly.
- For generic webhook workflows, `Webhook Response` handles the inbound HTTP response and `Discord Action` handles outbound Discord API calls.
