Skip to main content
RapidDev - Software Development Agency
openclaw-integrationsDirect API Integration

How to Connect Discord to OpenClaw

To connect Discord to OpenClaw, create a Discord bot application, copy your DISCORD_BOT_TOKEN, and configure it in OpenClaw's config file. OpenClaw then communicates with Discord's HTTP API and Gateway to send messages, receive commands, and automate server activity. This is a direct API integration — no ClawHub skill required. The bot runs under your Discord application and responds to events across any server it has been invited to.

What you'll learn

  • How to create a Discord bot application at the Discord Developer Portal and generate a bot token
  • How to configure DISCORD_BOT_TOKEN in OpenClaw's config for direct API integration
  • How to invite your OpenClaw bot to Discord servers with the correct permissions
  • How to send messages and respond to events across Discord channels through OpenClaw
  • How to troubleshoot common Discord bot authentication and permission errors
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Intermediate14 min read20 minutesMessagingMarch 2026RapidDev Engineering Team
TL;DR

To connect Discord to OpenClaw, create a Discord bot application, copy your DISCORD_BOT_TOKEN, and configure it in OpenClaw's config file. OpenClaw then communicates with Discord's HTTP API and Gateway to send messages, receive commands, and automate server activity. This is a direct API integration — no ClawHub skill required. The bot runs under your Discord application and responds to events across any server it has been invited to.

Why Connect Discord to OpenClaw?

Discord has evolved far beyond gaming — it is now the default community platform for open-source projects, developer communities, crypto communities, creator audiences, and support teams. Its structured server/channel model, rich permission system, and powerful bot API make it ideal for automation. If your team, customers, or audience lives in Discord, connecting OpenClaw to Discord means your AI agent can monitor conversations, respond to commands, post updates, and manage server activity without manual intervention.

The OpenClaw Discord integration works through Discord's bot system. You create a bot application (a few clicks in the Developer Portal), invite it to your servers, and give OpenClaw the bot token. From there, OpenClaw can send messages to any channel the bot has access to, listen for new messages and slash commands, react to events (member join, message reactions, thread creation), and build rich embedded responses. The integration uses Discord's REST API for sending and Discord's Gateway WebSocket for receiving — both are standard Discord bot infrastructure.

This integration is particularly valuable for teams that want to build Discord-native AI assistants, customer support bots that live in a Discord server, community moderation automation, or multi-platform messaging pipelines where Discord is one channel alongside Telegram and email. Unlike native ClawHub skills, this is a direct API integration — meaning you configure HTTP API calls and bot token credentials directly in OpenClaw rather than installing a packaged skill.

Integration method

Direct API Integration

Discord's bot API uses a token-based authentication model. You create a bot application at the Discord Developer Portal, invite it to your servers, and configure OpenClaw with the bot token under DISCORD_BOT_TOKEN. OpenClaw then calls Discord's REST API to send messages and connects to the Discord Gateway (WebSocket) to receive events in real time. This integration does not require a ClawHub skill — OpenClaw communicates directly with Discord's API endpoints using your bot token.

Prerequisites

  • A Discord account and access to the Discord Developer Portal at discord.com/developers
  • A Discord server where you have Administrator permissions to invite bots
  • OpenClaw installed and running on your machine
  • Basic familiarity with API keys and config files
  • Optional: a Discord server ID and channel IDs ready for targeting specific channels

Step-by-step guide

1

Create a Discord Bot Application and Get Your Bot Token

Go to the Discord Developer Portal at discord.com/developers/applications and click 'New Application'. Give it a name (e.g., 'OpenClaw Bot') and click 'Create'. This creates the application wrapper — next you need to create the actual bot. In the left sidebar, click 'Bot'. Click 'Add Bot' and confirm. Discord creates a bot user associated with your application. You will see the bot's username and a 'Token' section. Click 'Reset Token' and then 'Copy' to get your DISCORD_BOT_TOKEN. Store this token securely — it is the password to your bot account and should never be shared or committed to version control. While on the Bot page, configure these important settings: - Enable 'Message Content Intent' under the Privileged Gateway Intents section — this is required for your bot to read message content in servers. Without this, the bot can only see slash commands, not regular messages. - Enable 'Server Members Intent' if you want to track member joins and leaves. - Enable 'Presence Intent' if you need user presence data. Save your changes. Your DISCORD_BOT_TOKEN is ready to use in OpenClaw.

terminal
1# Your Discord bot token format:
2# DISCORD_BOT_TOKEN=MTExxxxxxxxxxxxxxxxxxx.Gxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
3
4# Verify your token works before configuring OpenClaw:
5curl -H "Authorization: Bot YOUR_BOT_TOKEN" \
6 https://discord.com/api/v10/users/@me
7
8# Expected response:
9# {"id": "123456789", "username": "OpenClaw Bot", "bot": true, ...}

Pro tip: Write down your Application ID (found on the General Information page) — you will need it to generate the bot invite URL in the next step. The Application ID is different from the bot token.

Expected result: You have a Discord bot application created, Message Content Intent enabled, and your DISCORD_BOT_TOKEN copied and ready to use.

2

Invite the Bot to Your Discord Server

Before your bot can interact with a Discord server, it needs to be invited with the correct permissions. Discord uses a URL-based invite system called OAuth2. In the Developer Portal, go to your application > OAuth2 > URL Generator. Under 'Scopes', check: - `bot` — required for all bot functionality - `applications.commands` — required if you want to register slash commands Under 'Bot Permissions', select the permissions your OpenClaw bot needs: - Send Messages - Read Message History - View Channels - Embed Links (for rich message formatting) - Add Reactions (if you want reaction-based interactions) - Manage Messages (optional, for moderation features) Copy the generated URL at the bottom of the page and open it in a browser. Select the server you want to add the bot to and click 'Authorize'. You must have Administrator permissions on that server to invite bots. After authorization, you should see your bot appear in the server's member list (it will show as offline until OpenClaw connects to the Gateway). Note down the server ID (right-click server name > Copy Server ID with Developer Mode enabled) and any channel IDs you want to target.

terminal
1# Generate bot invite URL manually (replace YOUR_APPLICATION_ID):
2# https://discord.com/oauth2/authorize?client_id=YOUR_APPLICATION_ID&scope=bot+applications.commands&permissions=68608
3
4# Permission integer 68608 covers:
5# - View Channels (1024)
6# - Send Messages (2048)
7# - Read Message History (65536)
8# - Embed Links (16384)
9# Total: 1024 + 2048 + 65536 + 16384 = 85024 (adjust based on your needs)
10
11# Get channel IDs via Discord API once bot is in the server:
12curl -H "Authorization: Bot YOUR_BOT_TOKEN" \
13 https://discord.com/api/v10/guilds/YOUR_SERVER_ID/channels

Pro tip: Enable Developer Mode in Discord (Settings > Advanced > Developer Mode) to right-click on servers, channels, and users to copy their IDs. You will need these IDs frequently when configuring OpenClaw targeting.

Expected result: The bot appears as a member in your Discord server, and you have the server ID and target channel IDs noted for configuration.

3

Configure DISCORD_BOT_TOKEN in OpenClaw

Open OpenClaw's config file at `~/.openclaw/config.yaml` and add the Discord integration block under the `integrations` key. This tells OpenClaw how to authenticate with Discord's API and which events to listen for. The `bot_token` field is your DISCORD_BOT_TOKEN from Step 1. The `gateway` section controls which Gateway events OpenClaw subscribes to — these are the Discord events that will trigger OpenClaw processing. The `channels` list (optional) restricts OpenClaw to specific channel IDs; if omitted, the bot will be active in all channels it has access to. The `intents` field must match the Privileged Intents you enabled in the Developer Portal. If you enabled Message Content Intent, include `MESSAGE_CONTENT` here. Mismatched intents are the most common cause of bots that connect successfully but cannot read message text. After saving, run `clawhub reload` to apply the configuration. OpenClaw will attempt to connect to the Discord Gateway and authenticate your bot. Check the OpenClaw log for a confirmation message indicating the bot is connected.

~/.openclaw/config.yaml
1# ~/.openclaw/config.yaml
2integrations:
3 discord:
4 bot_token: "YOUR_DISCORD_BOT_TOKEN"
5 intents:
6 - GUILDS
7 - GUILD_MESSAGES
8 - MESSAGE_CONTENT # Requires Privileged Intent enabled in Dev Portal
9 - GUILD_MEMBERS # Optional: for member join/leave events
10 gateway:
11 reconnect: true # Auto-reconnect on disconnect
12 heartbeat_interval: 41250 # Discord default, usually auto-negotiated
13 channels:
14 - "CHANNEL_ID_1" # Optional: restrict to specific channels
15 - "CHANNEL_ID_2" # Remove this block to monitor all channels
16 command_prefix: "!" # Prefix for traditional prefix-based commands
17 slash_commands: true # Register slash commands on connect

Pro tip: Keep your bot token out of version control. If you are storing OpenClaw config in a git repo, use environment variable substitution: `bot_token: "${DISCORD_BOT_TOKEN}"` and export the variable in your shell profile instead.

Expected result: Running `clawhub reload` shows no config errors and OpenClaw logs show the Discord bot connecting to the Gateway and going online.

4

Test Sending and Receiving Messages

With the bot connected, test both directions: sending a message from OpenClaw to Discord, and verifying OpenClaw receives incoming messages. To test sending, use Discord's REST API directly with a curl command targeting a specific channel ID. This confirms your bot token has permission to post in that channel. The channel ID must be a text channel in a server your bot has joined. To test receiving, go to your Discord server and type a message in a channel the bot can see. Check OpenClaw's log output — if Message Content Intent is configured correctly, the log will show the incoming message event with the message text. If you see the event but the `content` field is empty, your Message Content Intent is not enabled in the Developer Portal (a very common gotcha). Once bidirectional communication works, you can build more complex automation: slash command handlers, message filters, automated responses based on keywords, and workflow triggers.

terminal
1# Test sending a message to a Discord channel:
2curl -X POST "https://discord.com/api/v10/channels/YOUR_CHANNEL_ID/messages" \
3 -H "Authorization: Bot YOUR_BOT_TOKEN" \
4 -H "Content-Type: application/json" \
5 -d '{"content": "Hello from OpenClaw! Bot is online and connected."}'
6
7# Test sending an embedded message (richer formatting):
8curl -X POST "https://discord.com/api/v10/channels/YOUR_CHANNEL_ID/messages" \
9 -H "Authorization: Bot YOUR_BOT_TOKEN" \
10 -H "Content-Type: application/json" \
11 -d '{
12 "embeds": [{
13 "title": "OpenClaw Status",
14 "description": "Integration is working correctly.",
15 "color": 5763719,
16 "footer": {"text": "Powered by OpenClaw"}
17 }]
18 }'
19
20# Test getting recent messages from a channel:
21curl -H "Authorization: Bot YOUR_BOT_TOKEN" \
22 "https://discord.com/api/v10/channels/YOUR_CHANNEL_ID/messages?limit=5"

Pro tip: Discord's color field for embeds is an integer (not hex string). Convert hex to decimal: #57F287 (green) = 5763719. Common embed colors: green 5763719, red 15548997, blue 3447003, yellow 16705372.

Expected result: A message appears in the target Discord channel, and incoming messages from Discord appear in OpenClaw's event log.

5

Set Up Automated Workflows and Command Handling

With send and receive confirmed, configure OpenClaw to act on incoming Discord messages. The most common patterns are: responding to slash commands, triggering workflows on keyword matches, and posting automated notifications. For slash commands, register them with the Discord API first — this tells Discord what commands your bot supports so users see autocomplete. Commands are registered per-guild (faster for testing) or globally (takes up to 1 hour to propagate). After registration, Discord delivers interaction events to your bot when a user runs a slash command. For keyword-based automation, configure OpenClaw workflows with Discord message triggers and content filter conditions. RapidDev recommends starting with a single test command (`/status` or `!ping`) to confirm the full pipeline works before adding complex logic. The config below shows both a prefix command setup and a slash command registration example. The workflow section shows how to route Discord events to OpenClaw's AI response pipeline.

~/.openclaw/config.yaml
1# Register a slash command with Discord (run once per command):
2curl -X POST "https://discord.com/api/v10/applications/YOUR_APP_ID/guilds/YOUR_SERVER_ID/commands" \
3 -H "Authorization: Bot YOUR_BOT_TOKEN" \
4 -H "Content-Type: application/json" \
5 -d '{
6 "name": "ask",
7 "description": "Ask OpenClaw a question",
8 "options": [{
9 "name": "question",
10 "description": "Your question",
11 "type": 3,
12 "required": true
13 }]
14 }'
15
16# ~/.openclaw/config.yaml workflow example
17workflows:
18 discord-ai-reply:
19 trigger:
20 integration: discord
21 event: message_create
22 conditions:
23 - field: content
24 starts_with: "!"
25 - field: author.bot
26 equals: false
27 actions:
28 - type: ai-response
29 prompt: "You are a helpful assistant in a Discord server. Reply concisely to: {{trigger.content}}"
30 - type: integration-call
31 integration: discord
32 endpoint: /channels/{{trigger.channel_id}}/messages
33 method: POST
34 body:
35 content: "{{ai-response.output}}"
36 message_reference:
37 message_id: "{{trigger.id}}"

Pro tip: Always check `author.bot: false` in your trigger conditions to prevent your bot from responding to its own messages or other bots, which can create infinite message loops that rack up Discord API rate limit violations.

Expected result: OpenClaw responds to Discord commands or triggers automated actions based on incoming message content, with the bot appearing active and responsive in the server.

Common use cases

OpenClaw-Powered Discord Support Bot

Deploy OpenClaw as a support bot in your Discord server. When a user posts a question in a #support channel, OpenClaw reads the message, generates a helpful AI response, and replies in the same channel or thread. Handles FAQs, routes complex issues to human staff by pinging a role, and logs all interactions.

OpenClaw Prompt

Build an OpenClaw config that monitors the #support channel in Discord server ID 1234567890 and replies to new messages using AI with a friendly support persona

Copy this prompt to try it in OpenClaw

Automated Server Announcements

Use OpenClaw to post scheduled or event-triggered announcements to Discord channels. Post daily summaries of activity, release announcements, or scheduled notifications to a #announcements channel without manual copy-pasting from other tools.

OpenClaw Prompt

Configure OpenClaw to post a daily digest to Discord channel ID 9876543210 every morning at 9 AM summarizing the previous day's GitHub commits and task completions

Copy this prompt to try it in OpenClaw

Cross-Platform Message Routing

Route messages between Discord and other platforms OpenClaw is connected to. Receive messages in a Discord #alerts channel that originated from Telegram, email, or external webhooks — consolidating all communication streams into your team's Discord workspace.

OpenClaw Prompt

Set up OpenClaw to forward messages from my Telegram channel to Discord channel ID 1112223334 in real time, preserving sender name and timestamp

Copy this prompt to try it in OpenClaw

Troubleshooting

Bot is online but message content shows as empty or null

Cause: The Message Content Intent is not enabled in the Discord Developer Portal, even though it is listed in your OpenClaw config. Discord requires explicit opt-in for this privileged intent.

Solution: Go to discord.com/developers/applications > your app > Bot > Privileged Gateway Intents and toggle on 'Message Content Intent'. Save changes. Restart OpenClaw. Note: if your bot is in 100+ servers, you must apply to Discord for verified access to this intent.

Bot token invalid or '401 Unauthorized' when testing API calls

Cause: The DISCORD_BOT_TOKEN in your OpenClaw config is wrong, expired, or was regenerated in the Developer Portal after you copied it.

Solution: Go to the Developer Portal > Bot > Reset Token to generate a new token. Copy the new token immediately (it only displays once) and update `bot_token` in `~/.openclaw/config.yaml`. Run `clawhub reload`.

typescript
1# Test token validity:
2curl -H "Authorization: Bot YOUR_NEW_TOKEN" https://discord.com/api/v10/users/@me
3# Returns bot user info on success, 401 JSON error if token is invalid

Bot cannot send messages — '403 Missing Permissions' error

Cause: The bot does not have Send Messages permission in the target channel, or the channel has specific permission overrides that block the bot's role.

Solution: In Discord, go to the channel Settings > Permissions. Find your bot's role (or the @everyone role if the bot has no specific role). Ensure 'Send Messages' and 'View Channel' are checked with green checkmarks — not explicitly denied with red X marks.

typescript
1# Check what permissions the bot has in a channel:
2curl -H "Authorization: Bot YOUR_BOT_TOKEN" \
3 https://discord.com/api/v10/channels/YOUR_CHANNEL_ID
4# Look at the 'permission_overwrites' array for your bot's role ID

429 Too Many Requests — bot hitting Discord rate limits

Cause: OpenClaw is sending too many messages in a short time period. Discord enforces per-channel rate limits (5 messages per 5 seconds) and global rate limits on bot accounts.

Solution: Add rate limiting configuration to your OpenClaw Discord integration. Space out bulk sends with delays, and check for retry_after values in 429 responses before retrying. For bulk notifications, use Discord's Bulk Delete or batch sending patterns.

typescript
1# Discord rate limit response format read retry_after:
2# {"message": "You are being rate limited.", "retry_after": 1.234, "global": false}
3
4# Add delay between sends in OpenClaw workflows:
5# integrations.discord.rate_limit_delay: 1.5 # seconds between API calls

Best practices

  • Enable only the Gateway Intents your integration actually needs — requesting unnecessary privileged intents can delay bot verification if you ever scale past 100 servers and must apply to Discord.
  • Store DISCORD_BOT_TOKEN as an environment variable and reference it in config with `${DISCORD_BOT_TOKEN}` rather than hardcoding the token in `~/.openclaw/config.yaml` to prevent accidental credential exposure.
  • Always filter out bot messages in your event handlers (`author.bot: false`) to prevent feedback loops where your bot responds to its own messages or to other bots in the server.
  • Use slash commands rather than prefix commands for new bots — Discord has been deprecating prefix-based message commands in favor of slash commands, which provide autocomplete, parameter validation, and a better user experience.
  • Test with a dedicated #bot-testing channel before enabling your bot in public-facing channels — this lets you iterate on responses and fix errors without disrupting your community.
  • Use Discord embeds for structured data (summaries, alerts, status updates) rather than plain text — embeds support titles, descriptions, fields, footers, and color coding that make bot messages much easier to read.
  • Implement exponential backoff for rate limit handling — when you receive a 429 response, wait the `retry_after` duration before retrying, and double the wait on successive rate limit hits to avoid amplifying the problem.
  • Regularly rotate your bot token as a security practice, especially after any suspected exposure — tokens can be regenerated in the Developer Portal without needing to re-invite the bot to any servers.

Alternatives

Frequently asked questions

How do I set up Discord integration in OpenClaw?

Create a bot application at discord.com/developers/applications, enable Message Content Intent under Bot > Privileged Gateway Intents, copy the bot token, and invite the bot to your server using the OAuth2 URL Generator. Add `bot_token` and your intent list under `integrations.discord` in `~/.openclaw/config.yaml`, then run `clawhub reload`.

Where do I find my Discord bot token for OpenClaw?

Go to the Discord Developer Portal (discord.com/developers/applications), select your application, click 'Bot' in the left sidebar, and click 'Reset Token'. Copy the token immediately — Discord only shows it once after generation. This token goes in the `bot_token` field of your OpenClaw Discord config.

Why is my OpenClaw Discord bot not reading messages?

The most common cause is a missing Message Content Intent. In the Developer Portal, go to Bot > Privileged Gateway Intents and toggle on 'Message Content Intent'. Also verify that `MESSAGE_CONTENT` is listed in your OpenClaw config's `intents` array. Both the portal setting and the config intent must be present.

Can OpenClaw Discord bot work across multiple servers?

Yes — once you invite the bot to multiple servers using the same OAuth2 invite URL, it receives events from all of them. Your OpenClaw config can target specific server IDs or channel IDs, or leave the filter empty to process events across all servers the bot has joined.

What are the Discord API rate limits for bots?

Discord enforces a 5-messages-per-5-seconds limit per channel for bots, plus a global rate limit of 50 API requests per second. When rate limited, Discord returns a 429 response with a `retry_after` value in seconds. Configure OpenClaw to respect this value before retrying. For high-volume messaging, stagger sends across channels rather than posting to one channel in rapid succession.

Is there help available for complex OpenClaw Discord bot setups?

RapidDev's engineering team helps non-technical founders and teams set up OpenClaw integrations including Discord bots with custom command handling, multi-server routing, and AI-powered response pipelines. If you are hitting a wall with permissions, intents, or workflow logic, reach out for hands-on support.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.