Install
openclaw skills install feishu-doc-collabEnable real-time AI collaboration in Feishu (Lark) documents. When a user edits a Feishu doc, the agent automatically detects the change, reads the document,...
openclaw skills install feishu-doc-collabTurn any Feishu document into a real-time human-AI collaboration space.
This skill patches OpenClaw's Feishu extension to detect document edit events and trigger isolated agent sessions. Combined with a structured in-document chat protocol, it enables:
drive.file.edit_v1 — document edit eventsdrive.file.bitable_record_changed_v1 — (optional) bitable record changesdrive.file.read_v1 — (optional, auto-ignored to suppress warnings)space:document:retrieve — read documentsdocx:document:readonly — read docx content (app-level)base:table:read — read bitable table structurebase:record:read — read bitable recordsbase:record:update — update bitable records (for task board)base:field:read — read bitable field definitionsdrive:drive:readonly — read drive file infoopenclaw.json:
{
"hooks": {
"enabled": true,
"token": "your-hooks-token-here"
}
}
Add the hooks section if not present:
# Generate a random token
TOKEN=$(openssl rand -hex 16)
echo "Your hooks token: $TOKEN"
# Then add to openclaw.json:
# "hooks": { "enabled": true, "token": "<TOKEN>" }
bash ./skills/feishu-doc-collab/scripts/patch-monitor.sh
This patches the Feishu extension's monitor.js (or monitor.ts for older installs) to:
drive.file.edit_v1 and bitable_record_changed_v1 events/hooks/agent with deliver: falsedrive.file.read_v1 events (suppress warnings)Edit ./skills/feishu-doc-collab/config.json:
{
"agent_name": "MyBot",
"agent_display_name": "My AI Assistant"
}
The patch script uses this to set up message routing (who the agent responds as).
openclaw gateway restart
Copy the protocol template to your workspace:
cp ./skills/feishu-doc-collab/assets/DOC_PROTOCOL_TEMPLATE.md ./DOC_PROTOCOL.md
Edit DOC_PROTOCOL.md to fill in your participant roster.
User edits Feishu doc
↓
Feishu sends drive.file.edit_v1 event
↓
Patched monitor.ts receives event
↓
Checks: is this the bot's own edit? → Yes: skip (anti-loop)
↓ No
Debounce: same file triggered within 30s? → Yes: skip
↓ No
POST /hooks/agent with deliver:false (isolated session)
↓
Agent reads DOC_PROTOCOL.md for message format
↓
Agent reads the document, finds last message block
↓
Checks: status=🟢? addressed to me? not from me?
↓ Yes
Agent composes reply and appends to document
Messages in the document follow this format:
---
> **Sender Name** → **Receiver Name** | 🟢 完成
Your message content here.
Status flags:
Routing:
→ AgentName — addressed to a specific AI agent→ all — broadcast to all participantsThis solves a critical problem: Feishu auto-saves continuously while typing, which would trigger multiple premature AI responses without the status flag mechanism.
For structured task management alongside document collaboration:
Create a Bitable with these fields:
Configure in config.json:
{
"bitable": {
"app_token": "your_bitable_app_token",
"table_id": "your_table_id"
}
}
The patch also handles bitable_record_changed_v1 events for task routing.
⚠️ OpenClaw or extension updates may overwrite monitor.js. After any update:
bash ./skills/feishu-doc-collab/scripts/patch-monitor.sh
openclaw gateway restart
The patch script is idempotent — safe to run multiple times.
Note: For the openclaw-lark extension (compiled .js), no jiti cache clearing is needed.
For older built-in .ts installs, also run: rm -f /tmp/jiti/src-monitor.*.cjs
| Field | Type | Required | Description |
|---|---|---|---|
agent_name | string | Yes | Internal name used in protocol routing |
agent_display_name | string | Yes | Display name shown in doc replies |
bitable.app_token | string | No | Bitable app token for task board |
bitable.table_id | string | No | Bitable table ID for task board |
The patch reads from ~/.openclaw/openclaw.json:
hooks.token — authentication for /hooks/agent endpointgateway.port — gateway port (default: 18789)Problem: Feishu sends multiple drive.file.edit_v1 and bitable_record_changed_v1 events
for a single logical edit. Bitable edits are especially bad — changing one record field can trigger
10-20+ events in rapid succession. Without debounce, each event spawns a separate isolated agent
session (using the full model), causing massive token waste.
Real-world impact: A single bitable task edit triggered 15+ Hook sessions consuming 350k+ tokens, all running in parallel and all reaching the same conclusion: "nothing to do".
Solution: 30-second debounce per fileToken (implemented in patch-monitor.sh v2):
Map<string, number> tracks the last trigger timestamp per file/table/hooks/agent call, so no session is createdBot self-edit loop: When the agent updates a bitable record (e.g., changing status to "处理完"),
that edit triggers MORE events. The bot self-edit check (comparing operator_id to botOpenId)
catches most of these, but the debounce provides a critical safety net for cases where the
operator ID doesn't match (e.g., API calls vs. bot identity).
Important: Already-running sessions cannot be stopped by debounce. If an event storm has already started, the sessions will run to completion. Debounce only prevents NEW triggers.
OpenClaw or extension updates may overwrite monitor.js. After any update:
bash ./skills/feishu-doc-collab/scripts/patch-monitor.sh
openclaw gateway restart
The patch script is idempotent — checks for both /hooks/agent and _editDebounce markers.
drive.file.edit_v1 event subscription approvalCreated by dongwei. Inspired by the need for real-time human-AI collaboration in Chinese enterprise workflows using Feishu/Lark.
MIT