Skip to content
Guides

OpenClaw Discord setup

Creating the application and bot, the three privileged intents, the invite URL and baseline permissions, Developer Mode and the three IDs, DMs from server members, the SecretRef token patch, pairing by chat or CLI, the duplicate-token rule, running without Message Content, and turning a private server into a guild workspace

7 min read

Discord setup is longer than Telegram's because the bot needs an application, intents, an invite with permissions and three IDs before it can say hello. The OpenClaw docs walk it in order and then show the second half most people want: a private server where every channel is its own agent session. Here is the quick setup, the token rules, and the guild workspace.

Application, intents, invite

  • In the Developer Portal you create a new application, open the Bot page and set the username to your agent's name, then under Privileged Gateway Intents enable Message Content, required for normal guild messages, Server Members, recommended and required for role allowlists, name-to-ID matching and channel-audience access groups, and optionally Presence for presence updates.
  • The Reset Token button on the Bot page generates your first token despite its name; then the OAuth2 URL Generator takes the bot and application-commands scopes and, in the permissions section that appears, at least View Channels, Send Messages, Read Message History, Embed Links and Attach Files, optionally Add Reactions, and Send Messages in Threads if the bot will post in threads or in forum and media channel workflows, after which you open the generated URL, pick your server and continue.
  • Developer Mode in the Discord app lets you copy IDs: right-click the server icon to copy the server ID and your own avatar to copy your user ID, and keep both with the token; for pairing to work the server's privacy settings must allow direct messages from members, which you can turn off after pairing if you only use guild channels.
  • The token is a secret set on the machine running OpenClaw before you message the agent: export it, write a patch that enables the channel with an environment SecretRef, run the config patch command with a dry run and then for real, and start the gateway; a background service is restarted from the Mac app or by restarting the gateway run process, a managed service is installed from a shell where the variable is set or reads it from the OpenClaw env file, and a host blocked or rate-limited by Discord's startup application lookup can set the application ID so startup skips that REST call.
Long-term memory (MEMORY.md) only auto-loads in DM sessions; guild channels do not load it.

Pairing and tokens

You finish setup either by telling your agent on an existing channel that the token is in the config and giving it your user and server IDs, or by config, where the same JSON5 block can be applied with the patch command, plaintext tokens work too, and SecretRef values are supported across the env, file, exec and store providers. Several bots keep their token and application ID under their own account, since a top-level application ID is inherited and belongs there only when every account shares it. Once the gateway runs, a DM to the bot returns a pairing code that you approve by sending it to your agent or with the pairing list and approve commands, and codes expire after one hour. If Discord cannot grant Message Content, OpenClaw still works in DMs and in guild channels where users mention the bot explicitly: set the message-content intent to false so the gateway does not request the unavailable intent, keep the mention requirement on every configured channel, and accept that Discord omits user-authored content from other guild messages. Token resolution is account-aware, config values win over the environment fallback and the token variable serves only the default account; when two enabled accounts resolve to the same token, OpenClaw starts one monitor for it, a config-sourced token beats the env fallback, otherwise the first enabled account wins and the duplicate is reported disabled with a duplicate-bot-token reason; and an explicit per-call token on advanced outbound actions applies to that call while policy and retry settings still come from the selected account.

The guild workspace

  • Adding your server to the guild allowlist, by asking the agent or by setting an allowlist group policy with your server ID, the mention requirement and your user ID under guilds, lets the agent respond in any channel on the server rather than only in DMs.
  • By default the agent answers in guild channels only when mentioned, and on a private server you probably want every message: set the mention requirement to false, or for shared always-on rooms opt into message-tool visible replies so the agent can lurk and post only when it decides a reply is useful, which works best with the latest tool-reliable models; if Discord shows typing and the logs show token usage but nothing is posted, check whether the turn was an ambient room event or opted into message-tool replies, and session-busy notices follow the same policy, logged rather than posted.
  • Long-term memory auto-loads only in DM sessions, so for guild channels you either tell the agent to use the memory search and get tools when it needs long-term context, or put stable instructions in the agents or user files that are injected into every session and keep the notes in the memory file for on-demand access; then you create channels and chat, since the agent sees the channel name and each channel is an isolated session.

OpenClaw on Discord is the channel post this setup belongs to, and OpenClaw Discord access control the allowlist model the guild workspace is built on.

One channel, one session

The private-server pattern is the reason the setup is worth the extra steps: a coding channel, a home channel and a research channel each become a separate agent session with the channel name as context, which no DM-only setup can give you. OpenClaw ambient room events covers the lurk mode that makes a shared always-on room bearable, and Connect your first channel in five minutes the shorter walkthrough for a first channel.

On Diali

On Diali the Discord channel is connected from the dashboard and the runtime config is generated from it and replaced at each release, so the portal steps at the top of this post are the part that stays on your side. Discord on Diali describes the channel on Diali and Diali security the boundary every connected channel shares.

  • Three intents, five permissions, three IDs, one token.
  • Pairing codes expire after an hour; the token never goes in chat.
  • A private server makes every channel its own session.
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.