Connect OpenClaw to Discord
Overview
OpenClaw can run as a Discord bot in your servers and in DMs. Once connected, your self-hosted AI agent can read messages, reply in channels or private messages, use slash commands (if supported by your OpenClaw version), and run tasks 24/7-all from your own infrastructure.
This guide covers:
- Creating a Discord application and bot in the Discord Developer Portal
- Bot token, permissions, and intents
- Inviting the bot to your server
- Configuring the Discord channel in OpenClaw
- Verification and common Discord-specific issues
- Best practices and where to get help
Prerequisites
- OpenClaw installed and running - Gateway and CLI working. See the Quick Start Guide or installation hub for your platform.
- Discord account - You need a Discord account and permission to create apps (or use a server where you can add bots).
- Basic terminal/CLI - You will run
openclaw config editand optionallyopenclaw status.
Step 1: Create a Discord Application and Bot
- Go to the Discord Developer Portal and sign in.
- Click New Application, name it (e.g. “OpenClaw Agent”), and create it.
- In the left sidebar, open Bot. Click Add Bot and confirm.
- Under Token, click Reset Token or Copy to get the bot token. Store it securely-you will add it to OpenClaw’s config and never commit it to version control. If you use environment variables (recommended), put the token there instead of in the config file.
- Privileged Gateway Intents (if your OpenClaw Discord adapter needs them):
- Message Content Intent - Required if the bot must read message text (most setups). Enable it.
- Server Members Intent - Enable only if you need member list data.
- Presence Intent - Enable only if you need presence/status data.
Step 2: Bot Permissions and Invite Link
Your bot needs permission to read and send messages in the channels (and DMs) where OpenClaw should operate.
- In the Developer Portal, go to OAuth2 → URL Generator.
- Under Scopes, select bot (and applications.commands if you use slash commands).
- Under Bot Permissions, select at least:
- Read Messages/View Channels
- Send Messages
- Read Message History
- Use Slash Commands (if your setup uses them)
- Copy the generated Invite URL at the bottom, open it in a browser, choose your server, and authorize the bot.
Step 3: Configure OpenClaw for Discord
Add the Discord channel to your OpenClaw configuration. Exact schema may vary by OpenClaw version; refer to the official Discord channel documentation for the current structure.
- Open your config (e.g.
openclaw config editor edit the config file directly). - Add a channel entry for Discord. Typically you will set:
- Channel type (e.g.
discord) - Bot token - Prefer an environment variable (e.g.
DISCORD_BOT_TOKEN) and reference it in the config so the token is not stored in plain text in the file.
- Channel type (e.g.
- Save the config and restart the gateway (or let it reload if it supports hot reload).
Example (illustrative; check docs for your version):
# In your OpenClaw config, under channels (or equivalent):
# discord:
# token: ${DISCORD_BOT_TOKEN}
Set DISCORD_BOT_TOKEN in your environment before starting OpenClaw. For more options (e.g. allowed guilds, default prefix), see the advanced configuration guide and the official docs.
Step 4: Verify the Connection
- Run
openclaw status(or your CLI’s status command) and confirm the Discord channel is listed and connected. - In Discord, send a message in a channel where the bot has access (or in DMs with the bot). Your OpenClaw agent should receive the message and respond according to your agent and model setup.
- If you use slash commands, test one in the server or DMs.
If the bot does not respond, see Common Issues below and the channel troubleshooting guide.
Common Discord Issues
| Issue | Solution |
|---|---|
| Bot appears offline in Discord | Gateway may not be running or Discord channel not enabled. Run openclaw status, check logs, and ensure the bot token is correct and the gateway has restarted after config change. |
| Invalid token / authentication error | Confirm the token in the Developer Portal (Bot → Reset Token if needed) matches the value in your config or environment. Ensure no extra spaces or quotes. Never commit the token to git. |
| Bot doesn’t read messages | Enable Message Content Intent under Bot → Privileged Gateway Intents in the Developer Portal. Restart the gateway after changing intents. |
| Permission errors in channel | Re-check the bot’s role permissions in the server and the channel-specific overrides. Regenerate the invite URL with the required permissions (Read Messages/View Channels, Send Messages, Read Message History) and re-invite if needed. |
| Slash commands not showing | Ensure applications.commands scope was used in the invite URL and that your OpenClaw version and config support Discord slash commands. See official Discord channel docs. |
| Rate limits or disconnects | Discord enforces rate limits. Check OpenClaw logs for 429 or rate-limit messages; reduce message frequency or batch actions. Ensure network/firewall allows outbound connections to Discord. |
For more fixes (gateway, config, other channels), see the full troubleshooting hub and channel issues page.
Best Practices
- Keep the bot token secret. Use environment variables (e.g.
DISCORD_BOT_TOKEN) and follow security best practices. Rotate the token if it is ever exposed. - Principle of least privilege. Grant only the intents and permissions the bot needs (e.g. Message Content + Send/Read in chosen channels).
- Test in a private server first. Add the bot to a small server or a test server before using it in busy or production communities.
- Stay updated. Keep OpenClaw and your Discord adapter up to date for compatibility with Discord API changes.
- Monitor logs. Use
openclaw logs(or your log path) to catch connection and permission errors early.
Next Steps
- Add more channels: Telegram, WhatsApp, Slack - see the Channels hub.
- Install skills from ClawHub to extend what your agent can do in Discord.
- Explore use cases (e.g. customer support on Discord).
- Run through the security checklist and harden your deployment.
- Join the OpenClaw community (including the official Discord) for help and tips.
Related Resources
- Official Documentation - Links to docs.openclaw.ai
- OpenClaw Discord channel docs - Authoritative schema and options
- Video Tutorials - Installation and channel setup
- Configuration Templates - Example configs