How to Connect Openclaw to Discord
Quick Start
Connecting Openclaw to Discord lets you run an AI agent in your servers. This guide walks you through creating a bot, configuring your gateway, and controlling channel access.
For more messaging options, check out our guide on Connect Slack Openclaw or Google Chat Openclaw.
Create a Discord Bot
- Go to the Discord Developer Portal and click New Application.
- Name your application (e.g., Openclaw).
- Click Bot on the left sidebar and set the Username to your agent name.
- Click Reset Token to generate your Bot Token. Copy and secure it immediately.
- Scroll to Privileged Gateway Intents and enable Message Content Intent. Enable Server Members Intent if you need user resolution.
Configure Openclaw
Set your Discord token and enable the channel:
openclaw config set channels.discord.token '"YOUR_BOT_TOKEN"' --json
openclaw config set channels.discord.enabled true --json
Alternatively, use the environment variable:
export DISCORD_BOT_TOKEN="your-token-here"
Restart Gateway
Apply changes by restarting:
openclaw gateway restart
Channel Permissions
Control which servers and channels your bot responds in. Add this to your ~/.openclaw/openclaw.json:
{
"channels": {
"discord": {
"guilds": {
"YOUR_SERVER_ID": {
"channels": {
"general": { "allow": true, "requireMention": false }
}
}
}
}
}
}
Set requireMention to true if you want the bot to only respond when @mentioned.
Test Your Bot
Send a message in an allowed channel:
@YourBotName hello
The bot should reply within seconds. Check logs with openclaw logs if it does not respond.
Troubleshooting
- Bot offline: Verify your token is correct and the gateway is running.
- No responses: Check that Message Content Intent is enabled in the Discord Developer Portal.
- Permission errors: Ensure the bot has Send Messages and Read Message History permissions in your Discord channel.
- Wrong server: Double-check the YOUR_SERVER_ID in your config matches your Discord server.
Need help with other platforms? See Telegram Openclaw.