In this one we’re connecting OpenClaw to Discord — pairing the bot to a server and then locking it down so it only responds in the channels you choose.
If you’re new to OpenClaw, I have a previous post that covers the full installation and initial setup. This post focuses specifically on the Discord channel configuration.
📺 Prefer to watch? Full walkthrough on YouTube
What We’re Covering
- Spinning up a fresh server and installing OpenClaw via Ansible
- Creating a Discord bot and getting it configured in the Developer Portal
- Running
openclaw onboardand wiring up the Discord channel - Pairing the bot and enabling guild (server) access
- Restricting the OpenClaw Discord bot to specific channels using
openclaw.json
Step 1: Provision the Server
I’m spinning up a VM on Hetzner using a Pulumi project. It creates the VM and an SSH key — that’s it. A Makefile keeps the commands short.
make up # runs pulumi up
make ssh # shells into the server
Once you’re in, run openclaw to confirm it’s not there yet — we’ll install it next.
Step 2: Install OpenClaw with Ansible
Instead of installing manually, I’m using Ansible to configure the server. Ansible runs playbooks — an ordered sequence of commands — so the whole setup is repeatable.
make provision # runs the ansible playbook
The playbook installs everything needed for today’s demo. Once it’s done, SSH back in and run openclaw again to confirm it’s installed.
Step 3: Create Your Discord Bot
Head to the Discord Developer Portal and create a new application.
- Click New Application and name it
- Go to the Bot page and initialise the bot
- Click Reset Token — copy it and save it somewhere temporary on your machine
- Scroll down and enable both Server Members Intent and Message Content Intent
Keep the token somewhere safe until pairing is done. You can always reset it and reconnect if needed — but don’t skip saving it now.
Step 4: Run OpenClaw Onboard
Back on the server, run the onboarding wizard:
openclaw onboard
I’ll move through most of this quickly — if you want the slower walkthrough, check the previous post. Today we’re focused on Discord. Here’s what to select:
- Quickstart
- Model: MiniMax 2.7 Global
- Token: paste your MiniMax API key
- Channel: Discord
When it asks for the Discord bot token, I prefer using an environment variable instead of putting the token directly in the config file. Enter DISCORD_BOT_TOKEN as the value here.
Step 5: Configure the Allowlist
When the wizard asks for the access policy, pick allowlist.
What’s an Allowlist?
By default, OpenClaw locks down your Discord server — the agent won’t respond to just anyone. With an allowlist, you’re explicitly telling it: “these are the only servers, channels, or users my agent is allowed to talk to.” Everything else is ignored.
It’s the safer default. Even if your bot token leaks, random servers can’t just add your bot and start using it.
For the channel allowlist inside the wizard, skip it for now — we’ll configure that manually in openclaw.json in a later step. Skip the web search, skills, and hooks options too.
Step 6: Set the Environment Variable and Restart
Since we’re using an environment variable for the Discord token, we need to set it via systemctl so it persists across restarts:
sudo systemctl edit openclaw
Add the following under the [Service] block:
[Service]
Environment="DISCORD_BOT_TOKEN=your_token_here"
Then restart the gateway and check the status:
openclaw gateway restart
openclaw gateway status
Step 7: Add the Bot to Your Discord Server
Go back to the Discord Developer Portal and navigate to OAuth2 → URL Generator.
Enable the bot and applications.commands scopes, then set the following bot permissions:
- View Channels
- Send Messages
- Read Message History
Copy the generated URL, paste it into your browser, and select your server to add the bot.
Step 8: Pair via Direct Message
Pairing happens over DM. Before you disable DM access later, pair first.
Open a DM with your bot in Discord and send it a message to trigger the pairing prompt. It’ll give you a command to run on the server:
openclaw pairing approve discord <CODE>
Run that, and the bot is paired.
Step 9: Enable Guild (Server) Access in openclaw.json
After pairing, test the bot in one of your server’s channels. If it’s not responding, that’s expected — the guild isn’t configured yet.
Open openclaw.json and add the guilds configuration under the discord channel object. You’ll need your Server ID (right-click your server icon in Discord → Copy Server ID with Developer Mode on).
{
"channels": {
"discord": {
"enabled": true,
"token": {
"source": "env",
"provider": "default",
"id": "DISCORD_BOT_TOKEN"
},
"groupPolicy": "allowlist",
"guilds": {
"YOUR_SERVER_ID": {
"requireMention": false,
"users": ["YOUR_USER_ID"]
}
}
}
}
}
requireMention — when true, the bot only responds when @mentioned. Set it to false for a private server where it’s just you.
users — an array of Discord user IDs that are allowed to interact with the agent.
Restart the gateway after saving:
openclaw gateway restart
Test again — the bot should now respond in your channels.
Step 10: Restrict the Bot to Specific Channels
Right now the bot responds everywhere in the server. Let’s lock it down.
Create a new channel in Discord called #ai-assistant. Verify the bot responds there first, then go back to openclaw.json and add the channels object inside your guild config.
You’ll need the channel IDs — right-click each channel in Discord → Copy Channel ID.
{
"channels": {
"discord": {
"groupPolicy": "allowlist",
"guilds": {
"YOUR_SERVER_ID": {
"requireMention": false,
"users": ["YOUR_USER_ID"],
"channels": {
"GENERAL_CHANNEL_ID": { "allow": false },
"AI_ASSISTANT_CHANNEL_ID": { "allow": true }
}
}
}
}
}
}
Restart the gateway, then test both channels:
#ai-assistant→ responds ✅#general→ ignored ✅
That’s channel-level access control for your OpenClaw Discord bot.
Quick Reference: openclaw.json Discord Config
| Key | What it does |
|---|---|
groupPolicy | Set to allowlist to whitelist specific servers |
guilds | Map of server IDs and their config |
requireMention | Bot only responds when @mentioned |
users | Array of Discord user IDs allowed to interact |
channels | Per-channel allow/deny rules |
allow: true/false | Enable or disable the bot in a specific channel |
Bonus: Browser-Rendered Pages
I tried getting the bot to scrape a JavaScript-rendered page via DM — it doesn’t work out of the box. Pages that need a browser to load (React, Next.js, etc.) can’t be fetched with a plain HTTP request. If that’s something you’d find useful, drop a comment and I’ll cover it in a follow-up.
What’s Next
We’ve got OpenClaw running on Discord, paired, and restricted to specific channels. Next up: wiring in custom skills so the agent can actually do something useful inside those channels.
Questions? Drop them in the comments.