Channels

How to Connect OpenClaw to Discord

5 min read

Browse more in Channels.

All channels guides →

This guide walks you through connecting OpenClaw to Discord using the official Bot API so your agent can chat in DMs and guild channels. You will create a Discord application and bot, wire its token into OpenClaw, and complete the pairing flow.

By the end, your OpenClaw agent will respond to you directly in Discord and can be expanded into a full guild workspace.

Setup flow

Prerequisites

  • A Discord account with access to the Discord Developer Portal at https://discord.com/developers/applications.
  • A Discord server you can manage; if you do not have one, create it via "Create My Own > For me and my friends".
  • An OpenClaw gateway already installed and able to run the `openclaw gateway` command on your machine.
  • Permission to add a bot to your Discord server and to enable Message Content Intent and Server Members Intent for that bot.

Steps

  1. 1

    Create a Discord application and bot

    Start by creating a dedicated Discord application and bot so OpenClaw has its own identity in your server. This isolates your agent from any other bots and gives you a clean place to manage intents and permissions.

    text
    Go to the Discord Developer Portal and click **New Application**. Name it something like “OpenClaw”.Click **Bot** on the sidebar. Set the **Username** to whatever you call your OpenClaw agent.
  2. 2

    Enable privileged gateway intents

    OpenClaw needs specific gateway intents so your bot can see message content and resolve members correctly. If you skip this, the bot may connect but never see messages or resolve roles, which breaks routing and allowlists.

    text
    Still on the **Bot** page, scroll down to **Privileged Gateway Intents** and enable:
    *   **Message Content Intent** (required)
    *   **Server Members Intent** (recommended; required for role allowlists and name-to-ID matching)
    *   **Presence Intent** (optional; only needed for presence updates)
  3. 3

    Copy your bot token and invite the bot to your server

    You now generate the bot token that OpenClaw will use and create an OAuth2 invite URL with the right scopes and permissions. Treat the token like a password and avoid over-privileging the bot so you keep your server safe.

    text
    Scroll back up on the **Bot** page and click **Reset Token**.
    
    Despite the name, this generates your first token — nothing is being “reset.”
    
    Copy the token and save it somewhere. This is your **Bot Token** and you will need it shortly.
    
    Click **OAuth2** on the sidebar. You’ll generate an invite URL with the right permissions to add the bot to your server.Scroll down to **OAuth2 URL Generator** and enable:
    *   `bot`
    *   `applications.commands`
    
    A **Bot Permissions** section will appear below. Enable:
    *   View Channels
    *   Send Messages
    *   Read Message History
    *   Embed Links
    *   Attach Files
    *   Add Reactions (optional)
    
    Copy the generated URL at the bottom, paste it into your browser, select your server, and click **Continue** to connect. You should now see your bot in the Discord server.
  4. 4

    Enable Developer Mode and collect your IDs

    OpenClaw’s Discord config prefers numeric IDs for servers and users so audits and probes stay reliable. You enable Developer Mode once, then grab the Server ID and your own User ID that you will pass to OpenClaw during pairing.

    text
    Back in the Discord app, you need to enable Developer Mode so you can copy internal IDs.
    1.   Click **User Settings** (gear icon next to your avatar) → **Advanced** → toggle on **Developer Mode**
    2.   Right-click your **server icon** in the sidebar → **Copy Server ID**
    3.   Right-click your **own avatar** → **Copy User ID**
    
    Save your **Server ID** and **User ID** alongside your Bot Token — you’ll send all three to OpenClaw in the next step.
  5. 5

    Allow DMs from server members so pairing works

    Discord blocks DMs from server members if you disable them, which also blocks your bot from DMing you the pairing code. Turn this on at least for the pairing flow; you can lock it down later if you only use guild channels.

    text
    For pairing to work, Discord needs to allow your bot to DM you. Right-click your **server icon** → **Privacy Settings** → toggle on **Direct Messages**.This lets server members (including bots) send you DMs. Keep this enabled if you want to use Discord DMs with OpenClaw. If you only plan to use guild channels, you can disable DMs after pairing.
  6. 6

    Set your Discord bot token in OpenClaw and start the gateway

    Now you wire the Discord bot token into OpenClaw config using an environment-backed SecretRef and enable the Discord channel. Run the gateway after setting the token so it connects to Discord with the new credentials.

    bash
    export DISCORD_BOT_TOKEN="YOUR_BOT_TOKEN"
    openclaw config set channels.discord.token --ref-provider default --ref-source env --ref-id DISCORD_BOT_TOKEN --dry-run
    openclaw config set channels.discord.token --ref-provider default --ref-source env --ref-id DISCORD_BOT_TOKEN
    openclaw config set channels.discord.enabled true --strict-json
    openclaw gateway
  7. 7

    Configure OpenClaw for Discord and pair your account

    With the gateway running, you complete the pairing flow so OpenClaw knows which Discord user and server to associate with your agent. You can either drive this via chat or by editing file-based config if you prefer explicit JSON.

    text
    {
      channels: {
        discord: {
          enabled: true,
          token: {
            source: "env",
            provider: "default",
            id: "DISCORD_BOT_TOKEN",
          },
        },
      },
    }
    
    DISCORD_BOT_TOKEN=...
  8. 8

    Approve the first DM pairing from Discord

    Finally you link your Discord DM with your existing OpenClaw agent identity using a one-time pairing code. This prevents random Discord users from binding to your agent and gives you a clear approval step.

    bash
    openclaw pairing list discord
    openclaw pairing approve discord <CODE>
  9. 9

    Optionally allow your Discord guild channels to talk to the agent

    Once DMs work, you can turn your Discord server into a workspace where each channel has its own session. Start with an allowlist so the bot only responds in the guilds and channels you explicitly approve.

    text
    {
      channels: {
        discord: {
          groupPolicy: "allowlist",
          guilds: {
            YOUR_SERVER_ID: {
              requireMention: true,
              users: ["YOUR_USER_ID"],
            },
          },
        },
      },
    }

Configuration

OptionDescriptionExample
DISCORD_BOT_TOKENDiscord bot token used by OpenClaw to authenticate to the Discord gateway for the default account.DISCORD_BOT_TOKEN=sk-discord-bot-token-123
channels.discord.tokenSecretRef configuration for where OpenClaw should read the Discord bot token from.{ channels: { discord: { token: { source: "env", provider: "default", id: "DISCORD_BOT_TOKEN", }, }, }, }
channels.discord.enabledEnables or disables the Discord channel adapter in the OpenClaw gateway.true
channels.discord.groupPolicyControls how guild messages are handled, including whether servers must be allowlisted before the agent responds.allowlist
channels.discord.guildsPer-guild configuration for allowlists, mention requirements, users, roles, and channel-level overrides.{ channels: { discord: { guilds: { "123456789012345678": { requireMention: true, users: ["987654321098765432"], }, }, }, }, }
channels.discord.dmPolicyControls who can DM the bot and whether pairing is required for new users.pairing
channels.discord.dm.enabledToggles whether Discord DMs are handled at all by OpenClaw.true

Troubleshooting

Bot is online but never sees or responds to guild messages

This usually happens when the required Discord intents are disabled, so the gateway connects but receives no message events. In the Discord Developer Portal, enable Message Content Intent and Server Members Intent for your bot, then restart the OpenClaw gateway so it reconnects with the new intents.

Guild messages are blocked unexpectedly even though the bot is in the server

OpenClaw defaults to an allowlist-style group policy, so the bot ignores guild messages that are not explicitly allowed. guilds` allowlist, any `channels` map under that guild, and `requireMention` plus mention patterns to ensure the channel and sender are permitted.

Bot does not respond in DMs or pairing never completes

DM handling can be disabled in config or blocked by DM policy. dmPolicy` is not set to "disabled", and that you have approved the pending pairing when running in `pairing` mode.

Long-running Discord handlers time out or produce duplicate replies

`, increase the listener and worker timeouts for the Discord account. runTimeoutMs` only as a separate safety valve for queued turns.

bash
{
  channels: {
    discord: {
      accounts: {
        default: {
          eventQueue: {
            listenerTimeout: 120000,
          },
          inboundWorker: {
            runTimeoutMs: 1800000,
          },
        },
      },
    },
  },
}

General Discord channel issues and permission mismatches

When things look wired correctly but messages still fail, run the built-in diagnostics to probe channel status and inspect logs. `channels status --probe` works best with numeric channel IDs, so prefer those over slugs when you want accurate permission checks.

bash
openclaw doctor
openclaw channels status --probe
openclaw logs --follow

Frequently asked questions

Powered by Mem0

Add persistent memory to OpenClaw

Official Mem0 plugin for OpenClaw keeps context across chats and tools. Smaller prompts, lower cost, better continuity for your agents.

More in Channels