Problem: Discord Needs a Smarter Bot
Your Discord server needs an AI assistant that remembers context, executes real tasks, and works with your entire team—not just another chatbot that forgets everything between messages.
You'll learn:
- Set up OpenClaw with Discord in under 20 minutes
- Configure multi-user access and permissions
- Enable proactive notifications and task automation
Time: 20 min | Level: Intermediate
Why OpenClaw Stands Out
OpenClaw is the viral open-source AI assistant with 150,000+ GitHub stars that runs on your own hardware. Unlike ChatGPT bots, it has persistent memory, can execute shell commands, manage files, and trigger automation across 50+ integrations.
Common use cases:
- Team task automation (code reviews, deployments, scheduling)
- Server monitoring with proactive alerts
- Multi-channel coordination (link Discord ↔ Slack ↔ email)
- File processing and data extraction
Prerequisites
What you need:
- Node.js 20+ installed locally or a cloud server (DigitalOcean, Railway, Hetzner)
- Discord server with admin permissions
- API key from Anthropic (Claude) or OpenAI (GPT-4)
- 10 minutes for Discord Developer Portal setup
Cost estimate: $0-5/month if self-hosting; AI API usage varies ($0.01-0.50 per conversation typically)
Solution
Step 1: Install OpenClaw
On macOS/Linux:
# Install OpenClaw via npm (requires Node.js 20+)
npm install -g @openclaw/gateway
# Initialize configuration
openclaw setup
# Follow the onboarding wizard
openclaw onboard
Expected output:
✓ OpenClaw gateway initialized
✓ Config created at ~/.openclaw/config.json
→ Next: Configure your AI provider and channels
On Windows (WSL2):
# Install WSL2 first, then follow macOS/Linux steps
wsl --install -d Ubuntu-24.04
If you prefer Docker:
docker pull openclaw/openclaw:latest
docker run -it -v ~/.openclaw:/root/.openclaw openclaw/openclaw
Step 2: Create Discord Bot Application
In Discord Developer Portal:
- Go to https://discord.com/developers/applications
- Click New Application → name it "OpenClaw Assistant"
- Navigate to Bot tab → Click Add Bot
- Copy the Bot Token (you'll need this in Step 4)
Critical: Enable Gateway Intents
Under Bot → Privileged Gateway Intents, enable:
- ✅ Message Content Intent (required to read messages)
- ✅ Server Members Intent (needed for @mention detection)
Why this matters: Without Message Content Intent, your bot will connect but won't respond to any messages—this is Discord's security requirement.
Step 3: Invite Bot to Your Server
Generate OAuth2 URL:
In Developer Portal: OAuth2 → URL Generator
Select scopes:
- ✅
bot - ✅
applications.commands
- ✅
Select bot permissions:
- ✅ View Channels
- ✅ Send Messages
- ✅ Read Message History
- ✅ Add Reactions
- ✅ Attach Files
Copy generated URL, open in browser
Select your server and authorize
Expected result: Bot appears in your server's member list (offline until Step 5)
Step 4: Configure OpenClaw for Discord
Get your Discord Server & Channel IDs:
- In Discord: User Settings → Advanced → Enable Developer Mode
- Right-click your server → Copy Server ID (guild ID)
- Right-click desired channel (e.g., #bot-commands) → Copy Channel ID
- Right-click your username → Copy User ID (for allowlist)
Create OpenClaw config:
# Edit configuration
openclaw configure
Add this Discord configuration to ~/.openclaw/config.json:
{
"channels": {
"discord": {
"enabled": true,
"token": "YOUR_BOT_TOKEN_FROM_STEP_2",
"groupPolicy": "allowlist",
"guilds": {
"YOUR_GUILD_ID": {
"requireMention": true,
"users": ["YOUR_USER_ID"],
"channels": {
"bot-commands": {
"allow": true,
"requireMention": false
}
}
}
}
}
},
"providers": {
"anthropic": {
"apiKey": "sk-ant-api03-..."
}
}
}
Configuration explained:
requireMention: true→ Bot only responds when @mentioned (prevents spam in busy channels)groupPolicy: "allowlist"→ Only specified users can interactchannels.bot-commands.requireMention: false→ Responds to all messages in this channel
Alternative: Environment Variables
# Simpler for single-channel setups
export DISCORD_BOT_TOKEN="your_token_here"
export ANTHROPIC_API_KEY="sk-ant-api03-..."
openclaw gateway
Step 5: Start the Gateway
# Start OpenClaw service
openclaw gateway
# Or run in background (macOS/Linux)
openclaw gateway &
# Check status
openclaw status
Expected output:
✓ Gateway running on ws://127.0.0.1:18789
✓ Discord channel connected (1 guild)
✓ Anthropic provider ready
→ Monitoring channels...
If it fails:
- "Used disallowed intents" → Go back to Step 2, enable Message Content Intent
- "Invalid token" → Double-check bot token from Developer Portal
- "Cannot connect to Discord" → Check firewall settings, ensure port 443 outbound is open
Step 6: Test Your Bot
In Discord:
@OpenClaw Assistant hello
Expected response:
Hello! I'm your OpenClaw assistant. I can help with tasks,
remember our conversations, and execute commands. Try asking me
to summarize a file or set a reminder!
Try advanced features:
@OpenClaw run a quick server health check
@OpenClaw remind me in 30 minutes to review the PR
@OpenClaw search our docs for "deployment guide"
Verification
Run diagnostics:
# Health check
openclaw doctor
# Verify Discord connection
openclaw channels status --probe
You should see:
✓ Discord channel: connected
✓ Message Content Intent: enabled
✓ Server Members Intent: enabled
✓ Guilds: 1 configured, 1 active
✓ Channels: 1 allowed
Test multi-user access:
- Add another user ID to
guilds.YOUR_GUILD_ID.usersarray - Restart gateway:
openclaw gateway --force - Have them send:
@OpenClaw test
Advanced Configuration
Multi-Channel Setup
Different permissions per channel:
{
"guilds": {
"YOUR_GUILD_ID": {
"channels": {
"general": {
"allow": true,
"requireMention": true,
"systemPrompt": "Keep responses under 2 sentences"
},
"admin-only": {
"allow": true,
"users": ["ADMIN_USER_ID"],
"skills": ["exec", "files", "browser"]
},
"read-only": {
"allow": true,
"skills": []
}
}
}
}
}
Why per-channel prompts matter: Prevents assistant from writing essays in busy channels while allowing detailed responses in dedicated channels.
DM Support with Pairing
Enable secure DMs:
{
"discord": {
"dm": {
"enabled": true,
"policy": "pairing"
}
}
}
How it works:
- User DMs the bot
- Bot sends pairing code (expires in 1 hour)
- Approve with:
openclaw pairing approve discord <code> - User can now DM the bot directly
Security note: policy: "pairing" prevents random users from spamming your bot. Use policy: "open" only for public bots.
Proactive Notifications
Make OpenClaw reach out first:
# Send message to Discord channel
openclaw message send "channel:YOUR_CHANNEL_ID" "Daily standup reminder!"
# From a cron job
0 9 * * 1-5 openclaw message send "channel:123" "Good morning team!"
Trigger notifications from code:
// In your webhook endpoint
fetch('http://localhost:18789/tools/invoke', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
tool: 'agent_send',
input: {
channel: 'channel:YOUR_CHANNEL_ID',
message: 'Build failed! Check logs at https://...'
}
})
});
Thread Support
Bot automatically follows threads:
{
"discord": {
"actions": {
"threads": true
}
}
}
Threads inherit parent channel permissions by default. Override with explicit thread ID in config.
Reaction Triggers
Let users react to trigger actions:
{
"discord": {
"actions": {
"reactions": true
},
"guilds": {
"YOUR_GUILD_ID": {
"reactionNotifications": "all"
}
}
}
}
Example workflow: User adds ✅ reaction to a message → Bot marks task complete in project tracker.
What You Learned
- OpenClaw runs locally with full system access (unlike cloud chatbots)
- Discord setup requires Message Content Intent or bot won't respond
groupPolicy: "allowlist"+requireMentionprevents abuse in public servers- Per-channel configs enable different AI behaviors for different contexts
Limitations:
- Voice channels not supported (text only)
- File uploads capped at 8MB by default (configurable via
mediaMaxMb) - DM pairing codes expire after 1 hour
Security warning: OpenClaw can execute shell commands. Never give admin-only channels public access without strict users allowlists.
Troubleshooting
Bot Connects But Doesn't Respond
Symptom: Bot shows online but ignores messages
Fixes:
# Check Message Content Intent
openclaw channels status --probe
# Verify channel is allowed
grep -A 5 "channels" ~/.openclaw/config.json
# Test without mention requirement
# Temporarily set requireMention: false
Common cause: Forgot to enable Message Content Intent in Discord Developer Portal (Step 2).
"Used Disallowed Intents" Error
This means Discord blocked your bot's privileged access.
Fix:
- Discord Developer Portal → Your App → Bot tab
- Scroll to Privileged Gateway Intents
- Enable Message Content Intent
- Restart gateway:
openclaw gateway --force
Bot Stops Responding After 10 Minutes
Symptom: Works initially, then goes silent
This is usually WebSocket timeout or rate limiting.
{
"discord": {
"retry": {
"attempts": 5,
"minDelayMs": 1000,
"maxDelayMs": 60000
}
}
}
Or check logs:
openclaw logs --follow
Look for 429 Too Many Requests → You're hitting Discord's rate limits. Add delays between messages.
PluralKit Proxied Messages Ignored
For servers using PluralKit:
{
"discord": {
"pluralkit": {
"enabled": true,
"token": "pk_live_..."
}
}
}
Why this matters: PluralKit proxies messages for system members. Without this, OpenClaw sees them as bot messages (which are ignored by default).
Resources:
Tested on OpenClaw 2026.2.1, Discord Bot API v10, Node.js 22.x, macOS & Ubuntu 24.04