Skip to content

Integrate with Discord

To chat with your agent remotely, connect it to a Discord bot.

Prerequisites

  • Discord account: Required to create the bot application.
  • Discord server: A server where you have permissions to add bots.

Step 1: Create a Discord bot

  1. Log in to the Discord Developer Portal with your Discord account.

  2. Click New Application. New application in Discord developer portal

  3. Enter a name for the new app, agree to terms, and then click Create.

    Create an application window

  4. From the left sidebar, select Bot.

  5. Scroll down to the Privileged Gateway Intents section and enable the following settings:

    • Presence Intent
    • Server Members Intent
    • Message Content Intent
  6. Click Save Changes.

  7. Scroll up to the Token section, click Reset Token, and then copy the generated token for your Discord bot. You need the token for channel configuration later in Control UI.

    Reset token

Step 2: Invite the bot to server

  1. From the left sidebar, select OAuth2, and then find the OAuth2 URL Generator section:

    a. In Scopes, select Bot and applications.commands.

    OAuth2 URL Generator

    b. In Bot Permissions, set as the following image. You can modify the settings later.

    Bot permissions

  2. Copy the Generated URL at the bottom.

  3. Paste the URL into a new browser tab, select your Discord server, and then click Authorize. The bot is added to your server.

    Bot added to server

Step 3: Configure channel

Connect OpenClaw to your Discord bot by adding its configuration in the Control UI.

About channel configuration

This tutorial provides the basic setup to get your bot running in Discord quickly. For more detailed configurations, see the official OpenClaw documentation.

  1. Return to the Control UI > Config > Raw tab.

  2. Add the following channels section to the configuration file.

    This configuration enables Discord Direct Messages (DMs) and sets the DM policy to pairing for security.

    json
    "channels": {
        "discord": {
        "enabled": true,
        "token": "{YOUR_BOT_TOKEN}",
        "allowBots": true,
        "dm": {
            "enabled": true,
            "policy": "pairing"
        }
        }
    },

    Discord channel added

  3. Replace {YOUR_BOT_TOKEN} with your Discord bot token.

  4. Click Save.

  5. From the left sidebar, select Channels. On the Discord card, Probe ok indicates successful connection.

    Probe OK

Step 4: Authorize your account

For security, the bot does not talk to unauthorized users. You must pair your Discord account with the bot.

  1. Open Discord and send a Direct Message to your new bot. The bot will reply with an error message containing a Pairing Code.

  2. Open the OpenClaw CLI and enter the following command:

    bash
    openclaw pairing approve discord {Your-Pairing-Code}
  3. Once approved, you can start chatting with your agent in Discord.

Next steps