Source Code
Lark Integration
Connect Lark (Feishu) to OpenClaw for bidirectional messaging with full rich content support.
Quick Start
# 1. Set credentials
echo "FEISHU_APP_ID=cli_xxx" >> ~/.openclaw/workspace/.env
mkdir -p ~/.openclaw/secrets
echo "your_app_secret" > ~/.openclaw/secrets/feishu_app_secret
# 2. Start bridge
cd skills/lark-integration/scripts
node bridge-webhook.mjs
# 3. Configure Lark webhook URL in developer console
# https://open.larksuite.com โ Your App โ Event Subscriptions
# URL: http://YOUR_SERVER_IP:3000/webhook
Architecture
Lark App โโwebhookโโโบ Bridge (port 3000) โโWebSocketโโโบ OpenClaw Gateway
โ โ
โโโโโโโโโโโ Reply โโโโโโโโโโโโโโโโโโโ
Supported Message Types
| Type | Direction | Format |
|---|---|---|
text |
โ Both | Plain text |
post |
โ Receive | Rich text with images, links |
image |
โ Receive | Single image |
| Reply | โ Send | Text (cards via feishu-card skill) |
Platform Detection
The bridge auto-detects platform from URLs:
*.larksuite.comโhttps://open.larksuite.com(International)*.feishu.cnโhttps://open.feishu.cn(China)
Configuration
Environment Variables
| Variable | Required | Description |
|---|---|---|
FEISHU_APP_ID |
Yes | App ID from Lark Developer Console |
FEISHU_APP_SECRET_PATH |
No | Path to secret file (default: ~/.openclaw/secrets/feishu_app_secret) |
WEBHOOK_PORT |
No | Webhook listen port (default: 3000) |
FEISHU_THINKING_THRESHOLD_MS |
No | Delay before "Thinking..." placeholder (default: 2500) |
FEISHU_ENCRYPT_KEY |
No | Encryption key if enabled in Lark |
OPENCLAW_AGENT_ID |
No | Agent to route messages to (default: main) |
Lark App Permissions
Enable these scopes in Lark Developer Console โ Permissions & Scopes:
Messaging:
im:message- Send and receive messagesim:message:send_as_bot- Send messages as botim:resource- Download message resources (images)
Documents (optional):
docx:document:readonly- Read documentswiki:wiki:readonly- Read wiki spacessheets:spreadsheet:readonly- Read spreadsheetsbitable:bitable:readonly- Read bitablesdrive:drive:readonly- Access drive files
Scripts
bridge-webhook.mjs
Main webhook bridge. Receives Lark events, forwards to OpenClaw, sends replies.
FEISHU_APP_ID=cli_xxx node scripts/bridge-webhook.mjs
setup-service.mjs
Install as systemd service for auto-start:
node scripts/setup-service.mjs
# Creates /etc/systemd/system/lark-bridge.service
Image Handling
Images in messages are:
- Detected from
postcontent orimagemessage type - Downloaded via Lark API using
message_idandimage_key - Converted to base64
- Sent to OpenClaw Gateway as
attachmentsparameter
attachments: [{ mimeType: "image/png", content: "<base64>" }]
Group Chat Behavior
In group chats, the bridge responds when:
- Bot is @mentioned
- Message ends with
?or๏ผ - Message contains trigger words: help, please, why, how, what, ๅธฎ, ่ฏท, ๅๆ, etc.
- Message starts with bot name
Otherwise, messages are ignored to avoid noise.
Reading Documents
Use the feishu-doc skill to read Lark documents:
node skills/feishu-doc/index.js fetch "https://xxx.larksuite.com/docx/TOKEN"
Supported URL types:
/docx/- New documents/wiki/- Wiki pages (auto-resolves to underlying doc)/sheets/- Spreadsheets/base/- Bitables (multi-dimensional tables)
Permission Note: Documents must be shared with the bot, or the bot must have tenant-wide read permission.
Troubleshooting
"forBidden" error when reading docs
- Document not shared with bot โ Add bot as collaborator
- Missing scope โ Enable
docx:document:readonlyin console
No messages received
- Check webhook URL is accessible:
curl http://YOUR_IP:3000/health - Verify webhook in Lark console shows "Verified"
- Check bridge logs:
journalctl -u lark-bridge -f
"must be string" error
- Old bridge version โ Update to use
attachmentsfor images
Images not received
- Missing
im:resourcescope โ Enable in Lark console - Token expired โ Bridge auto-refreshes, restart if stuck
Service Management
# Check status
systemctl status lark-bridge
# View logs
journalctl -u lark-bridge -f
# Restart
systemctl restart lark-bridge
References
- Lark Developer Console (International)
- Feishu Developer Console (China)
- See
references/api-formats.mdfor message format details - See
references/setup-guide.mdfor step-by-step setup