What is a Discord bot?
New to bots? Here's the short version before we get into the setup.
A Discord bot is just an account that's controlled by software instead of a human. You invite it to your server like you'd invite a friend, give it permission to read and send messages in specific channels, and then it listens for messages and responds. OpenClaw powers the bot's brain — every message you send it gets processed by your AI agent, which then replies.
What can OpenClaw do in Discord?
Once connected, your bot can do everything OpenClaw can do — from inside Discord.
Answer Questions
Ask your bot anything — it uses your OpenClaw agent's full knowledge and connected tools to respond.
Run Automations
Trigger scheduled tasks, check emails, run reports, or fetch data — all by messaging your bot.
Manage Tasks
Add to-dos, set reminders, draft messages, or update notes without leaving Discord.
Search & Research
Ask the bot to look things up, summarize web pages, or research a topic and post the results.
Serve Your Whole Server
Other members can talk to the bot too — great for communities, dev teams, or shared workspaces.
Private DM Mode
Configure the bot to only respond to you via DMs, keeping your personal agent private.
Step-by-step setup
Takes about 15 minutes. You'll need a Discord account and OpenClaw already installed.
-
Go to the Discord Developer Portal
Open discord.com/developers/applications and log in with your Discord account. This is Discord's free developer dashboard — no credit card needed.
-
Create a new application
Click New Application in the top right. Give it a name — this becomes the bot's display name in your server (you can change it later). Click Create.
-
Add a bot to the application
In the left sidebar, click Bot. Then click Add Bot → Yes, do it!. Your application now has a bot account attached to it.
On this page you can also:
- Upload a profile picture for the bot
- Toggle Public Bot off if you want to be the only one who can add it to servers
-
Enable required Privileged Gateway Intents
Still on the Bot page, scroll down to Privileged Gateway Intents and enable:
- Message Content Intent — lets the bot read message text (required for OpenClaw to understand what you're saying)
- Server Members Intent — optional, needed if you want the bot to see member info
Click Save Changes.
Message Content Intent is requiredWithout this, your bot will receive messages but won't be able to read what they say. OpenClaw will not be able to respond.
-
Copy your bot token
On the Bot page, click Reset Token → confirm → then click Copy. This is your bot's password — treat it like one.
Never share your bot tokenAnyone with your token can control your bot. Never post it on GitHub, in a Discord message, or anywhere public. If it leaks, click Reset Token immediately to invalidate it.
-
Invite the bot to your server
In the left sidebar, go to OAuth2 → URL Generator. Under Scopes, check bot. Under Bot Permissions, check:
- Read Messages / View Channels
- Send Messages
- Read Message History
- Use Slash Commands (optional but recommended)
Copy the generated URL at the bottom of the page, open it in your browser, select your server, and click Authorize. Your bot will appear in your server's member list.
-
Add the token to openclaw.json
Open your openclaw.json file and add the Discord section:
openclaw.json{ "channels": { "discord": { "enabled": true, "token": "YOUR_BOT_TOKEN_HERE", "prefix": "!", // optional command prefix "allowed_channels": [], // empty = all channels "allowed_users": [], // empty = all users "respond_to_mentions": true, // @bot triggers a response "respond_to_dms": true // bot responds to direct messages } } }Replace
YOUR_BOT_TOKEN_HEREwith the token you copied in Step 5. -
Restart OpenClaw and test it
Save openclaw.json and restart OpenClaw. Your bot should now show as Online in your Discord server. Send it a message by mentioning it:
@YourBot hello, are you there?If it replies, you're done. If not, check the troubleshooting section below.
Mention your bot or DM it to start chatting. Every message is processed by your OpenClaw agent, so it has access to all your connected tools, memory, and skills.
Configuration options
Fine-tune how your bot behaves using these openclaw.json settings.
| Key | Type | Default | What it does |
|---|---|---|---|
token |
string | — | Your Discord bot token. Required. |
prefix |
string | "!" |
Command prefix for text commands (e.g. !help). Leave blank to disable. |
allowed_channels |
array | [] |
Channel IDs where the bot will respond. Empty array means all channels. |
allowed_users |
array | [] |
Discord user IDs that can talk to the bot. Empty array means anyone in the server. |
respond_to_mentions |
boolean | true |
Bot responds when someone @mentions it in a channel. |
respond_to_dms |
boolean | true |
Bot responds to direct messages. |
typing_indicator |
boolean | true |
Shows the bot "typing…" while generating a response. |
max_message_length |
number | 2000 |
Discord's message limit. Long responses are split automatically. |
Restrict the bot to one channel or user
If you're running the bot on a shared server, you probably don't want everyone talking to your personal AI agent. Here's how to lock it down.
To find a channel ID: right-click the channel in Discord → Copy Channel ID (you may need to enable Developer Mode in Discord Settings → Advanced first).
{
"channels": {
"discord": {
"enabled": true,
"token": "YOUR_BOT_TOKEN",
"allowed_channels": ["1234567890123456789"], // only this channel
"allowed_users": ["9876543210987654321"], // only you
"respond_to_dms": true
}
}
}
Example prompts to try
Once your bot is online, mention it or DM it with any of these to get started.
Common problems & fixes
-
The bot only shows as Online while OpenClaw is running. Check that:
- OpenClaw is actually running on your machine
- The
tokenin openclaw.json matches the one in the Developer Portal exactly - You saved openclaw.json and restarted OpenClaw after adding the Discord config
- The
enabledfield is set totrue
-
- Check that Message Content Intent is enabled in the Developer Portal under Bot → Privileged Gateway Intents
- Make sure you're @mentioning the bot or messaging it in an allowed channel
- If you set
allowed_channels, confirm you're in one of those channels - If you set
allowed_users, confirm your Discord user ID is in the list
-
The token in your openclaw.json doesn't match your bot's current token. This happens if:
- You copied it incorrectly (watch for extra spaces)
- You clicked Reset Token in the Developer Portal after setting it up
- The token has special characters that need to be quoted in JSON
Go to the Developer Portal → Bot → Reset Token → copy the new token and paste it into openclaw.json, then restart OpenClaw.
-
Set the
allowed_channelsandallowed_usersfields to restrict who and where the bot responds. See the Restrict to one channel section above for the exact config. Remember to use the numeric channel and user IDs, not the names. -
Discord has a 2000 character limit per message. OpenClaw automatically splits long responses into multiple messages, but if the split feels awkward you can ask your agent to be more concise, or add this to your AGENTS.md:
AGENTS.mdWhen responding in Discord, keep replies under 1800 characters. If a response needs to be longer, summarize and offer to continue.