How to connect OpenClaw to Discord, step by step
By the serverserv team · 8 min read · Updated
OpenClaw connects to Discord as a bot, so your agent can answer you in DMs and in your server's channels. You create an application in the Discord Developer Portal, switch on one intent, invite the bot, and give OpenClaw the token. Setup takes about 15 minutes. This guide covers each step, how to limit the bot to the right server and channels, and the errors people hit most.
Before you start
- OpenClaw installed, with a model provider such as Anthropic, OpenAI, Google or OpenRouter.
- A machine that stays on. The bot only replies while the OpenClaw gateway runs, so most people use a small server. See OpenClaw VPS requirements.
- A Discord server where you can add bots (you need the Manage Server permission).
Step 1: Create the Discord application and bot
- Open the Discord Developer Portal and click New Application. Name it, for example "OpenClaw".
- Open Bot in the sidebar and set the bot's username.
- Click Reset Token and copy the token. On a new bot this simply creates the first token. Keep it private: anyone with it controls your bot.
Step 2: Turn on the intents
On the same Bot page, under Privileged Gateway Intents:
- Message Content Intent: required. Without it the bot cannot read normal messages in your server.
- Server Members Intent: recommended. It lets OpenClaw match people and roles for allowlists.
- Presence Intent: optional; only needed if you use presence updates.
Step 3: Invite the bot to your server
- Go to OAuth2, then OAuth2 URL Generator.
- Tick the scopes
botandapplications.commands. - Under bot permissions, tick View Channels, Send Messages, Read Message History, Embed Links and Attach Files. Add Send Messages in Threads if the agent will reply in threads, and Add Reactions if you like.
- Open the generated link, pick your server and click Continue.
Then turn on Developer Mode in Discord (User Settings, then Developer) so you can right-click to copy your server ID and your own user ID. You will need both to lock the bot down later. To DM the bot, allow direct messages from server members in the server's Privacy Settings; you can turn this off again after pairing.
Step 4: Add the token to OpenClaw
Keep the token out of chat and config files by setting it as an environment variable on the server:
export DISCORD_BOT_TOKEN="your-bot-token"
Create a small file, discord.patch.json5, that turns on Discord and points at that variable:
{
channels: {
discord: {
enabled: true,
token: { source: "env", provider: "default", id: "DISCORD_BOT_TOKEN" },
},
},
}
Check it, apply it and start the gateway:
openclaw config patch --file ./discord.patch.json5 --dry-run
openclaw config patch --file ./discord.patch.json5
openclaw gateway
If OpenClaw runs as a background service, install or restart the service from a shell where DISCORD_BOT_TOKEN is set, or put the variable in ~/.openclaw/.env so the service always sees it.
Step 5: Approve your first DM
Discord DMs use pairing by default, so nobody can use your agent until you approve them. Send your bot a direct message, then approve the request on the server:
openclaw pairing list discord
openclaw pairing approve discord <CODE>
Message the bot again and your agent replies. Check the connection any time with openclaw channels status --probe.
Limiting who and where
Your agent can act for you, so keep it to the people and places you choose:
| Setting | What it controls |
|---|---|
channels.discord.dmPolicy | DMs: pairing (default), allowlist, open or disabled |
channels.discord.allowFrom | Who may DM the agent when using an allowlist |
channels.discord.groupPolicy | Server channels: allowlist (the safe default), open or disabled |
channels.discord.guilds | Which servers are allowed, by server ID; a channels list inside a server limits it to those channels; users and roles limit who can trigger it |
requireMention | Set on a server or channel entry so the agent only answers when mentioned |
channels.discord.allowBots | Set to false or "mentions" to stop other bots triggering endless loops |
Use IDs rather than names. Name matching is off by default for good reason: names can be changed by anyone. Keep the server itself patched, as in our Linux VPS security guide.
Troubleshooting
- "Used disallowed intents", or the bot sees no server messages: turn on Message Content Intent (and Server Members Intent if you use roles), then restart the gateway.
- Messages in your server are ignored: with
groupPolicyonallowlist, your server ID must be listed underchannels.discord.guilds. If that server has achannelslist, only those channels work. Also check whetherrequireMentionis on. - DMs do nothing: the sender may be waiting for pairing approval, or DMs are disabled in
dmPolicy. - Gateway timeout warnings at startup: usually a slow or blocked connection to Discord. A server in a proper data centre with a stable connection avoids most of these.
- Still stuck: run
openclaw doctor, thenopenclaw logs --followwhile you send a message, and read the skip reason.
Using other chat apps too? See our guides for Telegram and WhatsApp. One agent can answer on all of them.
Questions
Is the OpenClaw Discord bot free?
Yes. Discord bots are free to create. You pay only for the server OpenClaw runs on and your AI model usage.
Why does my OpenClaw Discord bot not see messages?
Most often Message Content Intent is off in the Developer Portal, or your server is not listed under channels.discord.guilds while groupPolicy is allowlist. Turn on the intent, add your server ID and restart the gateway.
Can OpenClaw join Discord voice channels?
OpenClaw has Discord voice features, including joining voice channels and voice transcripts. They are covered in the OpenClaw docs under the Discord channel pages.
Do I need a server to run OpenClaw on Discord?
You need a machine that stays on, because the bot only answers while OpenClaw runs. A small VPS with 2 vCPU and 4 GB RAM keeps it online 24/7.
Can one OpenClaw agent use Discord, Telegram and WhatsApp?
Yes. OpenClaw supports several chat channels at once, so the same agent can answer on Discord, Telegram, WhatsApp and others.
Sources
Related
Connect OpenClaw to Telegram
Create a bot in BotFather, add the token and approve pairing.
7 min readRead →Connect OpenClaw to WhatsApp
Link your WhatsApp number and approve who can talk to your agent.
6 min readRead →Best OpenClaw Hosting 2026
Six OpenClaw hosting options compared on price and setup.
7 min readRead →Ready to deploy?
Pick a plan, choose a term and you are online in minutes.
See all plansTalk to salesNeed a custom server, bulk pricing or help moving from another host? Our team will build a quote for you.