Before you start: You need a Discord account and a private Discord server. If you don't have one, create one: + → Create My Own → For me and my friends. Keep it private — this is your personal agent workspace, not a public community.
- Go to discord.com/developers/applications
- Click New Application
- Name it (e.g. "OpenClaw" or your agent's name) → click Create
- In the left sidebar, click Bot
- Set the Username to your agent's name
- Optionally upload a profile picture
Still on the Bot page, scroll down to Privileged Gateway Intents. This is where most installs go wrong — if Message Content Intent is not enabled, the bot connects but can't read any messages.
If you skip Message Content Intent: the bot will appear online in Discord but won't respond to any messages. This is the most common setup failure. You have to go back to the Developer Portal, enable the intent, and restart the gateway.
Scroll back to the top of the Bot page. Click Reset Token (despite the name, this generates your first token — it's not actually resetting anything).
Copy the token and save it somewhere safe. You'll use it in Step 6. This token is like a password — anyone with it can control your bot.
Never paste your bot token into a chat message — including to OpenClaw. You'll set it via the command line or config file only. Discord automatically invalidates tokens that appear in public messages.
In the left sidebar, click OAuth2 → scroll down to OAuth2 URL Generator.
Check these two scopes:
botapplications.commands
A Bot Permissions section appears below. Enable these:
Copy the generated URL at the bottom. Paste it into your browser, select your private server, click Continue → Authorize. The bot should now appear in your server's member list (offline until the gateway starts).
You need three IDs: your Server ID, your User ID, and optionally channel IDs. To copy them, Developer Mode must be on.
- User Settings (gear icon next to your avatar, bottom left) → Advanced → toggle on Developer Mode
- Right-click your server icon in the sidebar → Copy Server ID
- Right-click your own avatar anywhere in the server → Copy User ID
To copy a channel ID: right-click any channel name in the sidebar → Copy Channel ID. You'll need this for cron delivery and webhook delivery targets.
Set the token as an environment variable and configure OpenClaw to use it — never put the token in plaintext in config:
# Set the token as an env var on the machine running OpenClaw export DISCORD_BOT_TOKEN="YOUR_BOT_TOKEN_HERE" # Tell OpenClaw to read the token from env openclaw config set channels.discord.token --ref-provider default --ref-source env --ref-id DISCORD_BOT_TOKEN # Enable Discord openclaw config set channels.discord.enabled true --strict-json # Start the gateway (or restart if already running) openclaw gateway start
Alternatively, set it in config with an env reference (SOPS-compatible):
{
channels: {
discord: {
enabled: true,
token: {
source: "env",
provider: "default",
id: "DISCORD_BOT_TOKEN",
},
},
},
}
For pairing to work via DM, Discord must allow server bots to message you. In the Discord app:
- Right-click your server icon → Privacy Settings
- Toggle on Direct Messages
Once the gateway is running, DM your bot in Discord. It will respond with a pairing code. Approve it:
# List pending pairing requests openclaw pairing list discord # Approve the code (replace 1234 with the actual code) openclaw pairing approve discord 1234
Pairing codes expire after 1 hour. After approval, you can chat with your agent via Discord DM.
Guild workspace: per-channel sessions
DMs work in a single shared session. A guild workspace is more powerful: each Discord channel gets its own isolated agent session with its own context. You can have #coding, #home, #research, #finance — each with a distinct conversation history the agent treats separately.
1. Add your server to the guild allowlist
{
channels: {
discord: {
enabled: true,
token: { source: "env", provider: "default", id: "DISCORD_BOT_TOKEN" },
groupPolicy: "allowlist",
guilds: {
"YOUR_SERVER_ID": {
// Require @mention in channels (set false for fully private server)
requireMention: true,
// Only these users can interact via channels
users: ["YOUR_USER_ID"],
},
},
},
},
}
2. For a fully private server: disable @mention requirement
If it's just you and your bot, you don't need to @mention it every message:
{
channels: {
discord: {
guilds: {
"YOUR_SERVER_ID": {
requireMention: false, // responds to every message in allowed channels
users: ["YOUR_USER_ID"],
},
},
},
},
}
3. Set up your channel structure
Create channels in your Discord server for different contexts. The agent sees the channel name and each gets its own session:
#general— everyday assistant tasks#coding— programming help, the agent accumulates coding context here#research— web searches, article summaries#home— home automation, reminders#finance— budget tracking, financial questions
Memory in guild channels: MEMORY.md only auto-loads in DM sessions, not guild channels. For guild channel context, put stable facts in AGENTS.md or USER.md (loaded everywhere). Use memory_search or memory_get when you need long-term context inside a channel session.
Cron delivery to Discord channels
# Deliver a morning brief to a specific Discord channel openclaw cron add \ --name "Morning Brief" \ --cron "0 7 * * 1-5" \ --tz "America/New_York" \ --exact \ --session isolated \ --message "Morning brief: top priorities, calendar, anything urgent." \ --announce \ --channel discord \ --to "YOUR_CHANNEL_ID" \ --model openrouter/meta-llama/llama-3.3-70b-instruct:free
Get your channel ID: right-click any channel in the Discord sidebar (with Developer Mode on) → Copy Channel ID.
Troubleshooting
channels.discord.guilds in config with your Server ID. Also check that groupPolicy is set to "allowlist" and your User ID is in the users array.openclaw gateway status) and that DMs are allowed in your server Privacy Settings.