Connecting OpenClaw to Discord, step by step
Create the bot, enable the Message Content intent, invite it to your server, and hand OpenClaw the token. Plus the allowlist trap and how memory behaves in servers.
Connecting OpenClaw to Discord means creating a bot in the Discord Developer Portal, enabling the Message Content intent, inviting the bot to your server, and giving OpenClaw the bot token via config. DMs then work through OpenClaw’s normal pairing approval, and server channels answer when the bot is mentioned. No ports to open — the bot connects outward.
Create the bot (five minutes in the Developer Portal)
- 1. At
discord.com/developers/applications, create a new application and name it after your agent. In the Bot section, set the username your agent will appear as. - 2. Enable intents. Under Privileged Gateway Intents, turn on Message Content (needed to read normal server messages) and Server Members (recommended if you’ll use role-based allowlists). Presence is optional.
- 3. Get the token. Click Reset Token (that’s also how you get your first one) and copy it somewhere safe — it’s a credential, not a setting.
- 4. Invite the bot. In OAuth2, build an invite URL with the
botandapplications.commandsscopes plus View Channels, Send Messages, Read Message History, Embed Links, and Attach Files permissions, then open it and pick your server.
Tell OpenClaw about it
Put the token in the environment (never in chat, never inline in config) and enable the channel:
export DISCORD_BOT_TOKEN="YOUR_BOT_TOKEN"{
channels: {
discord: {
enabled: true,
token: { source: "env", provider: "default", id: "DISCORD_BOT_TOKEN" },
},
},
}Apply it and restart the gateway. DMs default to dmPolicy: "pairing" — the first time you DM your bot it replies with a pairing code, and you approve it (openclaw pairing approve discord <CODE>, or just tell your agent to). Codes expire after an hour, so approve promptly. That default is worth keeping: pairing is how your agent stays yours.
Server channels: mention-gated by design
In servers, OpenClaw answers where you’ve configured it — typically with requireMention: true, so the agent speaks when spoken to (@YourAgent or a reply to it). Each server channel gets its own isolated session, which is the right default for a bot that multiple people can see. Two behaviors surprise people:
- The allowlist trap. The moment you add one channel entry to a guild’s config, the channel map becomes an allowlist — every unlisted channel is denied, not left at defaults. Use the
"*"wildcard key if you want defaults preserved for the rest. - Memory works differently in servers. Your agent’s long-term memory file auto-loads only in DM sessions; guild channels don’t load it. The agent can still consult memory with its tools — it just won’t volunteer DM-context in public, which is arguably a feature.
Worth knowing before you rely on it
If your server has other bots, leave allowBots alone unless you want bot-to-bot conversations — OpenClaw ships a loop guard (a bot pair gets ~20 exchanges in a sliding window before suppression), but strict mention rules are the real protection. And if the Message Content intent isn’t available to you, the bot still works in DMs and wherever it’s explicitly mentioned. Setup-wise this channel is a sibling of the Telegram connect — outbound-only, token-based, no exposed ports — so if you’ve done one, the other will feel familiar.