How to Build an Intelligent Discord Bot with OpenClaw (Complete Guide)
Create a smart Discord bot powered by AI using OpenClaw. Covers bot setup, guild workspace pattern, components v2, forum channels, and real configuration examples.
Which model do you want as default?
Which channel do you want to use?
Limited servers, only 15 left
Most Discord bots are dumb. They respond to slash commands with predefined answers, match keywords, and follow rigid decision trees. An OpenClaw-powered Discord bot is different: it reads messages, understands context, remembers conversation history, uses tools, and responds intelligently.
This guide walks you through building an AI Discord bot with OpenClaw, from creating the bot application to advanced configurations like forum channels and components v2.
Why OpenClaw for Discord?
Traditional Discord bots require you to code every interaction. With OpenClaw, the AI handles the intelligence. You just configure the connection and define what the agent can do via skills.
Key advantages:
- Natural language understanding: No slash commands needed (though they are supported). Users just talk.
- Session isolation: Each channel gets its own conversation thread. The bot maintains separate context per channel.
- Guild workspace pattern: Your entire Discord server becomes an AI workspace where each channel is an isolated session.
- Components v2: Rich interactive messages with buttons, selects, and embeds.
- Forum channel support: AI can respond to forum posts, making it perfect for support forums.
- Multi-agent routing: Route different channels to specialized agents.
Step 1: Create a Discord Bot Application
- Go to the Discord Developer Portal
- Click "New Application" and give it a name
- Go to the "Bot" section
- Click "Reset Token" and copy the token (you will need this)
- Under "Privileged Gateway Intents", enable:
- Message Content Intent (required for reading messages)
- Server Members Intent (optional, for member-aware features)
- Go to "OAuth2" > "URL Generator"
- Select scopes:
bot,applications.commands - Select permissions:
Send Messages,Read Message History,Add Reactions,Use Slash Commands,Manage Messages(optional) - Copy the generated URL and open it to invite the bot to your server
Step 2: Configure OpenClaw
Add the Discord channel to your ~/.openclaw/openclaw.json:
{
"channels": {
"discord": {
"type": "discord",
"token": "YOUR_BOT_TOKEN_HERE",
"guildWorkspace": true,
"sessionScope": "per-channel-peer"
}
}
}
Key Configuration Options
token (required): Your Discord bot token from the Developer Portal.
guildWorkspace: When set to true, each Discord channel becomes an isolated session. This is the recommended pattern for server-wide AI assistance. The bot responds to all messages in channels it has access to.
sessionScope: Controls conversation isolation:
"per-channel-peer"-- Each user in each channel gets a separate conversation. Best for support bots."main"-- All messages in a channel share one conversation. Best for collaborative channels.
Step 3: Start and Test
openclaw start
The bot should come online in your Discord server. Send a message in any channel the bot has access to. You should see the bot thinking (typing indicator) and then responding.
Guild Workspace Pattern
The guild workspace pattern is what makes OpenClaw's Discord integration powerful. Instead of a bot that only responds to commands, you get an AI that is present across your entire server.
How it works:
- Each text channel = one isolated AI session
- The bot maintains separate conversation history per channel
- Users in #general have a different context than users in #support
- Forum posts get their own isolated sessions
Practical layout example:
#general -- Casual AI assistant, general questions
#code-help -- Programming-focused agent
#support -- Customer support with access to your docs
#brainstorm -- Creative ideation, no memory between topics
You can even use multi-agent routing to assign different AI models or system prompts per channel.
Forum Channel Support
Discord forum channels are perfect for support-style interactions. Each forum post becomes an isolated AI conversation:
Forum: #help-center
Post: "Can't connect to API" -- AI responds with troubleshooting steps
Post: "Billing question" -- AI responds with billing info
Post: "Feature request" -- AI acknowledges and categorizes
OpenClaw automatically detects forum channels and treats each post as a separate session. No additional configuration needed.
Components v2: Rich Interactions
OpenClaw supports Discord's components v2, enabling rich interactive messages:
- Buttons: Clickable actions within messages
- Select menus: Dropdown selections
- Embeds: Rich formatted messages with fields, images, and footers
The AI can generate these components dynamically based on context. For example, when helping with a multi-step process, it might present options as buttons rather than asking the user to type a choice.
Advanced Configuration
Multi-Agent Routing
Route specific channels to specialized agents:
{
"channels": {
"discord": {
"type": "discord",
"token": "YOUR_BOT_TOKEN_HERE",
"guildWorkspace": true
}
},
"agents": {
"support": {
"model": "claude-opus-4-6",
"systemPrompt": "You are a support agent. Help users resolve issues.",
"channels": ["#support", "#help-center"]
},
"code": {
"model": "claude-opus-4-6",
"systemPrompt": "You are a coding assistant. Help with programming questions.",
"channels": ["#code-help"]
}
}
}
DM Support
The bot can also handle direct messages:
{
"channels": {
"discord": {
"type": "discord",
"token": "YOUR_BOT_TOKEN_HERE",
"guildWorkspace": true,
"dmPolicy": "pairing"
}
}
}
Set dmPolicy to "pairing" for controlled access or "open" for public DMs.
Slash Commands
While OpenClaw works with natural language by default, you can register slash commands for common actions. The bot registers commands automatically based on configured skills.
Use Cases
Community Management
Deploy an AI moderator that:
- Answers frequently asked questions automatically
- Points users to relevant documentation
- Summarizes long threads when asked
- Welcomes new members with context-aware introductions
Technical Support
Create a support bot that:
- Understands error messages and suggests fixes
- Searches your documentation and knowledge base via skills
- Escalates complex issues to human support with a summary
- Maintains context across a multi-message troubleshooting session
AI-Assisted Moderation
Use OpenClaw to help with moderation:
- Flag potentially problematic content for review
- Provide context when moderators ask "what happened in this thread?"
- Auto-respond to common policy questions
- Generate summaries of heated discussions
Internal Team Assistant
For private servers:
- Shared AI assistant for brainstorming and planning
- Code review assistant in development channels
- Meeting notes summarizer
- Quick research tool accessible by the whole team
Connecting Multiple Channels
OpenClaw's gateway serves all channels simultaneously. Add WhatsApp and Telegram alongside Discord:
{
"channels": {
"discord": {
"type": "discord",
"token": "DISCORD_BOT_TOKEN",
"guildWorkspace": true
},
"whatsapp": {
"type": "whatsapp",
"dmPolicy": "pairing"
},
"telegram": {
"type": "telegram",
"token": "TELEGRAM_BOT_TOKEN"
}
}
}
One AI, three platforms. See our guides for WhatsApp and Telegram setup.
Troubleshooting
Bot is Online but Not Responding
- Check that Message Content Intent is enabled in the Developer Portal
- Verify the bot has "Read Messages" and "Send Messages" permissions in the channel
- Check OpenClaw logs:
openclaw logs
Bot Responds in Some Channels but Not Others
- With
guildWorkspace: true, the bot needs channel-level permissions - Check role permissions in Discord server settings
- Some channels may have category-level permission overrides
Slow Response Times
- AI response time depends on your model provider. Claude Opus typically responds in 3-8 seconds.
- For faster responses, consider a lighter model for simple channels
- Check your provider's rate limits
Bot Keeps Disconnecting
- Ensure your server has a stable internet connection
- Discord Gateway requires persistent WebSocket connections
- If running in Docker, check that the container is not being restarted by health checks
Security Best Practices
- Never commit your bot token to version control
- Use environment variables or OpenClaw's built-in secret management
- Run
openclaw security auditto check your configuration - Limit bot permissions to only what is needed
- Use channel-level permissions to restrict where the bot operates
- For public servers, consider rate limiting to prevent abuse
The Managed Alternative: ClawRapid
Setting up a Discord bot with OpenClaw is straightforward, but maintaining it requires a server and ongoing attention. ClawRapid offers managed OpenClaw instances with Discord pre-configured.
Benefits:
- Bot token securely stored
- Automatic reconnection and monitoring
- Multi-channel support out of the box
- No server maintenance
Deploy your AI Discord bot in minutes with ClawRapid.
FAQ
Q: Does the bot need to be mentioned to respond?
A: With guildWorkspace: true, the bot responds to all messages in channels it has access to. You can configure it to require mentions if preferred.
Q: Can it handle multiple servers? A: Yes. One OpenClaw instance can serve multiple Discord servers. Each server's channels are isolated sessions.
Q: What about voice channels? A: OpenClaw currently focuses on text-based interactions. Voice channel support is not built-in.
Q: How much does it cost to run? A: OpenClaw is free. The main cost is your AI provider API usage. For a moderately active server, expect $10-50/month in API costs depending on the model and volume.
Q: Can I use it alongside existing Discord bots? A: Absolutely. OpenClaw's bot operates independently and does not interfere with other bots. They can coexist in the same server and channels.
Ready to upgrade your Discord server with AI? Check out our OpenClaw use cases guide or deploy with ClawRapid for instant setup.
Which model do you want as default?
Which channel do you want to use?
Limited servers, only 15 left
Articles similaires

Build a Custom Morning Brief with OpenClaw (News, Tasks, and Next Actions)
Set up an OpenClaw morning brief that delivers curated news, calendar, and prioritized tasks, plus proactive recommendations the agent can execute for you.

OpenClaw Multi-Agent Content Factory: Research, Writing, and Thumbnails in Discord
Set up a multi-agent content factory with OpenClaw. A research agent finds opportunities, a writing agent drafts scripts and threads, and a thumbnail agent creates visuals, all organized in Discord channels and run on a schedule.

How to Create a Telegram AI Bot with OpenClaw (Step-by-Step Guide 2026)
Complete guide to building your own Telegram AI bot with OpenClaw. Step-by-step setup, configuration tips, use cases, and a 60-second alternative.