Skip to content

Commit fdc2168

Browse files
authored
Update agent.md
1 parent 0d7e13f commit fdc2168

1 file changed

Lines changed: 38 additions & 7 deletions

File tree

docs/user_manual/ai/agent.md

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,38 +119,50 @@ Discord Channel Configuration
119119

120120
## 4. Discord Channel Configuration
121121

122+
!!! note ""
122123
Up to this point, OpenClaw has been fully deployed. Next, we will configure the Discord channel. To configure the Discord channel, we first need to create an available bot in the Discord Developer Portal. Follow the steps below to complete the configuration step by step.
123124

125+
!!! note ""
124126
Note: This guide uses a personal Discord account. For server-level configurations involving enterprise or team servers, some permission settings may require server administrator approval, while other operation steps remain the same.
125127

126128
### 4.1. Step 1: Create a Discord Application and Bot User
127129

130+
!!! note ""
128131
First, log in to the Discord Developer Portal (link: https://discord.com/developers/applications), then click "New Application" in the upper right corner to create a new application.
129132

133+
!!! note ""
130134
Enter the application name (customizable, e.g., "OpenClaw Bot") and click "Create" to complete the application creation. Then, in the left navigation bar of the application page, select "Bot" and click "Add Bot" to create a bot user.
131135

136+
!!! note ""
132137
After creating the bot, click "Copy" under "Bot Token" to save the token (this token will be used in the subsequent OpenClaw configuration). Note: Keep the token confidential, as it is equivalent to the bot's access credential. If the token is leaked, click "Regenerate" to get a new one.
133138

134139
### 4.2. Step 2: Enable Required Privileged Gateway Intents
135140

141+
!!! note ""
136142
Discord blocks "Privileged Gateway Intents" by default; you need to explicitly enable the intents required by OpenClaw to ensure the bot can normally read and send messages. Under the "Bot" page, find the "Privileged Gateway Intents" section and enable the following two intents:
137143

144+
!!! note ""
138145
- Message Content Intent: Required to read message text in most servers; without it, the bot will connect but not respond to messages, and you may see the error "Used disallowed intents".
139146

147+
!!! note ""
140148
- Server Members Intent (Recommended): Required for member/user search and allowlist matching in servers.
141149

150+
!!! note ""
142151
You usually do not need to enable "Presence Intent".
143152

144153
### 4.3. Step 3: Generate Invite URL and Add Bot to Server
145154

155+
!!! note ""
146156
To make the bot work in your Discord server, you need to generate an invite URL and invite the bot to the target server. In the left navigation bar of the application page, select "OAuth2" → "URL Generator", then configure the scopes and bot permissions as follows:
147157

158+
!!! note ""
148159
#### Scopes
149160

150161
- ✅ bot
151162

152163
- ✅ applications.commands (Required for native slash commands)
153164

165+
!!! note ""
154166
#### Bot Permissions (Minimum Baseline)
155167

156168
- ✅ View Channels
@@ -167,16 +179,21 @@ To make the bot work in your Discord server, you need to generate an invite URL
167179

168180
- ✅ Use External Emojis / Stickers (Optional, only if needed)
169181

182+
!!! note ""
170183
Note: Avoid enabling "Administrator" unless you are debugging and fully trust the bot..
171184

185+
!!! note ""
172186
After completing the configuration, copy the generated URL, open it in a browser, select the target server where you want to add the bot, and click "Authorize" to complete the invitation. You may need to complete the human-machine verification during the process.
173187

174188
### 4.4. Step 4: Enable Developer Mode and Obtain IDs (Optional)
175189

190+
!!! note ""
176191
Discord uses numeric IDs for servers, users, and channels, which are preferred in OpenClaw configurations. To obtain these IDs, you need to enable Developer Mode in Discord (desktop/web version):
177192

193+
!!! note ""
178194
1. Open Discord, click the gear icon in the lower left corner to enter "User Settings".
179195

196+
!!! note ""
180197
2. Select "Advanced" in the left navigation bar, then enable "Developer Mode".
181198

182199
After enabling, you can right-click to copy the corresponding IDs:
@@ -195,21 +212,26 @@ The operation page is shown in the figure below.
195212

196213
### 4.5. Step 5: Configure OpenClaw for Discord Channel
197214

215+
!!! note ""
198216
After completing the Discord bot configuration, you need to set the bot token and related parameters in OpenClaw. There are two ways to configure it: using environment variables or modifying the configuration file. The configuration file method is recommended for more flexible settings.
199217

200218
#### 4.5.1. Configuration via Environment Variable (Recommended for Servers)
201219

220+
!!! note ""
202221
Set the environment variable with the bot token obtained in Step 1. The variable name is fixed as follows:
203222

223+
!!! note ""
204224
DISCORD_BOT_TOKEN=YOUR_BOT_TOKEN
205225

226+
!!! note ""
206227
Note: If both environment variables and configuration file settings are used, the configuration file settings take precedence (environment variables are only used as a fallback for the default account).
207228

208229
#### 4.5.2. Configuration via Configuration File
209230

231+
!!! note ""
210232
Modify the OpenClaw configuration file and add the Discord channel configuration. The minimum configuration is as follows:
211233

212-
234+
'''
213235
{
214236
"channels": {
215237
"discord": {
@@ -218,11 +240,12 @@ Modify the OpenClaw configuration file and add the Discord channel configuration
218240
}
219241
}
220242
}
221-
243+
'''
222244

245+
!!! note ""
223246
For more advanced configurations (e.g., allowlist, server/channel restrictions, private message settings), you can use the full configuration template as follows. Adjust the parameters according to your actual needs:
224247

225-
248+
'''
226249
{
227250
"channels": {
228251
"discord": {
@@ -280,8 +303,9 @@ For more advanced configurations (e.g., allowlist, server/channel restrictions,
280303
}
281304
}
282305
}
283-
306+
'''
284307

308+
!!! note ""
285309
After completing the configuration, enter the "Configuration" page of "Agent" in 1Panel, complete the Discord chat channel configuration, and click "Save", as shown in the figure below:
286310

287311
![img.png](../../img/ai/1Panel_OpenClaw_Discord_Channel_Config.png)
@@ -290,28 +314,35 @@ After completing the configuration, enter the "Configuration" page of "Agent" in
290314

291315
### 4.6. Step 6: Start Gateway and Verify Configuration
292316

317+
!!! note ""
293318
Start the OpenClaw Gateway. When the bot token is available (configuration file takes precedence, environment variable as fallback) and "channels.discord.enabled" is not false, the Discord channel will start automatically. Run the following command to start the Gateway (if not started automatically):
294319

320+
'''
295321
openclaw gateway
322+
'''
296323

324+
!!! note ""
297325
After starting the Gateway, verify whether the configuration is successful by following these steps:
298326

299-
1. Open the Discord client and enter the server where the bot was added.
327+
- 1. Open the Discord client and enter the server where the bot was added.
300328

301-
2. In the target channel (e.g., #general), send a message mentioning the bot (e.g., @OpenClaw Bot hello).
329+
- 2. In the target channel (e.g., #general), send a message mentioning the bot (e.g., @OpenClaw Bot hello).
302330

303-
3. If the bot replies normally, it indicates that the configuration is successful. The test effect is shown in the figure below.
331+
- 3. If the bot replies normally, it indicates that the configuration is successful. The test effect is shown in the figure below.
304332

305333
![img.png](../../img/ai/Discord_OpenClaw_Bot_Test_Page.png)
306334

307335
{: .browser-mockup}
308336

309337
### 4.7. Step 7: Troubleshooting (Common Issues)
310338

339+
!!! note ""
311340
If the bot fails to work normally, first run the following commands to perform a quick audit and view warnings:
312341

342+
'''
313343
openclaw doctor
314344
openclaw channels status --probe
345+
'''
315346

316347
#### Common Issues and Solutions
317348

0 commit comments

Comments
 (0)