> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nerves-hub.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Discord

> Post NervesHub device, error and deployment workflow notifications to a Discord channel through a channel webhook.

Your organization can post its device notifications to Discord channels. Each channel gets them through a webhook that you make in that channel's settings. NervesHub only calls out to Discord, so this also works from an instance that Discord cannot reach.

## Requirements

* NervesHub 2.5.0 or later.
* `SECRETS_ENCRYPTION_KEY` set on the instance. NervesHub encrypts each channel's webhook URL with it, and saving a channel fails without it. See [Feature prerequisites](https://docs.nerves-hub.org/hosting/feature-prerequisites.md#secrets-encryption-key).
* The built-in **Manage** or **Admin** role, or a custom role with the Teams and Discord channel permissions. See [Roles](https://docs.nerves-hub.org/access/roles.md).
* The **Manage Webhooks** permission in the Discord channel.

## Add a channel

**1. Make a webhook in Discord**

In Discord, open the channel's settings and choose **Integrations**, then **Webhooks**. Choose **New Webhook**, then **Copy Webhook URL**.

**2. Add the channel in NervesHub**

Open your organization and select the **Integrations** tab. Click **Add integration**, then **Discord channel**. While the organization has no integrations, click **Add Discord channel** instead.

**3. Fill in the form**

Paste the URL. Enter a **Name** for the channel. Choose the products and events, then click **Add channel**.

**4. Check that it works**

Open the channel's row menu and choose **Send test message**. NervesHub posts a message to the channel straight away, saying what the channel will get.

Discord does not tell NervesHub a channel's name, so the name is whatever you type.

The URL is all it takes to post to the channel. NervesHub stores it encrypted and never shows it again. When you edit a channel, leave the URL empty to keep the current one, or paste a new one to replace it.

Only Discord's own webhook URLs are accepted: `https://discord.com/api/webhooks/…`, or the same path on `discordapp.com`, `canary.discord.com` or `ptb.discord.com`.

Every member of the organization sees each channel's name, events, products and state. An organization can have up to 20 Discord channels.

## What is posted

| Event | Posted when |
| - | - |
| Health status changed | A device's [health status](https://docs.nerves-hub.org/management/health-monitoring.md) moves, such as from healthy to warning. |
| Update failed | A device's update fails, stops reporting progress, or ends with the device back on its old firmware. |
| Update succeeded | A device finishes updating. |
| New error | A device reports an error not seen before in its product. |
| Error reopened | An error that was marked resolved happens again. |
| Workflow step started | A [deployment group](https://docs.nerves-hub.org/setup/deployments.md)'s [workflow](https://docs.nerves-hub.org/concepts/deployment-workflows.md) begins a step, or begins it again after somebody retries it. |
| Workflow waiting for approval | A workflow reaches a step that holds the rollout until somebody approves it. |
| Workflow step completed | Every device a step covers is on the release's firmware, or somebody approved an approval step. |
| Workflow step failed | Too many of a step's devices fail to update, and the rollout stops there. |
| Workflow step skipped | Somebody skips a step. |
| Product notifications | NervesHub adds something to a product's [Notifications](https://docs.nerves-hub.org/management/notifications.md) page. |

These events have the same prerequisites as the matching [webhook events](https://docs.nerves-hub.org/outbound/webhooks.md#events).

NervesHub holds events for 15 seconds, then posts one message per kind of event. A single event gets an embed of its own, titled with what happened and linked to its page in NervesHub. A burst gets a count and the first ten devices, each linked. Messages are posted under the instance's name (`FRIENDLY_PLATFORM_NAME`).

Anything a device sent is escaped, so Discord shows its markdown instead of following it. Every message is posted with mentions turned off, so nothing in it can ping `@everyone` or anybody else.

## Limits

A channel webhook only posts. There are no buttons that act, as there are in [Slack](https://docs.nerves-hub.org/outbound/slack.md). Approve a waiting workflow on the deployment group's page, which the message links to.

## When posting fails

* If Discord refuses the webhook, because it was deleted or its URL no longer works, NervesHub turns the channel off. Each product it was getting events for gets a product notification saying why. Make a new webhook, edit the channel and paste the new URL.
* If Discord asks NervesHub to slow down, NervesHub waits as long as Discord says.
* Any other failure is retried after 10 seconds, 1 minute and 5 minutes.
* Events held for more than an hour are dropped.

## Related pages

* [Slack](https://docs.nerves-hub.org/outbound/slack.md)
* [Microsoft Teams](https://docs.nerves-hub.org/outbound/teams.md)
* [Webhooks](https://docs.nerves-hub.org/outbound/webhooks.md)
* [Product notifications](https://docs.nerves-hub.org/management/notifications.md)
* [Secrets encryption key prerequisite](https://docs.nerves-hub.org/hosting/feature-prerequisites.md#secrets-encryption-key)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.