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

# Discord

> Connect a Discord bot to a space for DMs and @mentions.

Connect a Discord bot to any Friday space so users can chat with it over DM or `@mentions`. Messages flow into the same conversation pipeline the web chat uses, and replies go back to Discord.

Unlike the other communicators, Discord doesn't need a public URL — your Friday instance connects out to Discord and holds the connection open.

## Prerequisites

* A Discord account that can create applications.
* A Discord server where you can invite the bot — if you don't have one, create a personal test server for free.
* Friday running. You don't need a public URL or tunnel for Discord.

## Setup

<Steps>
  <Step title="Create a Discord application">
    1. Open [discord.com/developers/applications](https://discord.com/developers/applications) and click **New Application**.
    2. Pick a name (e.g. *Friday Atlas*) and accept the developer ToS.
    3. On the **General Information** page, copy two values you'll need later:
       * **Application ID** — a long numeric string
       * **Public Key** — a 64-character hex string
  </Step>

  <Step title="Create the bot user and copy its token">
    1. In the left sidebar, click **Bot**. 2. Click **Reset Token** (or **Add
       Bot** if this is the first time). Discord shows the token **once** — copy it
       immediately.
  </Step>

  <Step title="Enable the Message Content Intent">
    Still on the **Bot** page, scroll to **Privileged Gateway Intents** and toggle **Message Content Intent** to **on**. Save changes.

    Without this toggle, every incoming message arrives with empty text — nothing will trigger the bot.
  </Step>

  <Step title="Connect Discord in Studio">
    1. In Studio, select your space from the sidebar and click **Info**.
    2. Find the **Communicators** card and click **Connect** next to **Discord**.
    3. Paste the **Bot Token**, **Application ID**, and **Public Key** into the form, then submit.

    Studio stores the credentials securely and connects to Discord. The status flips to **Connected** when the bot comes online.
  </Step>

  <Step title="Invite the bot to a server">
    Discord bots can only DM users once both sides share at least one server, and `@mentions` require a channel to mention in.

    1. In the Developer Portal, go to **OAuth2** → **URL Generator**.
    2. Under **Scopes**, check **`bot`** (do **not** check `applications.commands` — Friday doesn't use slash commands).
    3. Under **Bot Permissions**, check:
       * **Read Messages/View Channels**
       * **Send Messages**
       * **Read Message History**
    4. Copy the **Generated URL** at the bottom of the page.
    5. Open the URL in a browser, pick the server, and click **Authorize**.
  </Step>

  <Step title="Talk to your bot">
    1. In Discord, DM the bot (click its name in your server's member list → **Message**). Send "hello friday".
    2. Within a second or two, a new chat appears in Studio with a **DISCORD** badge.
    3. To `@mention` the bot in a channel, make sure the bot can read the channel and post `@<bot-name> ping`.

    <Info>
      Bot replies to `@mentions` appear in a Discord thread off the original message, not inline in the channel.
    </Info>
  </Step>
</Steps>

## Troubleshooting

<AccordionGroup>
  <Accordion title="Bot is online in Discord but silent on every message">
    The most common cause is **Message Content Intent disabled**. Toggle it on in the Developer Portal → **Bot** page and reconnect via Studio.
  </Accordion>

  <Accordion title="Bot disconnects with an auth error and doesn't come back">
    The bot token was rejected (revoked, expired, or mistyped). Regenerate the
    token in the Developer Portal and reconnect via Studio.
  </Accordion>

  <Accordion title="Connection never establishes at all">
    Usually a network block: outbound WebSocket to Discord is blocked by a corporate firewall, VPN, or egress policy. Test from the same host with `curl -v https://discord.com/api/v10/gateway`.
  </Accordion>
</AccordionGroup>

## Known limitations

* **Messaging only — no slash commands or button handlers.** Only DMs and `@mentions` are handled.
* **Message Content Intent is privileged.** For bots in **100+ servers**, Discord additionally requires account verification and an intent review.

## Configure via YAML

For CI or fully scripted setups, paste credentials directly into `workspace.yml` or the `.env` file in the Friday home directory (default `~/.friday/local/.env`). All three of `bot_token` / `public_key` / `application_id` must resolve.

<Tabs>
  <Tab title="Credentials inline">
    ```yaml workspace.yml theme={null}
    communicators:
      discord:
        kind: discord
        bot_token: MTIzNDU2Nzg5...
        public_key: abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890
        application_id: "1234567890123456789"
    ```
  </Tab>

  <Tab title="Credentials via env">
    ```bash # Friday home .env (default ~/.friday/local/.env) theme={null}
    DISCORD_BOT_TOKEN=MTIzNDU2Nzg5...
    DISCORD_PUBLIC_KEY=abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890
    DISCORD_APPLICATION_ID=1234567890123456789
    ```

    ```yaml workspace.yml theme={null}
    communicators:
      discord:
        kind: discord
    ```
  </Tab>
</Tabs>

Restart Friday so the new config is picked up.
