OpenClaw works beautifully in a chat window, but if your team already lives in Discord, opening a second app just to talk to your agent gets old fast. Discord is also the most flexible surface OpenClaw supports: one bot can answer your DMs, sit in every channel on your server, and keep a separate conversation for each room.
Connecting OpenClaw to Discord takes about 15 minutes. You create a bot in the Discord Developer Portal, drop its token into your OpenClaw config, pair your own Discord account, and then allowlist your server. This guide walks the whole ladder, from a first direct message to routing different channels to different agents.
What You Need Before You Start
You do not need to be a developer for this, but you do need four things in place:
- OpenClaw installed and running on a machine you control. If you have never set it up, start with our 30 minute OpenClaw setup guide and come back here.
- A Discord account and a server you own. A private server with just you and your bot is the recommended starting point.
- Terminal access to the machine running the gateway, so you can edit config and restart it.
- About 15 minutes, most of which is clicking through the Discord Developer Portal.
One pleasant surprise: if you already run OpenClaw on another channel, Discord is simpler to add than most. The bot token goes in config, and everything else is a few clicks. If you are deciding between platforms first, our guide to the difference between OpenClaw on Telegram, WhatsApp, and Discord is worth a read.
Level 1: Create the Bot in the Discord Developer Portal
Everything starts in the Discord Developer Portal. Sign in with your normal Discord account.
Create the application
Click New Application, give it a name (I use the agent’s name, so “OpenClaw” or “Jarvis”), and accept the terms. Then open the Bot tab in the left sidebar and set the username to whatever you want to see in Discord.
Enable the privileged intents
Still on the Bot page, scroll to Privileged Gateway Intents and turn on:
- Message Content Intent. This one is required. Without it, your bot connects and looks healthy, but it never sees the text of your messages.
- Server Members Intent. Recommended. You need it for role allowlists, name to ID matching, and channel audience access groups.
- Presence Intent. Optional, only if you want presence updates.
Copy the bot token
Click Reset Token and copy the value that appears. Despite the scary name, this is simply generating your first token, nothing is being reset. Treat it like a password, because anyone with it controls your bot.
Invite the bot to your server
Open OAuth2 in the sidebar and use the OAuth2 URL Generator. Under scopes, tick bot and applications.commands. Under Bot Permissions, tick at least:
- View Channels
- Send Messages
- Read Message History
- Embed Links
- Attach Files
- Add Reactions (optional)
If your agent will post inside threads, also tick Send Messages in Threads. Copy the generated URL, open it in a browser, pick your server, and click Continue. The bot now appears in your server offline.
Grab your Server ID and User ID
Back in the Discord app, open User Settings (the gear) then Developer and toggle on Developer Mode. Now right click your server icon and choose Copy Server ID, then right click your own avatar and choose Copy User ID. Keep both IDs with the bot token, you need all three in the next step.
Finally, right click your server icon and open Privacy Settings. Turn on Direct Messages so server members can DM you. Pairing relies on the bot being able to DM you, so if you skip this, the pairing code never arrives.
Level 2: Hand the Token to OpenClaw
Keep the token out of your config file and out of chat. Set it as an environment variable on the machine running OpenClaw, then point the config at the variable.
Create a small patch file and apply it:
The important line is the token source. OpenClaw reads DISCORD_BOT_TOKEN from the environment at startup, so the secret never sits in plain text in your config. Run the dry run first to see the merged result, then apply it for real.
If OpenClaw already runs as a background service, restart it so the new channel loads. If you installed it as a managed service, either run the install command from a shell where the variable is exported, or store the variable in ~/.openclaw/.env so the service can resolve it after a restart.
Level 3: Pair Your Discord Account
This is the step most people miss. OpenClaw connects to Discord in pairing mode by default, which means your DMs are locked down until you prove you are the owner.
Once the gateway is running, open Discord and send your bot a direct message. Anything works. It replies with a short pairing code.
Approve it either by telling your agent on another channel (“approve this Discord pairing code: XXXX”), or straight from the CLI:
Pairing codes expire after one hour, so approve it while it is fresh. After approval, your DM with the bot is live and you can just talk to your agent there.

Level 4: Turn Your Server Into an Agent Workspace
DMs are nice, but the real upgrade is your whole server. Once you allowlist your guild, the agent can answer in channels instead of only in private messages. Here is what happens under the hood:
Add your server to the guild allowlist. The config looks like this, and it is already included in the patch file above:
groupPolicy: "allowlist"keeps unknown servers out.guilds.YOUR_SERVER_ID.requireMention: truemeans the bot only answers when you @mention it.users: ["YOUR_USER_ID"]restricts who can trigger it, so nobody else can use your agent.
On a private server that is just you and your bot, bounce requireMention to false and the agent replies to every message in the channel, which feels far more natural.
How sessions work in channels
Each Discord channel is its own isolated session. That means #coding, #research, and #home each keep a separate conversation with their own context, and none of them bleed into each other. It is a genuinely useful way to run several workflows side by side without cross talk.
One gotcha worth knowing up front: long term memory (MEMORY.md) only auto-loads in DM sessions, not in guild channels. Put the stable instructions you always want present into AGENTS.md or USER.md, since those are injected into every session, and let the agent pull deeper context with its memory tools when needed.
Advanced: Route Channels to Different Agents
Once the basics work, the interesting part begins. One Discord bot can serve several different OpenClaw agents, each bound to its own channel. So your #coding channel can talk to a coding agent while #research talks to a research agent, all through the same bot.
You do this with bindings. Each binding matches a channel and points it at an agent ID:
- Match on
channel: "discord", theguildId, and apeerobject withkind: "channel"and the channel ID. - Point
agentIdat the agent you want in that room.
Two things trip people up here. First, use the guildId plus peer format. A single combined string like "guildId#channelId" does not match, and neither does a bare channelId field. Second, binding changes usually need a full gateway restart. A hot reload is not always enough, so restart properly before you assume it is broken.
Common Mistakes That Break a Discord Setup
- Skipping Message Content Intent. The bot connects, looks online, and answers nothing. This is the number one cause of “my bot is dead” reports.
- Extra spaces or quotes in the token. Copy the token raw. A stray newline in an env file will fail authentication with a vague error.
- DMs disabled on your server. If Direct Messages are off in Privacy Settings, the pairing code is never delivered and you wait forever.
- Mixing up Server ID and User ID. They look almost identical. Paste the wrong one and the allowlist silently excludes you.
- Forgetting that channels are mention gated. By default the bot only replies when @mentioned in a guild channel. If nobody mentions it, the channel looks broken even though it is working as designed.
- Expecting one shared memory across channels. Each channel is an isolated session. If you want shared behavior, put it in AGENTS.md.
Frequently Asked Questions
For direct messages, no. You can pair with the bot and chat privately without owning a server. But channels only work on a server where the bot is present, and the safest setup is a private server that only you and the bot can see.
Guild messages are mention gated by default. The bot only responds when you @mention it inside a channel. Either mention it, or set requireMention to false for that guild if you want it to answer every message.
No. The bot token is the secret credential that lets OpenClaw control the bot, and it must never be shared or pasted into chat. The application ID is a public identifier. Treat the token like a password and store it as an environment variable.
Yes. A single bot can route different Discord channels to different OpenClaw agents using bindings. Each binding matches a guild and channel, then points that channel at a specific agent id, so several agents can share one bot.
MEMORY.md only auto-loads in direct message sessions, not in guild channels. For always present context, put stable rules in AGENTS.md or USER.md, which are injected into every session, and let the agent use its memory tools for deeper lookups.
Check out our comparison of the best AI agent platforms, including OpenClaw vs CrewAI vs AutoGen, to see which one fits how you actually work.
See Our ComparisonFinal Thoughts
Getting OpenClaw into Discord is mostly about three small things done right: the Message Content Intent, a token stored safely, and one pairing approval so your DMs stop being locked. Get those three sorted and you have an agent that lives where your conversations already happen, answering DMs and serving every channel with its own memory.
Do the four levels in order rather than trying to jump to multi agent routing on day one. A stable single bot in one channel teaches you the failure modes far faster than debugging five bindings at once. Once you have that, the rest is just a config line away.

