You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
123
124
125
+
!!! note ""
124
126
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.
125
127
126
128
### 4.1. Step 1: Create a Discord Application and Bot User
127
129
130
+
!!! note ""
128
131
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.
129
132
133
+
!!! note ""
130
134
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.
131
135
136
+
!!! note ""
132
137
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.
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:
137
143
144
+
!!! note ""
138
145
- 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".
139
146
147
+
!!! note ""
140
148
- Server Members Intent (Recommended): Required for member/user search and allowlist matching in servers.
141
149
150
+
!!! note ""
142
151
You usually do not need to enable "Presence Intent".
143
152
144
153
### 4.3. Step 3: Generate Invite URL and Add Bot to Server
145
154
155
+
!!! note ""
146
156
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:
147
157
158
+
!!! note ""
148
159
#### Scopes
149
160
150
161
- ✅ bot
151
162
152
163
- ✅ applications.commands (Required for native slash commands)
153
164
165
+
!!! note ""
154
166
#### Bot Permissions (Minimum Baseline)
155
167
156
168
- ✅ View Channels
@@ -167,16 +179,21 @@ To make the bot work in your Discord server, you need to generate an invite URL
167
179
168
180
- ✅ Use External Emojis / Stickers (Optional, only if needed)
169
181
182
+
!!! note ""
170
183
Note: Avoid enabling "Administrator" unless you are debugging and fully trust the bot..
171
184
185
+
!!! note ""
172
186
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.
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):
177
192
193
+
!!! note ""
178
194
1. Open Discord, click the gear icon in the lower left corner to enter "User Settings".
179
195
196
+
!!! note ""
180
197
2. Select "Advanced" in the left navigation bar, then enable "Developer Mode".
181
198
182
199
After enabling, you can right-click to copy the corresponding IDs:
@@ -195,21 +212,26 @@ The operation page is shown in the figure below.
195
212
196
213
### 4.5. Step 5: Configure OpenClaw for Discord Channel
197
214
215
+
!!! note ""
198
216
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.
199
217
200
218
#### 4.5.1. Configuration via Environment Variable (Recommended for Servers)
201
219
220
+
!!! note ""
202
221
Set the environment variable with the bot token obtained in Step 1. The variable name is fixed as follows:
203
222
223
+
!!! note ""
204
224
DISCORD_BOT_TOKEN=YOUR_BOT_TOKEN
205
225
226
+
!!! note ""
206
227
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).
207
228
208
229
#### 4.5.2. Configuration via Configuration File
209
230
231
+
!!! note ""
210
232
Modify the OpenClaw configuration file and add the Discord channel configuration. The minimum configuration is as follows:
211
233
212
-
234
+
'''
213
235
{
214
236
"channels": {
215
237
"discord": {
@@ -218,11 +240,12 @@ Modify the OpenClaw configuration file and add the Discord channel configuration
218
240
}
219
241
}
220
242
}
221
-
243
+
'''
222
244
245
+
!!! note ""
223
246
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:
224
247
225
-
248
+
'''
226
249
{
227
250
"channels": {
228
251
"discord": {
@@ -280,8 +303,9 @@ For more advanced configurations (e.g., allowlist, server/channel restrictions,
280
303
}
281
304
}
282
305
}
283
-
306
+
'''
284
307
308
+
!!! note ""
285
309
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:
@@ -290,28 +314,35 @@ After completing the configuration, enter the "Configuration" page of "Agent" in
290
314
291
315
### 4.6. Step 6: Start Gateway and Verify Configuration
292
316
317
+
!!! note ""
293
318
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):
294
319
320
+
'''
295
321
openclaw gateway
322
+
'''
296
323
324
+
!!! note ""
297
325
After starting the Gateway, verify whether the configuration is successful by following these steps:
298
326
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.
300
328
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).
302
330
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.
0 commit comments