@bobotu/feishu-fork 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +922 -0
  3. package/index.ts +65 -0
  4. package/openclaw.plugin.json +10 -0
  5. package/package.json +72 -0
  6. package/skills/feishu-doc/SKILL.md +161 -0
  7. package/skills/feishu-doc/references/block-types.md +102 -0
  8. package/skills/feishu-drive/SKILL.md +96 -0
  9. package/skills/feishu-perm/SKILL.md +90 -0
  10. package/skills/feishu-task/SKILL.md +210 -0
  11. package/skills/feishu-wiki/SKILL.md +96 -0
  12. package/src/accounts.ts +140 -0
  13. package/src/bitable-tools/actions.ts +199 -0
  14. package/src/bitable-tools/common.ts +90 -0
  15. package/src/bitable-tools/index.ts +1 -0
  16. package/src/bitable-tools/meta.ts +80 -0
  17. package/src/bitable-tools/register.ts +195 -0
  18. package/src/bitable-tools/schemas.ts +221 -0
  19. package/src/bot.ts +1125 -0
  20. package/src/channel.ts +334 -0
  21. package/src/client.ts +114 -0
  22. package/src/config-schema.ts +237 -0
  23. package/src/dedup.ts +54 -0
  24. package/src/directory.ts +165 -0
  25. package/src/doc-tools/actions.ts +341 -0
  26. package/src/doc-tools/common.ts +33 -0
  27. package/src/doc-tools/index.ts +2 -0
  28. package/src/doc-tools/register.ts +90 -0
  29. package/src/doc-tools/schemas.ts +85 -0
  30. package/src/doc-write-service.ts +711 -0
  31. package/src/drive-tools/actions.ts +182 -0
  32. package/src/drive-tools/common.ts +18 -0
  33. package/src/drive-tools/index.ts +2 -0
  34. package/src/drive-tools/register.ts +71 -0
  35. package/src/drive-tools/schemas.ts +67 -0
  36. package/src/dynamic-agent.ts +135 -0
  37. package/src/external-keys.ts +19 -0
  38. package/src/media.ts +510 -0
  39. package/src/mention.ts +121 -0
  40. package/src/monitor.ts +323 -0
  41. package/src/onboarding.ts +449 -0
  42. package/src/outbound.ts +40 -0
  43. package/src/perm-tools/actions.ts +111 -0
  44. package/src/perm-tools/common.ts +18 -0
  45. package/src/perm-tools/index.ts +2 -0
  46. package/src/perm-tools/register.ts +65 -0
  47. package/src/perm-tools/schemas.ts +52 -0
  48. package/src/policy.ts +117 -0
  49. package/src/probe.ts +147 -0
  50. package/src/reactions.ts +160 -0
  51. package/src/reply-dispatcher.ts +240 -0
  52. package/src/runtime.ts +14 -0
  53. package/src/send.ts +391 -0
  54. package/src/streaming-card.ts +211 -0
  55. package/src/targets.ts +58 -0
  56. package/src/task-tools/actions.ts +590 -0
  57. package/src/task-tools/common.ts +18 -0
  58. package/src/task-tools/constants.ts +13 -0
  59. package/src/task-tools/index.ts +1 -0
  60. package/src/task-tools/register.ts +263 -0
  61. package/src/task-tools/schemas.ts +567 -0
  62. package/src/text/markdown-links.ts +104 -0
  63. package/src/tools-common/feishu-api.ts +184 -0
  64. package/src/tools-common/tool-context.ts +23 -0
  65. package/src/tools-common/tool-exec.ts +73 -0
  66. package/src/tools-config.ts +22 -0
  67. package/src/types.ts +79 -0
  68. package/src/typing.ts +75 -0
  69. package/src/wiki-tools/actions.ts +166 -0
  70. package/src/wiki-tools/common.ts +18 -0
  71. package/src/wiki-tools/index.ts +2 -0
  72. package/src/wiki-tools/register.ts +66 -0
  73. package/src/wiki-tools/schemas.ts +55 -0
package/README.md ADDED
@@ -0,0 +1,922 @@
1
+ # clawd-feishu
2
+
3
+ Feishu/Lark (飞书) channel plugin for [OpenClaw](https://github.com/openclaw/openclaw).
4
+
5
+ > **中文社区资料** - 配置教程、常见问题、使用技巧:[Wiki](https://github.com/m1heng/clawdbot-feishu/wiki)
6
+ >
7
+ > **Contributing / 贡献指南**: [CONTRIBUTING.md](./CONTRIBUTING.md)
8
+ >
9
+ > **Issue Reporting / 问题反馈**: Please check [Discussions](https://github.com/m1heng/clawdbot-feishu/discussions) first for common solutions, then open a structured Issue Form if needed.
10
+ > 问题反馈前请先查看 [Discussions](https://github.com/m1heng/clawdbot-feishu/discussions) 是否已有常见解答;如仍未解决,再提交结构化 Issue 模板。
11
+ >
12
+ > **Questions / 使用咨询**: Use `Question` issue for troubleshooting; use [Discussions](https://github.com/m1heng/clawdbot-feishu/discussions) for open-ended Q&A.
13
+ > 排查型咨询请提交 `Question` Issue;开放式交流请使用 [Discussions](https://github.com/m1heng/clawdbot-feishu/discussions)。
14
+
15
+ [English](#english) | [中文](#中文)
16
+
17
+ ---
18
+
19
+ ## English
20
+
21
+ ### Installation
22
+
23
+ ```bash
24
+ openclaw plugins install @m1heng-clawd/feishu
25
+ ```
26
+
27
+ > [!IMPORTANT]
28
+ > **Windows Troubleshooting (`spawn npm ENOENT`)**
29
+ >
30
+ > If `openclaw plugins install` fails, install manually:
31
+ >
32
+ > ```bash
33
+ > # 1. Download the package
34
+ > curl -O https://registry.npmjs.org/@m1heng-clawd/feishu/-/feishu-0.1.3.tgz
35
+ >
36
+ > # 2. Install from local file
37
+ > openclaw plugins install ./feishu-0.1.3.tgz
38
+ > ```
39
+
40
+ ### Upgrade
41
+
42
+ ```bash
43
+ openclaw plugins update feishu
44
+ ```
45
+
46
+ ### Configuration
47
+
48
+ 1. Create a self-built app on [Feishu Open Platform](https://open.feishu.cn)
49
+ 2. Get your App ID and App Secret from the Credentials page
50
+ 3. Enable required permissions (see below)
51
+ 4. **Configure event subscriptions** (see below) ⚠️ Important
52
+ 5. Configure the plugin:
53
+
54
+ #### Required Permissions
55
+
56
+ | Permission | Scope | Description |
57
+ |------------|-------|-------------|
58
+ | `im:message` | Messaging | Send and receive messages |
59
+ | `im:message.p2p_msg:readonly` | DM | Read direct messages to bot |
60
+ | `im:message.group_at_msg:readonly` | Group | Receive @mention messages in groups |
61
+ | `im:message:send_as_bot` | Send | Send messages as the bot |
62
+ | `im:resource` | Media | Upload and download images/files |
63
+
64
+ #### Optional Permissions
65
+
66
+ | Permission | Scope | Description |
67
+ |------------|-------|-------------|
68
+ | `contact:user.base:readonly` | User info | Get basic user info (required to resolve sender display names for speaker attribution) |
69
+ | `im:message.group_msg` | Group | Read all group messages (sensitive) |
70
+ | `im:message:readonly` | Read | Get message history |
71
+ | `im:message:update` | Edit | Update/edit sent messages |
72
+ | `im:message:recall` | Recall | Recall sent messages |
73
+ | `im:message.reactions:read` | Reactions | View message reactions |
74
+
75
+ #### Tool Permissions
76
+
77
+ **Read-only** (minimum required):
78
+
79
+ | Permission | Tool | Description |
80
+ |------------|------|-------------|
81
+ | `docx:document:readonly` | `feishu_doc` | Read documents |
82
+ | `drive:drive:readonly` | `feishu_drive` | List folders, get file info |
83
+ | `wiki:wiki:readonly` | `feishu_wiki` | List spaces, list nodes, get node info, search |
84
+ | `bitable:app:readonly` | `feishu_bitable` | Read bitable records and fields |
85
+ | `task:task:read` | `feishu_task_get` | Get task details |
86
+ | `task:tasklist:read` | `feishu_tasklist_get`, `feishu_tasklist_list` | Get/list tasklists |
87
+ | `task:comment:read` | `feishu_task_comment_list`, `feishu_task_comment_get` | List/get task comments |
88
+ | `task:attachment:read` | `feishu_task_attachment_list`, `feishu_task_attachment_get` | List/get task attachments |
89
+
90
+ **Read-write** (optional, for create/edit/delete operations):
91
+
92
+ | Permission | Tool | Description |
93
+ |------------|------|-------------|
94
+ | `docx:document` | `feishu_doc` | Create/edit documents |
95
+ | `docx:document.block:convert` | `feishu_doc` | Markdown to blocks conversion (required for write/append/create_and_write; also used by `feishu_drive.import_document`) |
96
+ | `drive:drive` | `feishu_doc`, `feishu_drive` | Upload images to documents, create folders, move/delete files |
97
+ | `wiki:wiki` | `feishu_wiki` | Create/move/rename wiki nodes |
98
+ | `bitable:app` | `feishu_bitable` | Create/update/delete bitable records and manage fields |
99
+ | `task:task:write` | `feishu_task_create`, `feishu_task_subtask_create`, `feishu_task_update`, `feishu_task_delete` | Create/update/delete tasks |
100
+ | `task:tasklist:write` | `feishu_tasklist_create`, `feishu_tasklist_update`, `feishu_tasklist_delete`, `feishu_tasklist_add_members`, `feishu_tasklist_remove_members`, `feishu_task_add_tasklist`, `feishu_task_remove_tasklist` | Create/update/delete tasklists and manage membership |
101
+ | `task:comment:write` | `feishu_task_comment_create`, `feishu_task_comment_update`, `feishu_task_comment_delete` | Create/update/delete task comments |
102
+ | `task:attachment:write` | `feishu_task_attachment_upload`, `feishu_task_attachment_delete` | Upload/delete task attachments |
103
+
104
+ > Task scope names may vary slightly in Feishu console UI. If needed, search for Task / Tasklist / Comment / Attachment-related permissions and grant read/write accordingly.
105
+
106
+ #### Task Comment Scopes ⚠️
107
+
108
+ Task comments require dedicated scopes:
109
+ 1. Read comments: grant `task:comment:read`.
110
+ 2. Create/update/delete comments: grant `task:comment:write`.
111
+
112
+ If these scopes are missing, comment APIs will return permission-denied errors.
113
+
114
+ #### Task Attachment Upload ⚠️
115
+
116
+ Task attachments support upload/get/list/delete. Upload sources:
117
+ 1. Local files on the OpenClaw/Node host (`file_path`)
118
+ 2. Remote links (`file_url`, public or presigned)
119
+
120
+ For `file_url`, OpenClaw runtime media loader is used with safety checks and size limit (`mediaMaxMb`), then the downloaded file is uploaded via a temporary local file.
121
+
122
+ #### Tasklist Ownership ⚠️
123
+
124
+ > **Important:** Keep tasklist owner as the bot. Add users as members instead.
125
+
126
+ Tasklist access is granted based on owner + member roles. If you change the owner to a user and the bot is not a member, the bot may lose permission to read/edit/manage that tasklist (and subsequent operations will fail).
127
+
128
+ #### Task Visibility & Subtasks ⚠️
129
+
130
+ > **Important:** A user can only view a task when they are included as an assignee.
131
+ >
132
+ > **Limitation:** The bot can currently only create subtasks for tasks created by itself.
133
+
134
+ To avoid “task created but not visible” issues:
135
+ 1. When creating a task, set the requesting user as an assignee.
136
+ 2. If you need more flexible subtask organization/visibility, consider using tasklists.
137
+
138
+ #### Drive Access ⚠️
139
+
140
+ > **Important:** Bots don't have their own "My Space" (root folder). Bots can only access files/folders that have been **shared with them**.
141
+
142
+ To let the bot manage files:
143
+ 1. Create a folder in your Feishu Drive
144
+ 2. Right-click the folder → **Share** → search for your bot name
145
+ 3. Grant appropriate permission (view/edit)
146
+
147
+ Without this step, `feishu_drive` operations like `create_folder` will fail because the bot has no root folder to create in.
148
+
149
+ #### Wiki Space Access ⚠️
150
+
151
+ > **Important:** API permissions alone are not enough for wiki access. You must also add the bot to each wiki space.
152
+
153
+ 1. Open the wiki space you want the bot to access
154
+ 2. Click **Settings** (gear icon) → **Members**
155
+ 3. Click **Add Member** → search for your bot name
156
+ 4. Select appropriate permission level (view/edit)
157
+
158
+ Without this step, `feishu_wiki` will return empty results even with correct API permissions.
159
+
160
+ Reference: [Wiki FAQ - How to add app to wiki](https://open.feishu.cn/document/server-docs/docs/wiki-v2/wiki-qa#a40ad4ca)
161
+
162
+ #### Bitable Access ⚠️
163
+
164
+ > **Important:** Like other resources, the bot can only access bitables that have been **shared with it**.
165
+
166
+ To let the bot access a bitable:
167
+ 1. Open the bitable you want the bot to access
168
+ 2. Click **Share** button → search for your bot name
169
+ 3. Grant appropriate permission (view/edit)
170
+
171
+ The `feishu_bitable` tools support both URL formats:
172
+ - `/base/XXX?table=YYY` - Standard bitable URL
173
+ - `/wiki/XXX?table=YYY` - Bitable embedded in wiki (auto-converts to app_token)
174
+
175
+ #### Event Subscriptions ⚠️
176
+
177
+ > **This is the most commonly missed configuration!** If the bot can send messages but cannot receive them, check this section.
178
+
179
+ In the Feishu Open Platform console, go to **Events & Callbacks**:
180
+
181
+ 1. **Event configuration**: Select the subscription mode matching your `connectionMode`:
182
+ - **Long connection** — for `connectionMode: "websocket"` (recommended, no public URL needed)
183
+ - **Request URL** — for `connectionMode: "webhook"` (requires a publicly accessible URL)
184
+ 2. **Add event subscriptions**:
185
+
186
+ | Event | Description |
187
+ |-------|-------------|
188
+ | `im.message.receive_v1` | Receive messages (required) |
189
+ | `im.message.message_read_v1` | Message read receipts |
190
+ | `im.chat.member.bot.added_v1` | Bot added to group |
191
+ | `im.chat.member.bot.deleted_v1` | Bot removed from group |
192
+
193
+ 3. Ensure the event permissions are approved
194
+
195
+ ```bash
196
+ openclaw config set channels.feishu.appId "cli_xxxxx"
197
+ openclaw config set channels.feishu.appSecret "your_app_secret"
198
+ openclaw config set channels.feishu.enabled true
199
+ ```
200
+
201
+ ### Configuration Options
202
+
203
+ ```yaml
204
+ channels:
205
+ feishu:
206
+ enabled: true
207
+ appId: "cli_xxxxx"
208
+ appSecret: "secret"
209
+ # Domain: "feishu" (China), "lark" (International), or custom URL
210
+ domain: "feishu" # or "https://open.xxx.cn" for private deployment
211
+ # Connection mode: "websocket" (recommended) or "webhook"
212
+ connectionMode: "websocket"
213
+ # DM policy: "pairing" | "open" | "allowlist"
214
+ dmPolicy: "pairing"
215
+ # DM allowlist (open_id/user_id). Include "*" when dmPolicy="open"
216
+ allowFrom: []
217
+ # Group policy: "open" | "allowlist" | "disabled"
218
+ groupPolicy: "allowlist"
219
+ # Require @mention in groups
220
+ requireMention: true
221
+ # Group command mention bypass: "never" | "single_bot" | "always"
222
+ # Default "single_bot": allow authorized command-only messages without @
223
+ # only when the group has a single bot.
224
+ groupCommandMentionBypass: "single_bot"
225
+ # Max media size in MB (default: 30)
226
+ mediaMaxMb: 30
227
+ # Render mode for bot replies: "auto" | "raw" | "card"
228
+ renderMode: "auto"
229
+ ```
230
+
231
+ #### DM Policy & Access Control
232
+
233
+ `dmPolicy` controls who can interact with the bot in direct messages (DM).
234
+ In multi-account mode, this is resolved per account (`channels.feishu.accounts.<accountId>`).
235
+
236
+ | `dmPolicy` | Who can send DM | How to grant access to a user |
237
+ |------------|------------------|--------------------------------|
238
+ | `pairing` | Users in `allowFrom`, or users approved through pairing | User sends a DM and gets a pairing code; bot owner runs `openclaw pairing approve feishu <code>`. |
239
+ | `open` | Everyone | Set `allowFrom: ["*"]` so all users are treated as allowed. |
240
+ | `allowlist` | Only users in `allowFrom` | Add the user's `open_id`/`user_id` to `allowFrom`, then reload config. |
241
+
242
+ Notes:
243
+ - `allowFrom` accepts Feishu user IDs (`open_id` recommended, `user_id` also supported).
244
+ - If `dmPolicy: "open"`, use `allowFrom: ["*"]`. This is required by top-level schema validation and keeps access behavior explicit.
245
+ - `pairing` and `allowlist` can both pre-authorize users with `allowFrom`.
246
+
247
+ Pairing flow (owner approval):
248
+ 1. User sends any DM to the bot.
249
+ 2. Bot replies with a pairing code (for example `H9ZEHY8R`).
250
+ 3. Bot owner approves:
251
+
252
+ ```bash
253
+ openclaw pairing approve feishu H9ZEHY8R
254
+ ```
255
+
256
+ 4. The user is added to the allow store and can chat immediately.
257
+
258
+ Example: open to everyone
259
+
260
+ ```yaml
261
+ channels:
262
+ feishu:
263
+ dmPolicy: "open"
264
+ allowFrom: ["*"]
265
+ ```
266
+
267
+ Example: controlled rollout (pairing + pre-approved users)
268
+
269
+ ```yaml
270
+ channels:
271
+ feishu:
272
+ dmPolicy: "pairing"
273
+ allowFrom:
274
+ - "ou_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
275
+ ```
276
+
277
+ Example: strict allowlist
278
+
279
+ ```yaml
280
+ channels:
281
+ feishu:
282
+ dmPolicy: "allowlist"
283
+ allowFrom:
284
+ - "ou_alice"
285
+ - "ou_bob"
286
+ ```
287
+
288
+ Example: account-level isolation
289
+
290
+ ```yaml
291
+ channels:
292
+ feishu:
293
+ accounts:
294
+ lobster-1:
295
+ dmPolicy: "open"
296
+ allowFrom: ["*"]
297
+ lobster-5:
298
+ dmPolicy: "pairing"
299
+ ```
300
+
301
+ Top-level `channels.feishu.dmPolicy` / `channels.feishu.allowFrom` are fallback defaults for accounts that do not override them.
302
+
303
+ > `dmPolicy` only controls who can trigger the bot.
304
+ > To actually read/write docs or files, you still need: (1) correct Feishu app scopes, and (2) sharing the target resources (Drive/Wiki/Bitable) with the bot.
305
+
306
+ #### Group Command Mention Bypass
307
+
308
+ When `requireMention: true`, Feishu can still allow authorized control commands (such as `/new`) without `@bot`.
309
+
310
+ | `groupCommandMentionBypass` | Behavior |
311
+ |----------------------------|----------|
312
+ | `never` | Never bypass `@` requirement for group commands. |
313
+ | `single_bot` | Bypass only when the group contains at most one bot (default). |
314
+ | `always` | Always allow authorized control commands to bypass mention gating. |
315
+
316
+ Notes:
317
+ - Bypass only applies to authorized control commands in group chats.
318
+ - If any user is explicitly `@`-mentioned in the same message, bypass is disabled.
319
+ - In DMs, this setting does not apply.
320
+
321
+ #### Connection Mode
322
+
323
+ Two connection modes are available for receiving events from Feishu:
324
+
325
+ | Mode | Description |
326
+ |------|-------------|
327
+ | `websocket` | (Default, recommended) Long-polling WebSocket connection. No public URL required, works behind NAT/firewall. Best for local development and most deployments. |
328
+ | `webhook` | HTTP server that receives event callbacks. Requires a publicly accessible URL. Suitable for server deployments behind a reverse proxy (e.g. Nginx). |
329
+
330
+ **WebSocket mode** (default, no extra config needed):
331
+
332
+ ```yaml
333
+ channels:
334
+ feishu:
335
+ connectionMode: "websocket" # or just omit this line
336
+ ```
337
+
338
+ In Feishu console: Events & Callbacks → select **Long connection**.
339
+
340
+ **Webhook mode**:
341
+
342
+ ```yaml
343
+ channels:
344
+ feishu:
345
+ connectionMode: "webhook"
346
+ webhookPort: 3000 # HTTP server port (default: 3000)
347
+ webhookPath: "/feishu/events" # Event callback path (default: "/feishu/events")
348
+ encryptKey: "your_encrypt_key" # From Feishu console → Events & Callbacks → Encrypt Key
349
+ verificationToken: "your_verify_token" # From Feishu console → Events & Callbacks → Verification Token
350
+ ```
351
+
352
+ In Feishu console: Events & Callbacks → select **Request URL** → set the URL to:
353
+
354
+ ```
355
+ https://your-domain.com/feishu/events
356
+ ```
357
+
358
+ > **Note:** The Request URL must be HTTPS and publicly accessible. For local development, you can use tools like [ngrok](https://ngrok.com) to create a tunnel: `ngrok http 3000`, then use the generated URL.
359
+
360
+ #### Render Mode
361
+
362
+ | Mode | Description |
363
+ |------|-------------|
364
+ | `auto` | (Default) Automatically detect: use card for messages with code blocks or tables, plain text otherwise. |
365
+ | `raw` | Always send replies as plain text. Markdown tables are converted to ASCII. |
366
+ | `card` | Always send replies as interactive cards with full markdown rendering (syntax highlighting, tables, clickable links). |
367
+
368
+ #### Dynamic Agent Creation (Multi-User Workspace Isolation)
369
+
370
+ When enabled, each DM user automatically gets their own isolated agent instance with a dedicated workspace. This provides complete isolation including separate conversation history, memory (MEMORY.md), and workspace files.
371
+
372
+ ```yaml
373
+ channels:
374
+ feishu:
375
+ dmPolicy: "open"
376
+ allowFrom: ["*"]
377
+ dynamicAgentCreation:
378
+ enabled: true
379
+ # Template for workspace directory ({userId} = OpenID, {agentId} = generated agent ID)
380
+ workspaceTemplate: "~/workspaces/feishu-{agentId}"
381
+ # Template for agent config directory
382
+ agentDirTemplate: "~/.openclaw/agents/{agentId}/agent"
383
+ # Optional: limit total number of dynamic agents
384
+ maxAgents: 100
385
+
386
+ session:
387
+ # Also set dmScope for session isolation (conversation history)
388
+ dmScope: "per-peer"
389
+ ```
390
+
391
+ | Option | Description |
392
+ |--------|-------------|
393
+ | `enabled` | Enable dynamic agent creation for DM users |
394
+ | `workspaceTemplate` | Template for workspace path. Supports `{userId}` (OpenID) and `{agentId}` (= `feishu-{openId}`) |
395
+ | `agentDirTemplate` | Template for agent directory path |
396
+ | `maxAgents` | Optional limit on number of dynamic agents |
397
+
398
+ **How it works:**
399
+ 1. When a new user sends a DM, the system creates a new agent entry in `openclaw.json`
400
+ 2. A binding is created to route that user's DM to their dedicated agent
401
+ 3. Workspace and agent directories are created automatically
402
+ 4. Subsequent messages from that user go to their isolated agent
403
+
404
+ **Difference from `dmScope: "per-peer"`:**
405
+ - `dmScope: "per-peer"` only isolates conversation history
406
+ - `dynamicAgentCreation` provides full isolation (workspace, memory, identity, tools)
407
+
408
+ ### Features
409
+
410
+ - WebSocket and Webhook connection modes
411
+ - Direct messages and group chats
412
+ - Message replies and quoted message context
413
+ - **Inbound media support**: AI can see images, read files (PDF, Excel, etc.), and process rich text with embedded images
414
+ - Image and file uploads (outbound)
415
+ - Typing indicator (via emoji reactions)
416
+ - Pairing flow for DM approval
417
+ - User and group directory lookup
418
+ - **Card render mode**: Optional markdown rendering with syntax highlighting
419
+ - **Document tools**: Read, create, and write Feishu documents with markdown, including atomic `create_and_write` / `import_document` flows for reliable create+content write
420
+ - **Wiki tools**: Navigate knowledge bases, list spaces, get node details, search, create/move/rename nodes
421
+ - **Drive tools**: List folders, get file info, create folders, move/delete files
422
+ - **Bitable tools**: Manage bitable (多维表格) fields and records (read/create/update/delete), supports both `/base/` and `/wiki/` URLs
423
+ - **Task tools**: Create, get details, update, and delete tasks via Feishu Task v2 API
424
+ - **@mention forwarding**: When you @mention someone in your message, the bot's reply will automatically @mention them too
425
+ - **Permission error notification**: When the bot encounters a Feishu API permission error, it automatically notifies the user with the permission grant URL
426
+ - **Dynamic agent creation**: Each DM user can have their own isolated agent instance with dedicated workspace (optional)
427
+
428
+ #### @Mention Forwarding
429
+
430
+ When you want the bot to @mention someone in its reply, simply @mention them in your message:
431
+
432
+ - **In DM**: `@张三 say hello` → Bot replies with `@张三 Hello!`
433
+ - **In Group**: `@bot @张三 say hello` → Bot replies with `@张三 Hello!`
434
+
435
+ The bot automatically detects @mentions in your message and includes them in its reply. No extra permissions required beyond the standard messaging permissions.
436
+
437
+ ### FAQ
438
+
439
+ #### Bot cannot receive messages
440
+
441
+ Check the following:
442
+ 1. Have you configured **event subscriptions**? (See Event Subscriptions section)
443
+ 2. Does the event subscription mode match your `connectionMode`?
444
+ - `websocket` → **Long connection** in Feishu console
445
+ - `webhook` → **Request URL** in Feishu console (URL must be reachable)
446
+ 3. Did you add the `im.message.receive_v1` event?
447
+ 4. Are the permissions approved?
448
+ 5. For webhook mode: is your server running and the URL publicly accessible?
449
+
450
+ #### 403 error when sending messages
451
+
452
+ Ensure `im:message:send_as_bot` permission is approved.
453
+
454
+ #### How to clear history / start new conversation
455
+
456
+ Send `/new` command in the chat.
457
+
458
+ #### Why is the output not streaming
459
+
460
+ Feishu API has rate limits. Streaming updates can easily trigger throttling. We use complete-then-send approach for stability.
461
+
462
+ #### Cannot find the bot in Feishu
463
+
464
+ 1. Ensure the app is published (at least to test version)
465
+ 2. Search for the bot name in Feishu search box
466
+ 3. Check if your account is in the app's availability scope
467
+
468
+ ---
469
+
470
+ ## 中文
471
+
472
+ ### 安装
473
+
474
+ ```bash
475
+ openclaw plugins install @m1heng-clawd/feishu
476
+ ```
477
+
478
+ > [!IMPORTANT]
479
+ > **Windows 排错(`spawn npm ENOENT`)**
480
+ >
481
+ > 如果 `openclaw plugins install` 失败,可以手动安装:
482
+ >
483
+ > ```bash
484
+ > # 1. 下载插件包
485
+ > curl -O https://registry.npmjs.org/@m1heng-clawd/feishu/-/feishu-0.1.3.tgz
486
+ >
487
+ > # 2. 从本地安装
488
+ > openclaw plugins install ./feishu-0.1.3.tgz
489
+ > ```
490
+
491
+ ### 升级
492
+
493
+ ```bash
494
+ openclaw plugins update feishu
495
+ ```
496
+
497
+ ### 配置
498
+
499
+ 1. 在 [飞书开放平台](https://open.feishu.cn) 创建自建应用
500
+ 2. 在凭证页面获取 App ID 和 App Secret
501
+ 3. 开启所需权限(见下方)
502
+ 4. **配置事件订阅**(见下方)⚠️ 重要
503
+ 5. 配置插件:
504
+
505
+ #### 必需权限
506
+
507
+ | 权限 | 范围 | 说明 |
508
+ |------|------|------|
509
+ | `im:message` | 消息 | 发送和接收消息 |
510
+ | `im:message.p2p_msg:readonly` | 私聊 | 读取发给机器人的私聊消息 |
511
+ | `im:message.group_at_msg:readonly` | 群聊 | 接收群内 @机器人 的消息 |
512
+ | `im:message:send_as_bot` | 发送 | 以机器人身份发送消息 |
513
+ | `im:resource` | 媒体 | 上传和下载图片/文件 |
514
+
515
+ #### 可选权限
516
+
517
+ | 权限 | 范围 | 说明 |
518
+ |------|------|------|
519
+ | `contact:user.base:readonly` | 用户信息 | 获取用户基本信息(用于解析发送者姓名,避免群聊/私聊把不同人当成同一说话者) |
520
+ | `im:message.group_msg` | 群聊 | 读取所有群消息(敏感) |
521
+ | `im:message:readonly` | 读取 | 获取历史消息 |
522
+ | `im:message:update` | 编辑 | 更新/编辑已发送消息 |
523
+ | `im:message:recall` | 撤回 | 撤回已发送消息 |
524
+ | `im:message.reactions:read` | 表情 | 查看消息表情回复 |
525
+
526
+ #### 工具权限
527
+
528
+ **只读权限**(最低要求):
529
+
530
+ | 权限 | 工具 | 说明 |
531
+ |------|------|------|
532
+ | `docx:document:readonly` | `feishu_doc` | 读取文档 |
533
+ | `drive:drive:readonly` | `feishu_drive` | 列出文件夹、获取文件信息 |
534
+ | `wiki:wiki:readonly` | `feishu_wiki` | 列出空间、列出节点、获取节点详情、搜索 |
535
+ | `bitable:app:readonly` | `feishu_bitable` | 读取多维表格记录和字段 |
536
+ | `task:task:read` | `feishu_task_get` | 获取任务详情 |
537
+ | `task:tasklist:read` | `feishu_tasklist_get`, `feishu_tasklist_list` | 获取/列出任务清单(tasklists) |
538
+ | `task:comment:read` | `feishu_task_comment_list`, `feishu_task_comment_get` | 列出/获取任务评论 |
539
+ | `task:attachment:read` | `feishu_task_attachment_list`, `feishu_task_attachment_get` | 列出/获取任务附件 |
540
+
541
+ **读写权限**(可选,用于创建/编辑/删除操作):
542
+
543
+ | 权限 | 工具 | 说明 |
544
+ |------|------|------|
545
+ | `docx:document` | `feishu_doc` | 创建/编辑文档 |
546
+ | `docx:document.block:convert` | `feishu_doc` | Markdown 转 blocks(write/append/create_and_write 必需,`feishu_drive.import_document` 也会用到) |
547
+ | `drive:drive` | `feishu_doc`, `feishu_drive` | 上传图片到文档、创建文件夹、移动/删除文件 |
548
+ | `wiki:wiki` | `feishu_wiki` | 创建/移动/重命名知识库节点 |
549
+ | `bitable:app` | `feishu_bitable` | 创建/更新/删除多维表格记录并管理字段 |
550
+ | `task:task:write` | `feishu_task_create`, `feishu_task_subtask_create`, `feishu_task_update`, `feishu_task_delete` | 创建/更新/删除任务 |
551
+ | `task:tasklist:write` | `feishu_tasklist_create`, `feishu_tasklist_update`, `feishu_tasklist_delete`, `feishu_tasklist_add_members`, `feishu_tasklist_remove_members`, `feishu_task_add_tasklist`, `feishu_task_remove_tasklist` | 创建/更新/删除任务清单并管理成员/关联任务 |
552
+ | `task:comment:write` | `feishu_task_comment_create`, `feishu_task_comment_update`, `feishu_task_comment_delete` | 创建/更新/删除任务评论 |
553
+ | `task:attachment:write` | `feishu_task_attachment_upload`, `feishu_task_attachment_delete` | 上传/删除任务附件 |
554
+
555
+ > 飞书控制台中任务权限的显示名称可能略有差异,必要时可按关键字 `task` / `tasklist` / `comment` / `attachment` 搜索并授予对应读写权限。
556
+
557
+ #### 任务评论权限 ⚠️
558
+
559
+ 任务评论需要单独授权:
560
+ 1. 读取评论:授予 `task:comment:read`。
561
+ 2. 创建/更新/删除评论:授予 `task:comment:write`。
562
+
563
+ 缺少上述权限时,评论相关接口会返回权限不足错误。
564
+
565
+ #### 任务附件上传 ⚠️
566
+
567
+ 任务附件支持上传/获取/列表/删除。上传来源:
568
+ 1. OpenClaw/Node 所在机器的本地文件路径(`file_path`)
569
+ 2. 可直接下载的远程链接(`file_url`,公开/预签名 URL)
570
+
571
+ `file_url` 上传路径会使用 OpenClaw 运行时的媒体下载安全校验与大小限制(`mediaMaxMb`),随后经临时本地文件上传到任务附件。
572
+
573
+ #### 任务清单所有者限制 ⚠️
574
+
575
+ > **重要:** 创建/修改任务清单时,请保持清单所有者为机器人本身,只把用户作为协作人添加。
576
+
577
+ 任务清单权限基于“所有者 + 协作成员角色”授予。如果把清单所有者改成用户、且机器人不在协作成员中,机器人可能会失去对该清单的读取/编辑/管理权限,导致后续对清单的操作失败。
578
+
579
+ #### 任务限制 ⚠️
580
+
581
+ > **重要:** 只有当任务责任人包含用户时,用户才能查看到该任务。
582
+ >
583
+ > **限制:** 机器人目前只能给自己创建出来的任务创建子任务。
584
+
585
+ 为避免“任务创建了但用户看不到”的问题:
586
+ 1. 创建任务时,请把发起用户设为任务负责人(`assignee`)。
587
+ 2. 如需更灵活的子任务创建/组织/可见性管理,建议使用任务清单(tasklists)。
588
+
589
+ #### 云空间访问权限 ⚠️
590
+
591
+ > **重要:** 机器人没有自己的"我的空间"(根目录)。机器人只能访问**被分享给它的文件/文件夹**。
592
+
593
+ 要让机器人管理文件:
594
+ 1. 在你的飞书云空间创建一个文件夹
595
+ 2. 右键文件夹 → **分享** → 搜索机器人名称
596
+ 3. 授予相应权限(查看/编辑)
597
+
598
+ 如果不做这一步,`feishu_drive` 的 `create_folder` 等操作会失败,因为机器人没有根目录可以创建文件夹。
599
+
600
+ #### 知识库空间权限 ⚠️
601
+
602
+ > **重要:** 仅有 API 权限不够,还需要将机器人添加到知识库空间。
603
+
604
+ 1. 打开需要机器人访问的知识库空间
605
+ 2. 点击 **设置**(齿轮图标)→ **成员管理**
606
+ 3. 点击 **添加成员** → 搜索机器人名称
607
+ 4. 选择权限级别(查看/编辑)
608
+
609
+ 如果不做这一步,即使 API 权限正确,`feishu_wiki` 也会返回空结果。
610
+
611
+ 参考文档:[知识库常见问题 - 如何将应用添加为知识库成员](https://open.feishu.cn/document/server-docs/docs/wiki-v2/wiki-qa#a40ad4ca)
612
+
613
+ #### 多维表格访问权限 ⚠️
614
+
615
+ > **重要:** 与其他资源一样,机器人只能访问**被分享给它的多维表格**。
616
+
617
+ 要让机器人访问多维表格:
618
+ 1. 打开需要机器人访问的多维表格
619
+ 2. 点击 **分享** 按钮 → 搜索机器人名称
620
+ 3. 授予相应权限(查看/编辑)
621
+
622
+ `feishu_bitable` 工具支持两种 URL 格式:
623
+ - `/base/XXX?table=YYY` - 标准多维表格链接
624
+ - `/wiki/XXX?table=YYY` - 嵌入在知识库中的多维表格(自动转换为 app_token)
625
+
626
+ #### 事件订阅 ⚠️
627
+
628
+ > **这是最容易遗漏的配置!** 如果机器人能发消息但收不到消息,请检查此项。
629
+
630
+ 在飞书开放平台的应用后台,进入 **事件与回调** 页面:
631
+
632
+ 1. **事件配置方式**:根据你的 `connectionMode` 选择对应的订阅方式:
633
+ - **使用长连接接收事件** — 对应 `connectionMode: "websocket"`(推荐,无需公网地址)
634
+ - **使用请求地址接收事件** — 对应 `connectionMode: "webhook"`(需要公网可访问的 URL)
635
+ 2. **添加事件订阅**,勾选以下事件:
636
+
637
+ | 事件 | 说明 |
638
+ |------|------|
639
+ | `im.message.receive_v1` | 接收消息(必需) |
640
+ | `im.message.message_read_v1` | 消息已读回执 |
641
+ | `im.chat.member.bot.added_v1` | 机器人进群 |
642
+ | `im.chat.member.bot.deleted_v1` | 机器人被移出群 |
643
+
644
+ 3. 确保事件订阅的权限已申请并通过审核
645
+
646
+ ```bash
647
+ openclaw config set channels.feishu.appId "cli_xxxxx"
648
+ openclaw config set channels.feishu.appSecret "your_app_secret"
649
+ openclaw config set channels.feishu.enabled true
650
+ ```
651
+
652
+ ### 配置选项
653
+
654
+ ```yaml
655
+ channels:
656
+ feishu:
657
+ enabled: true
658
+ appId: "cli_xxxxx"
659
+ appSecret: "secret"
660
+ # 域名: "feishu" (国内)、"lark" (国际) 或自定义 URL
661
+ domain: "feishu" # 私有化部署可用 "https://open.xxx.cn"
662
+ # 连接模式: "websocket" (推荐) 或 "webhook"
663
+ connectionMode: "websocket"
664
+ # 私聊策略: "pairing" | "open" | "allowlist"
665
+ dmPolicy: "pairing"
666
+ # 私聊白名单(open_id/user_id);当 dmPolicy="open" 时请包含 "*"
667
+ allowFrom: []
668
+ # 群聊策略: "open" | "allowlist" | "disabled"
669
+ groupPolicy: "allowlist"
670
+ # 群聊是否需要 @机器人
671
+ requireMention: true
672
+ # 群聊命令绕过 @ 策略: "never" | "single_bot" | "always"
673
+ # 默认 "single_bot":仅当群内机器人数量 <= 1 时,允许已授权命令免 @
674
+ groupCommandMentionBypass: "single_bot"
675
+ # 媒体文件最大大小 (MB, 默认 30)
676
+ mediaMaxMb: 30
677
+ # 回复渲染模式: "auto" | "raw" | "card"
678
+ renderMode: "auto"
679
+ ```
680
+
681
+ #### 私聊策略(dmPolicy)与访问授权
682
+
683
+ `dmPolicy` 控制的是“谁可以在私聊里触发机器人”。
684
+ 在多账号模式下,它按账号生效(`channels.feishu.accounts.<accountId>`)。
685
+
686
+ | `dmPolicy` | 谁能私聊触发机器人 | 如何给用户开通 |
687
+ |------------|------------------|----------------|
688
+ | `pairing` | `allowFrom` 中的用户,或已通过配对审批的用户 | 用户先私聊机器人拿到配对码;管理员执行 `openclaw pairing approve feishu <code>`。 |
689
+ | `open` | 所有人 | 配置 `allowFrom: ["*"]`,表示全部放开。 |
690
+ | `allowlist` | 仅 `allowFrom` 中的用户 | 将用户 `open_id`/`user_id` 加入 `allowFrom`,然后重载配置。 |
691
+
692
+ 说明:
693
+ - `allowFrom` 支持飞书用户 ID(推荐 `open_id`,也支持 `user_id`)。
694
+ - 当 `dmPolicy: "open"` 时,建议固定写 `allowFrom: ["*"]`,语义最清晰,也满足顶层配置校验要求。
695
+ - `pairing` 和 `allowlist` 都可以先通过 `allowFrom` 预授权部分用户。
696
+
697
+ 配对审批流程(pairing):
698
+ 1. 用户先给机器人发一条私聊消息。
699
+ 2. 机器人返回配对码(例如 `H9ZEHY8R`)。
700
+ 3. 管理员执行审批命令:
701
+
702
+ ```bash
703
+ openclaw pairing approve feishu H9ZEHY8R
704
+ ```
705
+
706
+ 4. 审批后该用户立即可用。
707
+
708
+ 示例:全部放开
709
+
710
+ ```yaml
711
+ channels:
712
+ feishu:
713
+ dmPolicy: "open"
714
+ allowFrom: ["*"]
715
+ ```
716
+
717
+ 示例:灰度放开(pairing + 预授权)
718
+
719
+ ```yaml
720
+ channels:
721
+ feishu:
722
+ dmPolicy: "pairing"
723
+ allowFrom:
724
+ - "ou_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
725
+ ```
726
+
727
+ 示例:严格白名单
728
+
729
+ ```yaml
730
+ channels:
731
+ feishu:
732
+ dmPolicy: "allowlist"
733
+ allowFrom:
734
+ - "ou_alice"
735
+ - "ou_bob"
736
+ ```
737
+
738
+ 示例:按账号隔离配置
739
+
740
+ ```yaml
741
+ channels:
742
+ feishu:
743
+ accounts:
744
+ lobster-1:
745
+ dmPolicy: "open"
746
+ allowFrom: ["*"]
747
+ lobster-5:
748
+ dmPolicy: "pairing"
749
+ ```
750
+
751
+ `channels.feishu.dmPolicy` / `channels.feishu.allowFrom` 是“默认值”;账号下未覆盖时才会继承。
752
+
753
+ > `dmPolicy` 只控制“是否允许触发机器人”。
754
+ > 真正执行文档/云盘/知识库/多维表格操作,还需要两层权限:1)应用 API 权限(scopes);2)把目标资源分享给机器人。
755
+
756
+ #### 群聊命令免 @ 策略
757
+
758
+ 当 `requireMention: true` 时,Feishu 仍可让“已授权控制命令(如 `/new`)”在不 `@bot` 的情况下通过。
759
+
760
+ | `groupCommandMentionBypass` | 行为 |
761
+ |----------------------------|------|
762
+ | `never` | 群聊命令永不绕过 `@` 校验。 |
763
+ | `single_bot` | 仅当群内机器人数量不超过 1 个时才允许绕过(默认)。 |
764
+ | `always` | 已授权控制命令始终可绕过 `@` 校验。 |
765
+
766
+ 说明:
767
+ - 仅对群聊中的“已授权控制命令”生效。
768
+ - 同一条消息里如果显式 `@` 了任意用户,则不会触发命令免 `@`。
769
+ - 私聊场景不受该配置影响。
770
+
771
+ #### 连接模式
772
+
773
+ 支持两种从飞书接收事件的连接模式:
774
+
775
+ | 模式 | 说明 |
776
+ |------|------|
777
+ | `websocket` | (默认,推荐)长连接 WebSocket 模式。无需公网地址,可在 NAT/防火墙后使用。适合本地开发和大部分部署场景。 |
778
+ | `webhook` | HTTP 服务器接收事件回调。需要公网可访问的 URL。适合通过反向代理(如 Nginx)部署的服务器环境。 |
779
+
780
+ **WebSocket 模式**(默认,无需额外配置):
781
+
782
+ ```yaml
783
+ channels:
784
+ feishu:
785
+ connectionMode: "websocket" # 或直接省略此行
786
+ ```
787
+
788
+ 飞书控制台:事件与回调 → 选择 **使用长连接接收事件**。
789
+
790
+ **Webhook 模式**:
791
+
792
+ ```yaml
793
+ channels:
794
+ feishu:
795
+ connectionMode: "webhook"
796
+ webhookPort: 3000 # HTTP 服务端口(默认: 3000)
797
+ webhookPath: "/feishu/events" # 事件回调路径(默认: "/feishu/events")
798
+ encryptKey: "your_encrypt_key" # 飞书控制台 → 事件与回调 → Encrypt Key
799
+ verificationToken: "your_verify_token" # 飞书控制台 → 事件与回调 → Verification Token
800
+ ```
801
+
802
+ 飞书控制台:事件与回调 → 选择 **使用请求地址接收事件** → 填入请求地址:
803
+
804
+ ```
805
+ https://your-domain.com/feishu/events
806
+ ```
807
+
808
+ > **提示:** 请求地址必须是 HTTPS 且公网可访问。本地开发时,可使用 [ngrok](https://ngrok.com) 等工具创建隧道:`ngrok http 3000`,然后使用生成的地址。
809
+
810
+ #### 渲染模式
811
+
812
+ | 模式 | 说明 |
813
+ |------|------|
814
+ | `auto` | (默认)自动检测:有代码块或表格时用卡片,否则纯文本 |
815
+ | `raw` | 始终纯文本,表格转为 ASCII |
816
+ | `card` | 始终使用卡片,支持语法高亮、表格、链接等 |
817
+
818
+ #### 动态 Agent 创建(多用户 Workspace 隔离)
819
+
820
+ 启用后,每个私聊用户会自动获得独立的 agent 实例和专属 workspace。这提供完整的隔离,包括独立的对话历史、记忆(MEMORY.md)和工作区文件。
821
+
822
+ ```yaml
823
+ channels:
824
+ feishu:
825
+ dmPolicy: "open"
826
+ allowFrom: ["*"]
827
+ dynamicAgentCreation:
828
+ enabled: true
829
+ # workspace 目录模板 ({userId} = OpenID, {agentId} = 生成的 agent ID)
830
+ workspaceTemplate: "~/workspaces/feishu-{agentId}"
831
+ # agent 配置目录模板
832
+ agentDirTemplate: "~/.openclaw/agents/{agentId}/agent"
833
+ # 可选:限制动态 agent 总数
834
+ maxAgents: 100
835
+
836
+ session:
837
+ # 同时设置 dmScope 以隔离对话历史
838
+ dmScope: "per-peer"
839
+ ```
840
+
841
+ | 选项 | 说明 |
842
+ |------|------|
843
+ | `enabled` | 是否为私聊用户启用动态 agent 创建 |
844
+ | `workspaceTemplate` | workspace 路径模板,支持 `{userId}`(OpenID)和 `{agentId}`(= `feishu-{openId}`)|
845
+ | `agentDirTemplate` | agent 目录路径模板 |
846
+ | `maxAgents` | 可选,限制动态 agent 的最大数量 |
847
+
848
+ **工作原理:**
849
+ 1. 当新用户发送私聊时,系统在 `openclaw.json` 中创建新的 agent 条目
850
+ 2. 创建 binding 将该用户的私聊路由到专属 agent
851
+ 3. 自动创建 workspace 和 agent 目录
852
+ 4. 该用户后续的消息都会路由到其隔离的 agent
853
+
854
+ **与 `dmScope: "per-peer"` 的区别:**
855
+ - `dmScope: "per-peer"` 仅隔离对话历史
856
+ - `dynamicAgentCreation` 提供完整隔离(workspace、记忆、身份、工具)
857
+
858
+ ### 功能
859
+
860
+ - WebSocket 和 Webhook 连接模式
861
+ - 私聊和群聊
862
+ - 消息回复和引用上下文
863
+ - **入站媒体支持**:AI 可以看到图片、读取文件(PDF、Excel 等)、处理富文本中的嵌入图片
864
+ - 图片和文件上传(出站)
865
+ - 输入指示器(通过表情回复实现)
866
+ - 私聊配对审批流程
867
+ - 用户和群组目录查询
868
+ - **卡片渲染模式**:支持语法高亮的 Markdown 渲染
869
+ - **文档工具**:读取、创建、用 Markdown 写入飞书文档(表格因 API 限制不支持)
870
+ - **知识库工具**:浏览知识库、列出空间、获取节点详情、搜索、创建/移动/重命名节点
871
+ - **云空间工具**:列出文件夹、获取文件信息、创建文件夹、移动/删除文件
872
+ - **多维表格工具**:支持多维表格字段与记录的读取/创建/更新/删除,支持 `/base/` 和 `/wiki/` 两种链接格式
873
+ - **任务工具**:基于 Task v2 API 支持任务创建、获取详情、更新和删除
874
+ - **@ 转发功能**:在消息中 @ 某人,机器人的回复会自动 @ 该用户
875
+ - **权限错误提示**:当机器人遇到飞书 API 权限错误时,会自动通知用户并提供权限授权链接
876
+ - **动态 Agent 创建**:每个私聊用户可拥有独立的 agent 实例和专属 workspace(可选)
877
+
878
+ #### @ 转发功能
879
+
880
+ 如果你希望机器人的回复中 @ 某人,只需在你的消息中 @ 他们:
881
+
882
+ - **私聊**:`@张三 跟他问好` → 机器人回复 `@张三 你好!`
883
+ - **群聊**:`@机器人 @张三 跟他问好` → 机器人回复 `@张三 你好!`
884
+
885
+ 机器人会自动检测消息中的 @ 并在回复时带上。无需额外权限。
886
+
887
+ ### 常见问题
888
+
889
+ #### 机器人收不到消息
890
+
891
+ 检查以下配置:
892
+ 1. 是否配置了 **事件订阅**?(见上方事件订阅章节)
893
+ 2. 事件订阅方式是否与 `connectionMode` 匹配?
894
+ - `websocket` → 飞书控制台选择 **使用长连接接收事件**
895
+ - `webhook` → 飞书控制台选择 **使用请求地址接收事件**(URL 必须可访问)
896
+ 3. 是否添加了 `im.message.receive_v1` 事件?
897
+ 4. 相关权限是否已申请并审核通过?
898
+ 5. 如果使用 webhook 模式:服务是否正在运行?URL 是否公网可访问?
899
+
900
+ #### 返回消息时 403 错误
901
+
902
+ 确保已申请 `im:message:send_as_bot` 权限,并且权限已审核通过。
903
+
904
+ #### 如何清理历史会话 / 开启新对话
905
+
906
+ 在聊天中发送 `/new` 命令即可开启新对话。
907
+
908
+ #### 消息为什么不是流式输出
909
+
910
+ 飞书 API 有请求频率限制,流式更新消息很容易触发限流。当前采用完整回复后一次性发送的方式,以保证稳定性。
911
+
912
+ #### 在飞书里找不到机器人
913
+
914
+ 1. 确保应用已发布(至少发布到测试版本)
915
+ 2. 在飞书搜索框中搜索机器人名称
916
+ 3. 检查应用可用范围是否包含你的账号
917
+
918
+ ---
919
+
920
+ ## License
921
+
922
+ MIT