Skip to content
Guides

Getting a Discord bot token for OpenClaw

The Developer Portal steps, the intents, and where the token goes

5 min read

OpenClaw on Discord starts with a bot token, and the token is the last thing Discord gives you after a short sequence: an application, a bot, the privileged intents, and only then a token. The docs then have you invite the bot with an OAuth2 URL, collect three IDs, and hand the token to OpenClaw through an environment variable rather than a message. Here is the order, why each step exists, and what to do with the token once you have it.

The steps

  • In the Developer Portal create a new application, open Bot and set the username to your agent’s name; use a private server if you can, created for you and your friends.
  • Under Privileged Gateway Intents enable Message Content, required for normal guild messages; Server Members, recommended, for role allowlists and name matching; and Presence only if you want presence updates.
  • Click Reset Token and copy it. Despite the name, it generates your first token; nothing is being reset.
  • In OAuth2, generate an invite URL with the bot and applications.commands scopes and at least View Channels, Send Messages, Read Message History, Embed Links and Attach Files; add Send Messages in Threads if the bot will post in threads. Open the URL, pick the server, continue.
  • Turn on Developer Mode, copy the Server ID from the server icon and your User ID from your avatar, and allow direct messages from server members so pairing can reach you.

Where the token goes

The token is a secret. The docs set it as an environment variable on the machine running OpenClaw and reference it from the config as a secret reference, applied with a config patch and a dry run first. If OpenClaw runs as a service, install the service from a shell where the variable is set, or keep it in the OpenClaw environment file so the reference resolves after a restart. Plain token strings in the config work too; the docs prefer the reference.

The bot token is a secret. Set it on the machine running OpenClaw before messaging your agent

The two mistakes

  • Used disallowed intents, or a bot that sees no guild messages: the Message Content intent was not enabled on the Bot page.
  • A bot that never answers a DM: pairing is on by default, the first message gets a code, and someone has to approve it from OpenClaw.

OpenClaw on Discord walks the access modes and guild allowlists once the bot is in, and OpenClaw not responding is the general silent-bot ladder.

One more setting

If your host is blocked or rate-limited by Discord’s startup application lookup, set the application ID from the portal in the config so startup can skip that call. With several bots, keep each token and application ID under its own account; a top-level application ID is inherited by all of them.

On Diali

On Diali you paste the token once when you connect the channel; the application, the intents and the invite are still yours to click, and Discord on Diali is where it connects. Hosted OpenClaw on Diali is the assistant.

  • Application, bot, intents, then the token; Reset Token is how you get the first one.
  • Invite with the two scopes and the five permissions, then collect the Server and User IDs.
  • The token goes in an environment variable and a secret reference, never in a chat.
Get started

Stop reading about it, build one

Set up an agent, pick a channel, and have it working inside the app you already keep open.