---
related_nodes: ["discord_action"]
---

# Discord Bot

Starts a workflow from Discord gateway events received through a `discord_bot` connection.

Slash commands arrive here over the Discord Gateway when the Discord application does not have an Interaction Endpoint URL configured. Discord sends interactions either to the gateway or to the configured HTTP endpoint, not both.

## When to Use

- React to Discord messages through a stateful bot
- React when a user adds an emoji reaction to one of the bot's messages
- Trigger slash-command workflows through the Discord gateway
- Feed gateway interaction data into `Discord Action`
- Avoid generic webhook interaction workflows when a gateway bot is enough

## Configuration

### connection

The `discord_bot` connection whose gateway events start the workflow. Add one under **Settings → Connections**; agents discover existing ones with `list_connections` and `provider_name: "discord_bot"`, then pass the returned connection id.

The gateway intents come from the connection's `intents` property, set by editing the Discord Bot connection under **Settings → Connections**. Every trigger on the same connection shares one gateway session with those intents.

### event_kind

Choose which gateway event should start the workflow:

- `message`
- `slash_command`
- `reaction_add`

### command_name

Optional slash-command filter.

- Ignored for `message`
- Ignored for `reaction_add`
- When set for `slash_command`, only matching slash commands trigger the workflow

### when_mentioned, when_replied_to, when_direct_message

Optional checkboxes for `message`, all off by default. Ignored for `slash_command` and `reaction_add`.

- `when_mentioned` (**Bot mentioned**): the message mentions the connection's bot user.
- `when_replied_to` (**Replies to bot**): the message is a reply to one of the bot's messages, whether or not the reply pings the bot. When Discord does not include the original message, for example because it was deleted, the reply's author is unknown and it does not count.
- `when_direct_message` (**Direct message with bot**): the message is in a direct message with the bot, mentioned or not.

With all three off, every message starts the workflow. With any on, a message starts it only when it meets at least one enabled condition. Unmatched messages start no run at all.

The conditions do not look at who sent the message, so the bot's own messages count too. With `when_direct_message` on, a workflow that answers in the DM is started again by its own answer; end that branch when `{{ output.message.author.bot }}` is true.

### initial_presence

Optional. Off by default. When on, sets the online status and activity the bot shows once this trigger installs:

- `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 plain text of at most 128 characters; templates are not rendered because the trigger installs with no input.

Presence belongs to the bot's gateway session, which runs only while a Discord listener on the connection keeps it open. It is kept across reconnects, cleared when the last listener goes away, and lost when Verdalia restarts. When several triggers on one connection set an initial presence, the most recently installed one wins, and saving a workflow reinstalls its trigger. To change presence from a workflow, use `Discord Action` with `set_presence`.

## Output Contract

The node emits one `output` object:

```json
{
  "event": "message",
  "message": {
    "id": "123",
    "channel_id": "456",
    "content": "hello",
    "is_mentioned": true
  },
  "interaction": null,
  "reaction": null
}
```

or:

```json
{
  "event": "slash_command",
  "message": null,
  "interaction": {
    "id": "123",
    "token": "interaction_token",
    "command": { "name": "ping", "options": [] }
  },
  "reaction": null
}
```

or:

```json
{
  "event": "reaction_add",
  "message": null,
  "interaction": null,
  "reaction": {
    "user_id": "789",
    "channel_id": "456",
    "message_id": "123",
    "guild_id": "321",
    "message_author_id": "bot-user-id",
    "emoji": { "id": null, "name": "👍", "animated": false },
    "burst": false
  }
}
```

## Common Paths

### Message workflow

Use:

- `{{ output.message.channel_id }}`
- `{{ output.message.id }}`
- `{{ output.message.content }}`
- `{{ output.message.is_mentioned }}`
- `{{ output.message.attachments }}`

### Video summary workflow

For a Discord video attachment, fetch the attachment URL as binary, extract audio, then transcribe:

```text
[Discord Bot event_kind=message]
    ↓ attachment url
[HTTP Request]
    Response: auto
    ↓ { body: binary }
[Extract Audio]
    ↓ audio/ogg binary
[Transcribe Audio]
    ↓ text
[AI Agent]
    ↓ summary
[Discord Action]
```

Add `Upload Media` only when you want durable storage for the source video or extracted audio.

### Slash-command workflow

Use:

- `{{ output.interaction.id }}`
- `{{ output.interaction.token }}`
- `{{ output.interaction.command.name }}`
- `{{ output.interaction.command.options }}`

### Reaction workflow

Use:

- `{{ output.reaction.user_id }}`
- `{{ output.reaction.channel_id }}`
- `{{ output.reaction.message_id }}`
- `{{ output.reaction.emoji.name }}`
- `{{ output.reaction.emoji.id }}`

## Example

```text
[Discord Bot event_kind=slash_command]
    ↓
[Discord Action credential_kind=connection op=respond_to_interaction]
```

Typical field mapping:

- `interaction_id`: `{{ output.interaction.id }}`
- `token`: `{{ output.interaction.token }}`

## Tips

- Use `event_kind` to keep one workflow focused on one Discord event type.
- Each matching event starts one run, in the order Discord sent them, including events that arrive while earlier runs are still going.
- Use `command_name` when you want one workflow per slash command.
- The connection's bot token must belong to the same Discord application that owns the slash command.
- Manage slash commands from the Discord Bot connection's **Commands** action under **Settings → Connections**, then sync them to Discord.
- The gateway connection always includes `GUILDS`, which Discord uses for application command events.
- `reaction_add` only emits reactions from other users to messages authored by the connection's bot; the bot's own reactions are ignored.
- Enable `GUILD_MESSAGE_REACTIONS` for guild reactions and `DIRECT_MESSAGE_REACTIONS` for DM reactions in the connection's `intents`. A connection with no intents uses `GUILDS`, `GUILD_MESSAGES`, `GUILD_MESSAGE_REACTIONS`, `DIRECT_MESSAGES`, `DIRECT_MESSAGE_REACTIONS`, and `MESSAGE_CONTENT`.
- Message content needs `MESSAGE_CONTENT` in the connection's intents and the Message Content privileged intent enabled for the application in Discord's developer portal.
- `message.is_mentioned` is true only when the connection's bot user appears in the message mentions list.
- Use `when_mentioned`, `when_replied_to`, and `when_direct_message` instead of an `If` or `Js` node to ignore messages not addressed to the bot.
- `Discord Action` can use the same `discord_bot` connection for outbound HTTP calls.
