What You Will Achieve
By following this guide, you will connect OpenClaw to Discord. Once connected, you can chat with AI through direct messages to your bot, or add the bot to a server where members can interact with it. Discord is popular for communities, gaming groups, and teams who want shared access to AI.
What is a Discord Bot?
A Discord bot is an automated account that can join servers and respond to messages. You will create your own bot through Discord's Developer Portal, and OpenClaw will control it. When someone messages your bot, OpenClaw receives the message, gets an AI response, and sends it back through Discord.
Before You Start
Make sure you have completed these steps:
- OpenClaw is installed and running on your computer
- You have a Discord account (free to create at discord.com)
- Discord app is installed on your phone or computer (or use the web version)
Check OpenClaw Status First
Before continuing, open your terminal and run openclaw status. You should see "Gateway: running". If not, start OpenClaw first by running openclaw gateway --daemon.
Verify OpenClaw is running:
openclaw status
Expected Result
Gateway: running Port: 18789 Auth: configured
Understanding the Process
Here is what we will do:
- Create a Discord Application in the Discord Developer Portal
- Create a Bot for your application
- Get a Bot Token (a secret key that lets OpenClaw control your bot)
- Add the bot to a server (optional, for server-based usage)
- Configure OpenClaw with your bot token
- Test the connection by sending a message
DMs vs Server Usage
Your Discord bot can work in two ways:
- Direct Messages (DMs): Users message the bot privately, one-on-one
- Server channels: The bot joins a server and responds in text channels
This guide covers both options. You can use either or both.
Step-by-Step Setup
Open the Discord Developer Portal
Discord has a special website for creating bots called the Developer Portal.
Open this URL in your web browser:
https://discord.com/developers/applications
If you are not logged in, Discord will ask you to log in with your Discord account.
Expected Result
You see the Discord Developer Portal with a page titled "Applications". If this is your first time, the list will be empty.
Create a New Application
An "Application" in Discord is like a container for your bot. We need to create one first.
- Click the "New Application" button (usually in the top-right corner)
- Enter a name for your application (like "My AI Bot" or "OpenClaw Assistant")
- Check the box to agree to Discord's Terms of Service
- Click "Create"
Choosing a Name
This name will be visible to users when they interact with your bot. Choose something friendly and descriptive. You can change it later if needed.
Expected Result
You are taken to your new application's settings page. You will see tabs on the left side like "General Information", "OAuth2", "Bot", etc.
Create a Bot for Your Application
Now we need to add a bot to your application.
- In the left sidebar, click "Bot"
- Click the "Add Bot" button
- A popup will ask "Add a bot to this app?" - Click "Yes, do it!"
Expected Result
The page now shows your bot settings. You will see your bot's username (same as your application name) and a profile picture.
Important settings to configure:
-
Public Bot: Turn this OFF if you want only you to be able to add the bot to servers. Turn it ON if you want others to add it to their servers.
-
Message Content Intent: You MUST turn this ON for OpenClaw to work. This allows your bot to read message content.
Enable Message Content Intent
Without the Message Content Intent enabled, your bot cannot read messages and OpenClaw will not work. Make sure you scroll down and toggle "MESSAGE CONTENT INTENT" to ON. You will see a warning about verification for 100+ servers - this is only relevant if your bot becomes very popular.
- Click "Save Changes" at the bottom if prompted.
Get Your Bot Token
The Bot Token is a secret password that lets OpenClaw control your bot. We need to copy it.
- On the Bot settings page, find the "Token" section
- Click "Reset Token" (or "View Token" if available)
- Discord may ask you to confirm with your password or 2FA code
- Click "Copy" to copy the token to your clipboard
Keep Your Token Secret!
NEVER share your bot token with anyone. Anyone with your token can fully control your bot. If you accidentally share it:
- Go back to the Bot settings
- Click "Reset Token" to generate a new one
- Update the token in OpenClaw
Expected Result
Your token is now copied. It looks something like: MTIzNDU2Nzg5MDEyMzQ1Njc4.XXXXXX.XXXXXXXXXXXXXXXXXXXXXXXX
Save this token somewhere safe - you will need it in a few steps.
Generate an Invite Link (For Server Usage)
If you want to add your bot to a Discord server, you need to create an invite link.
Skip This Step for DM-Only Usage
If you only want to use the bot through Direct Messages and not add it to any servers, you can skip this step.
-
In the left sidebar, click "OAuth2"
-
Click "URL Generator" (under OAuth2)
-
In the "SCOPES" section, check "bot"
-
A new section called "BOT PERMISSIONS" appears below
-
In BOT PERMISSIONS, check these boxes:
- Read Messages/View Channels
- Send Messages
- Read Message History
- (Optional) Embed Links - for rich message formatting
- (Optional) Attach Files - if you want the bot to send files
-
Scroll down to see the "GENERATED URL"
-
Click "Copy" to copy the URL
Expected Result
You have a URL that looks like: https://discord.com/api/oauth2/authorize?client_id=123456789...
Add the Bot to Your Server
Now let us add the bot to a Discord server.
You Need Server Permissions
To add a bot to a server, you must have the "Manage Server" permission on that server. If you do not have this, ask the server owner to add the bot using your invite link.
- Open the invite URL you copied in a new browser tab
- Discord shows a page asking which server to add the bot to
- Click the dropdown menu and select your server
- Click "Continue"
- Review the permissions and click "Authorize"
- Complete the CAPTCHA if prompted
Expected Result
You see "Authorized" with a checkmark. Your bot is now in your server!
Go to your Discord server - you should see your bot in the member list (it will appear offline until we connect OpenClaw).
Add the Bot Token to OpenClaw
Now we need to tell OpenClaw about your Discord bot. There are two ways to do this:
Method A: Using Environment Variable (Recommended for beginners)
Set the token as an environment variable:
export DISCORD_BOT_TOKEN="MTIzNDU2Nzg5MDEyMzQ1Njc4.XXXXXX.XXXXXXXXXXXXXXXXXXXXXXXX"
Make It Permanent
To keep this setting after restarting your computer, add the export line to your ~/.bashrc or ~/.zshrc file.
Method B: Using Configuration File
Edit the OpenClaw configuration file at ~/.openclaw/openclaw.json:
{
"channels": {
"discord": {
"enabled": true,
"token": "MTIzNDU2Nzg5MDEyMzQ1Njc4.XXXXXX.XXXXXXXXXXXXXXXXXXXXXXXX"
}
}
}
How to Edit the Config File
- On Mac/Linux: Run
nano ~/.openclaw/openclaw.jsonin Terminal - On Windows (WSL): Run
nano ~/.openclaw/openclaw.jsonin Ubuntu - Save the file with Ctrl+O, then exit with Ctrl+X
Expected Result
Your configuration now contains your Discord bot token.
Restart the OpenClaw Gateway
For the new channel to work, we need to restart OpenClaw's gateway.
openclaw gateway restart
Wait a few seconds for the gateway to restart.
Expected Result
Stopping gateway... Starting gateway... Gateway started successfully Channels: discord (connected)
Check your Discord server - your bot should now show as "Online" in the member list!
Send Your First Message
Now let us test that everything works!
Option A: Direct Message (DM)
- In Discord, click on your bot in any member list
- Click "Message" to start a DM
- Type "Hello!" and send
Option B: Server Channel
- Go to any text channel where the bot has access
- Mention your bot:
@YourBotName Hello! - Or configure the bot to respond to all messages (advanced)
First Message: Pairing Required
The first time you message your bot, OpenClaw needs to verify that you are allowed to use it. This is called "pairing".
What happens next:
- Your bot will reply with a pairing code (a 6-digit number)
- Go to your terminal and run:
openclaw pairing list discord
- Approve the pairing:
openclaw pairing approve discord 123456
Replace 123456 with the actual pairing code shown.
Expected Result
Pending pairing requests: [1] Discord: username#1234 (Code: 123456)
Approve which request? 1 Pairing approved for username#1234
Test Your AI Connection
Now that pairing is complete, send another message:
- Go back to Discord
- Send a message like "What can you help me with?"
Expected Result
Your bot should respond with an AI-generated message within a few seconds.
Congratulations!
You have successfully connected OpenClaw to Discord! You can now chat with AI through Discord on any device.
Common Problems and Solutions
Bot shows offline in Discord
Check if OpenClaw is running:
openclaw status
If the gateway is not running, start it:
openclaw gateway --daemon
If still offline, verify your token is correct:
openclaw channels remove --channel discord
openclaw channels add --channel discord --token YOUR_TOKEN
"Invalid token" error
This means the Bot Token you entered is incorrect.
Solution:
- Go back to the Discord Developer Portal
- Navigate to your application, then Bot
- Click "Reset Token" to generate a new one
- Copy the new token
- Run
openclaw channels remove --channel discordthenopenclaw channels add --channel discord --token YOUR_NEW_TOKEN
Bot does not respond to messages
Check these settings in the Developer Portal:
- Message Content Intent must be enabled (Bot settings page)
- The bot must have Read Messages and Send Messages permissions in the server
Also verify:
openclaw logs --limit 20
Look for any error messages related to Discord.
"Missing Access" or permission errors
The bot does not have the right permissions in the server.
Solution:
- In Discord, right-click the channel
- Click "Edit Channel"
- Go to "Permissions"
- Make sure your bot role has "View Channel", "Send Messages", and "Read Message History" enabled
Bot responds in DMs but not in servers
For server channels, you may need to:
- Mention the bot:
@YourBotName message here - Or configure OpenClaw to respond to all messages (see advanced configuration)
Pairing code not appearing
If you sent a message but did not receive a pairing code:
- Check that Message Content Intent is enabled
- Make sure the gateway is running:
openclaw status - Check the logs:
openclaw logs --limit 20 - Try restarting:
openclaw gateway restart
Setting Up Server-Wide Access
If you want multiple people in your server to use the AI bot, you have options:
Option 1: Individual Pairing
Each user messages the bot, receives a pairing code, and you approve them one by one. This gives you control over who can use the bot.
Option 2: Configure Allowlist in Config File
You can configure OpenClaw to allow specific users by editing ~/.openclaw/openclaw.json:
{
"channels": {
"discord": {
"dmPolicy": "allowlist",
"allowFrom": ["user_id_1", "user_id_2"]
}
}
}
To find a user ID:
- In Discord, enable Developer Mode (Settings > Advanced > Developer Mode)
- Right-click on a user
- Click "Copy User ID"
Option 3: Dedicated Channel
Create a channel specifically for AI chat:
- Create a new text channel (e.g., #ai-chat)
- Set the bot to only respond in that channel
- Configure appropriate permissions
Customizing Your Bot
Change Bot Profile Picture
- Go to Discord Developer Portal
- Click your application
- Click "Bot" in the sidebar
- Click on the current avatar
- Upload a new image
Change Bot Username
- Go to Discord Developer Portal
- Click your application
- Click "Bot" in the sidebar
- Edit the "USERNAME" field
- Click "Save Changes"
Username Change Limits
Discord limits how often you can change a bot's username. Do not change it frequently.
Add a Status Message
You can set a custom status for your bot by configuring it in ~/.openclaw/openclaw.json. See the official OpenClaw documentation for available options.
Security Tips
Keep Your Bot Token Secret
Never share your Bot Token with anyone. If someone gets your token, they can fully control your bot.
If your token is compromised:
- Go to Discord Developer Portal
- Navigate to your application's Bot settings
- Click "Reset Token"
- Update OpenClaw with the new token:
openclaw channels remove --channel discord
openclaw channels add --channel discord --token YOUR_TOKEN
Additional security tips:
- Keep "Public Bot" OFF unless you want others to add your bot to their servers
- Regularly check who has access through
openclaw pairing list discord - To remove a user's access, you can update the allowlist in your configuration file
Discord-Specific Features
Rich Embeds
Discord supports rich message formatting. OpenClaw can send formatted responses with:
- Colored sidebars
- Titles and descriptions
- Fields and footers
- Timestamps
This is enabled by default when the bot has "Embed Links" permission.
Slash Commands (Advanced)
Discord supports slash commands (like /ask question). This requires additional setup in the Developer Portal. See the official OpenClaw documentation for details.
Multiple Servers
Your bot can be in multiple servers simultaneously. Each server can have its own configuration:
- Different response triggers
- Different permissions
- Different approved users
What To Do Next
Now that Discord is connected, explore these options:
- Connect to Telegram - Use AI through Telegram
- Connect to WhatsApp - Use AI through WhatsApp
- Multi-Channel Setup - Use multiple platforms at once
- Your First Agent - Learn to customize AI responses
Need Help?
If you run into problems not covered here, check our Troubleshooting guide or visit the official OpenClaw documentation.
Last updated: February 3, 2026 | Found an error? Contact us