﻿The Discord notifier posts color-coded embeds to a channel through a Discord
[channel webhook][dw]. No bot to host: the webhook URL is all it needs.

[dw]: https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks

```toml title="runwisp.toml"
[notifiers.discord-ops]
type        = "discord"
webhook_url = "${DISCORD_OPS_URL}"
```

## Fields

| Key             | Required | What it does                                                                                            |
| --------------- | -------- | ------------------------------------------------------------------------------------------------------- |
| `webhook_url`   | yes      | The webhook URL. Keep it out of the file; see [Storing the secret](/notifications/#storing-the-secret). |
| `template_path` | no       | A Go template file that replaces the built-in message.                                                  |

## Creating the webhook

1. In your server, open **Server Settings → Integrations → Webhooks** and click
   **New Webhook**.
2. Pick the channel (for example `#ops-alerts`).
3. Set the name and avatar. Messages are posted under them.
4. Click **Copy Webhook URL**. It looks like
   `https://discord.com/api/webhooks/1234567890/XXXXXXXXXXXXXXXXXXXX`.

Anyone with the URL can post to your channel, so treat it as a secret. A webhook
belongs to one channel; for a second channel, create a second webhook and a
second `[notifiers.*]` block. Discord notifiers don't accept a
`discord-ops:<target>` override.

## What a message looks like

Each event is one embed. The color strip shows the outcome:

| Color   | When                                 |
| ------- | ------------------------------------ |
| Red     | failures, timeouts, crashes          |
| Green   | successes                            |
| Yellow  | warnings, like low disk space        |
| Blurple | everything else, like a run starting |

```
❌ backup-postgres failed

Exited with code 1 after 0.3s.
Triggered via the REST API · 14 May, 17:11.

    Error: connection refused
    dial tcp 127.0.0.1:5432: connect:
    connection refused

from runwisp · bright-falcon
```

- The title links to the run when
  the [Web UI address](/configuration/daemon/#external_url) is known.
- The last lines of output appear for failures and timeouts, when there is a
  log.
- Mentions are turned off, so a task that prints `@everyone` can't ping your
  whole server.

## Changing the message

Point `template_path` at your own Go template. Start from the built-in
[`discord.tmpl.json`](https://github.com/runwisp/runwisp/blob/main/apps/runwisp/internal/notify/render/defaults/discord.tmpl.json),
which has the embed layout and the color table. It gets the whole event and the
same helpers as the [Slack template](/notifications/providers/slack/#changing-the-message).

## What's rejected

- A missing or empty `webhook_url`, or one that isn't `http://` or `https://`.
