Connect OpenClaw to Discord

📘 Channel guide: This page covers Discord-only setup. New to OpenClaw? Start with the Quick Start Guide and installation, then return here to add 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 edit and optionally openclaw status.

Step 1: Create a Discord Application and Bot

  1. Go to the Discord Developer Portal and sign in.
  2. Click New Application, name it (e.g. “OpenClaw Agent”), and create it.
  3. In the left sidebar, open Bot. Click Add Bot and confirm.
  4. 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.
  5. 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.

  1. In the Developer Portal, go to OAuth2URL Generator.
  2. Under Scopes, select bot (and applications.commands if you use slash commands).
  3. Under Bot Permissions, select at least:
    • Read Messages/View Channels
    • Send Messages
    • Read Message History
    • Use Slash Commands (if your setup uses them)
    Add others as needed (e.g. Embed Links, Attach Files, Manage Messages).
  4. 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.

  1. Open your config (e.g. openclaw config edit or edit the config file directly).
  2. 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.
  3. 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

  1. Run openclaw status (or your CLI’s status command) and confirm the Discord channel is listed and connected.
  2. 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.
  3. 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

Related Resources