|
115 | 115 |  |
116 | 116 | {: .browser-mockup} |
117 | 117 |
|
118 | | -## 4. Feishu Channel Configuration |
| 118 | +Discord Channel Configuration |
| 119 | + |
| 120 | +## 4. Discord Channel Configuration |
119 | 121 |
|
120 | 122 | !!! note "" |
121 | | - Up to this point, OpenClaw has been fully deployed. Next, we will configure the Feishu channel. To configure the Feishu channel, we first need to create an available robot in Feishu. Follow the steps below to complete the configuration step by step. |
| 123 | +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. |
122 | 124 |
|
123 | | - Note: A personal Feishu account is used in this guide. For enterprise accounts, version release and permission authorization require administrator approval, while other operation steps remain the same. |
| 125 | +!!! note "" |
| 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. |
124 | 127 |
|
125 | | -### 4.1. Step 1: Create a Custom Enterprise App |
| 128 | +### 4.1. Step 1: Create a Discord Application and Bot User |
126 | 129 |
|
127 | 130 | !!! note "" |
128 | | - First, log in to Feishu and enter the Feishu Open Platform (link: https://open.feishu.cn/app), then access the "Developer Console" and select "Custom Apps", click "Create Custom App", as shown in the figure below. |
| 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 |
|
130 | | - |
131 | | -{: .browser-mockup} |
| 133 | +!!! note "" |
| 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. |
132 | 135 |
|
133 | 136 | !!! note "" |
134 | | - As shown in the figure below, enter the relevant app name and basic information as required and click "Create". |
| 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. |
135 | 138 |
|
136 | | - |
137 | | -{: .browser-mockup} |
| 139 | +### 4.2. Step 2: Enable Required Privileged Gateway Intents |
138 | 140 |
|
139 | | -### 4.2. Step 2: Create a Bot |
| 141 | +!!! note "" |
| 142 | +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: |
140 | 143 |
|
141 | 144 | !!! note "" |
142 | | - As shown in the figure below, click to create a bot to complete the bot creation process. |
| 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". |
143 | 146 |
|
144 | | - |
145 | | -{: .browser-mockup} |
| 147 | +!!! note "" |
| 148 | +- Server Members Intent (Recommended): Required for member/user search and allowlist matching in servers. |
146 | 149 |
|
147 | 150 | !!! note "" |
148 | | - After entering the bot page, click the edit button after bot configuration to define the bot name, as shown in the figure below: |
| 151 | +You usually do not need to enable "Presence Intent". |
149 | 152 |
|
150 | | - |
151 | | -{: .browser-mockup} |
| 153 | +### 4.3. Step 3: Generate Invite URL and Add Bot to Server |
152 | 154 |
|
153 | | -### 4.3. Step 3: Permission Configuration |
| 155 | +!!! note "" |
| 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: |
154 | 157 |
|
155 | 158 | !!! note "" |
156 | | - After creating the bot, click to enter "Permissions & Scopes" and then click "Batch import/export scopes". |
| 159 | +#### Scopes |
157 | 160 |
|
158 | | - |
159 | | -{: .browser-mockup} |
| 161 | +- ✅ bot |
| 162 | + |
| 163 | +- ✅ applications.commands (Required for native slash commands) |
160 | 164 |
|
161 | 165 | !!! note "" |
162 | | - Click "Batch import/export scopes", clear the default permission configuration information, copy and paste the permission authorization script as shown below, and click "Save". |
| 166 | +#### Bot Permissions (Minimum Baseline) |
163 | 167 |
|
164 | | -```json |
165 | | -{ |
166 | | - "scopes": { |
167 | | - "tenant": [ |
168 | | - "aily:file:read", |
169 | | - "aily:file:write", |
170 | | - "application:application.app_message_stats.overview:readonly", |
171 | | - "application:application.self_manage", |
172 | | - "application:bot.menu:write", |
173 | | - "cardkit:card:write", |
174 | | - "contact:contact.base:readonly", |
175 | | - "contact:user.employee_id:readonly", |
176 | | - "corehr:file:download", |
177 | | - "docs:document.content:read", |
178 | | - "event:ip_list", |
179 | | - "im:chat", |
180 | | - "im:chat.access_event.bot_p2p_chat:read", |
181 | | - "im:chat.members:bot_access", |
182 | | - "im:message", |
183 | | - "im:message.group_at_msg:readonly", |
184 | | - "im:message.group_msg", |
185 | | - "im:message.p2p_msg:readonly", |
186 | | - "im:message:readonly", |
187 | | - "im:message:send_as_bot", |
188 | | - "im:resource", |
189 | | - "sheets:spreadsheet", |
190 | | - "wiki:wiki:readonly" |
191 | | - ], |
192 | | - "user": [ |
193 | | - "aily:file:read", |
194 | | - "aily:file:write", |
195 | | - "contact:contact.base:readonly", |
196 | | - "im:chat.access_event.bot_p2p_chat:read" |
197 | | - ] |
198 | | - } |
199 | | -} |
200 | | -``` |
| 168 | +- ✅ View Channels |
201 | 169 |
|
202 | | -!!! note "" |
203 | | - The effect after pasting is shown in the figure below: |
| 170 | +- ✅ Send Messages |
204 | 171 |
|
205 | | - |
206 | | -{: .browser-mockup} |
| 172 | +- ✅ Read Message History |
| 173 | + |
| 174 | +- ✅ Embed Links |
| 175 | + |
| 176 | +- ✅ Attach Files |
| 177 | + |
| 178 | +- ✅ Add Reactions (Optional but recommended) |
| 179 | + |
| 180 | +- ✅ Use External Emojis / Stickers (Optional, only if needed) |
207 | 181 |
|
208 | 182 | !!! note "" |
209 | | - Click "Next, Review New Scopes" and finally ensure that all permissions are enabled. For personal accounts, confirm the permissions by yourself; for enterprise accounts, administrator review is required. Ensure all permissions are enabled as shown in the figure below: |
| 183 | +Note: Avoid enabling "Administrator" unless you are debugging and fully trust the bot.. |
210 | 184 |
|
211 | | - |
212 | | -{: .browser-mockup} |
| 185 | +!!! note "" |
| 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. |
213 | 187 |
|
214 | | -### 4.4. Step 4: Obtain Credentials and Configure in 1Panel |
| 188 | +### 4.4. Step 4: Enable Developer Mode and Obtain IDs (Optional) |
215 | 189 |
|
216 | 190 | !!! note "" |
217 | | - Enter the Feishu platform and obtain the app credentials in "Credentials & Basic Info", as shown in the figure below: |
| 191 | +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): |
218 | 192 |
|
219 | | - |
220 | | -{: .browser-mockup} |
| 193 | +!!! note "" |
| 194 | +1. Open Discord, click the gear icon in the lower left corner to enter "User Settings". |
221 | 195 |
|
222 | 196 | !!! note "" |
223 | | - After obtaining the credentials, enter the "Configuration" page of "Agent" in 1Panel, complete the Feishu chat channel configuration, and click "Save", as shown in the figure below: |
| 197 | +2. Select "Advanced" in the left navigation bar, then enable "Developer Mode". |
| 198 | + |
| 199 | +After enabling, you can right-click to copy the corresponding IDs: |
| 200 | + |
| 201 | +- Server Name → Copy Server ID (Guild ID) |
| 202 | + |
| 203 | +- Channel (e.g., #help) → Copy Channel ID |
| 204 | + |
| 205 | +- Your User Avatar → Copy User ID |
| 206 | + |
| 207 | +The operation page is shown in the figure below. |
| 208 | + |
| 209 | + |
224 | 210 |
|
225 | | - |
226 | 211 | {: .browser-mockup} |
227 | 212 |
|
228 | | -### 4.5. Step 5: Create Events and Callbacks |
| 213 | +### 4.5. Step 5: Configure OpenClaw for Discord Channel |
229 | 214 |
|
230 | 215 | !!! note "" |
231 | | - As shown in the figure below, enter the "Events & Callbacks" menu and complete the subscription method setting and event addition respectively. |
| 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. |
232 | 217 |
|
233 | | - |
234 | | -{: .browser-mockup} |
| 218 | +#### 4.5.1. Configuration via Environment Variable (Recommended for Servers) |
235 | 219 |
|
236 | | -#### Subscription Method Setting |
| 220 | +!!! note "" |
| 221 | +Set the environment variable with the bot token obtained in Step 1. The variable name is fixed as follows: |
237 | 222 |
|
238 | 223 | !!! note "" |
239 | | - Select the persistent connection subscription method as shown in the figure below: |
| 224 | +DISCORD_BOT_TOKEN=YOUR_BOT_TOKEN |
240 | 225 |
|
241 | | - |
242 | | -{: .browser-mockup} |
| 226 | +!!! note "" |
| 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). |
243 | 228 |
|
244 | | -#### Add Events: |
| 229 | +#### 4.5.2. Configuration via Configuration File |
245 | 230 |
|
246 | 231 | !!! note "" |
247 | | - Enter "im.message.receive_v1" to search, check "Receive messages" based on "App-based Subscription", and finally confirm the addition. |
| 232 | +Modify the OpenClaw configuration file and add the Discord channel configuration. The minimum configuration is as follows: |
248 | 233 |
|
249 | | - |
250 | | -{: .browser-mockup} |
| 234 | +''' |
| 235 | +{ |
| 236 | + "channels": { |
| 237 | + "discord": { |
| 238 | + "enabled": true, |
| 239 | + "token": "YOUR_BOT_TOKEN" |
| 240 | + } |
| 241 | + } |
| 242 | +} |
| 243 | +''' |
251 | 244 |
|
252 | | -### 4.6. Step 6: Create and Release a Version |
| 245 | +!!! note "" |
| 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: |
| 247 | + |
| 248 | +''' |
| 249 | +{ |
| 250 | + "channels": { |
| 251 | + "discord": { |
| 252 | + "enabled": true, |
| 253 | + "token": "abc.123", |
| 254 | + "groupPolicy": "allowlist", |
| 255 | + "mediaMaxMb": 8, |
| 256 | + "actions": { |
| 257 | + "reactions": true, |
| 258 | + "stickers": true, |
| 259 | + "emojiUploads": true, |
| 260 | + "stickerUploads": true, |
| 261 | + "polls": true, |
| 262 | + "permissions": true, |
| 263 | + "messages": true, |
| 264 | + "threads": true, |
| 265 | + "pins": true, |
| 266 | + "search": true, |
| 267 | + "memberInfo": true, |
| 268 | + "roleInfo": true, |
| 269 | + "roles": false, |
| 270 | + "channelInfo": true, |
| 271 | + "channels": true, |
| 272 | + "voiceStatus": true, |
| 273 | + "events": true, |
| 274 | + "moderation": false |
| 275 | + }, |
| 276 | + "replyToMode": "off", |
| 277 | + "dm": { |
| 278 | + "enabled": true, |
| 279 | + "policy": "pairing", |
| 280 | + "allowFrom": ["123456789012345678", "steipete"], |
| 281 | + "groupEnabled": false, |
| 282 | + "groupChannels": ["openclaw-dm"] |
| 283 | + }, |
| 284 | + "guilds": { |
| 285 | + "*": { "requireMention": true }, |
| 286 | + "123456789012345678": { |
| 287 | + "slug": "friends-of-openclaw", |
| 288 | + "requireMention": false, |
| 289 | + "reactionNotifications": "own", |
| 290 | + "users": ["987654321098765432", "steipete"], |
| 291 | + "channels": { |
| 292 | + "general": { "allow": true }, |
| 293 | + "help": { |
| 294 | + "allow": true, |
| 295 | + "requireMention": true, |
| 296 | + "users": ["987654321098765432"], |
| 297 | + "skills": ["search", "docs"], |
| 298 | + "systemPrompt": "Keep answers short." |
| 299 | + } |
| 300 | + } |
| 301 | + } |
| 302 | + } |
| 303 | + } |
| 304 | + } |
| 305 | +} |
| 306 | +''' |
253 | 307 |
|
254 | 308 | !!! note "" |
255 | | - After confirmation, click "Create Version", then enter the relevant version information as required and release it. No approval is required for personal accounts, while enterprise accounts need enterprise approval. |
| 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: |
| 310 | + |
| 311 | + |
256 | 312 |
|
257 | | - |
258 | 313 | {: .browser-mockup} |
259 | 314 |
|
260 | | -### 4.7. Step 7: Verify the Feishu Channel Configuration |
| 315 | +### 4.6. Step 6: Start Gateway and Verify Configuration |
261 | 316 |
|
262 | 317 | !!! note "" |
263 | | - After completing all the above configurations, open the app in the Feishu client as shown in the figure below: |
| 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): |
264 | 319 |
|
265 | | - |
266 | | -{: .browser-mockup} |
| 320 | +''' |
| 321 | +openclaw gateway |
| 322 | +''' |
267 | 323 |
|
268 | 324 | !!! note "" |
269 | | - Finally, perform a simple test. The prompt as shown in the figure below indicates that the configuration is successful. |
| 325 | +After starting the Gateway, verify whether the configuration is successful by following these steps: |
| 326 | + |
| 327 | +- 1. Open the Discord client and enter the server where the bot was added. |
| 328 | + |
| 329 | +- 2. In the target channel (e.g., #general), send a message mentioning the bot (e.g., @OpenClaw Bot hello). |
| 330 | + |
| 331 | +- 3. If the bot replies normally, it indicates that the configuration is successful. The test effect is shown in the figure below. |
| 332 | + |
| 333 | + |
270 | 334 |
|
271 | | - |
272 | 335 | {: .browser-mockup} |
273 | 336 |
|
| 337 | +### 4.7. Step 7: Troubleshooting (Common Issues) |
| 338 | + |
| 339 | +!!! note "" |
| 340 | +If the bot fails to work normally, first run the following commands to perform a quick audit and view warnings: |
| 341 | + |
| 342 | +''' |
| 343 | +openclaw doctor |
| 344 | +openclaw channels status --probe |
| 345 | +''' |
| 346 | + |
| 347 | +#### Common Issues and Solutions |
| 348 | + |
| 349 | +- "Used disallowed intents": Enable "Message Content Intent" (and "Server Members Intent" if needed) in the Discord Developer Portal, then restart the Gateway. |
| 350 | + |
| 351 | +- Bot connects but does not reply in server channels: Check if the bot has "View Channels", "Send Messages", and "Read Message History" permissions; ensure "Message Content Intent" is enabled; verify if the configuration requires mentioning the bot (requireMention: true) but you did not mention it; check if the server/channel allowlist rejects the current channel/user. |
| 352 | + |
| 353 | +- Private messages not working: Check if "channels.discord.dm.enabled" is false or "dm.policy" is "disabled"; if "dm.policy" is "pairing", you need to approve the pairing code first (run "openclaw pairing approve discord <code>"). |
| 354 | + |
| 355 | +- requireMention: false but no reply: The default "groupPolicy" is "allowlist"; set "channels.discord.groupPolicy" to "open" or add a server entry under "channels.discord.guilds". |
| 356 | + |
274 | 357 | # 6. Model Configuration Modification |
275 | 358 |
|
276 | 359 | !!! note "" |
|
0 commit comments