add-feishu
Original:🇺🇸 English
Translated
3 scriptsChecked / no sensitive code detected
Add Feishu (Lark) as a channel. Uses WebSocket long connection — no public URL or ngrok needed. Works alongside WhatsApp, Telegram, Slack, or as a standalone channel.
3installs
Added on
NPX Install
npx skill4agent add will-17173/nanoclaw-add-feishu-skill add-feishuTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Add Feishu Channel
This skill adds Feishu (飞书/Lark) support to NanoClaw using the skills engine for deterministic code changes, then walks through interactive setup.
Phase 1: Pre-flight
Check if already applied
Read . If is in , skip to Phase 3 (Setup). The code changes are already in place.
.nanoclaw/state.yamlfeishuapplied_skillsAsk the user
Use to collect configuration:
AskUserQuestionAskUserQuestion: Do you have a Feishu (Lark) app already created, or do you need to create one?
If they have one, ask for the App ID and App Secret. If not, walk them through creation in Phase 3.
Phase 2: Apply Code Changes
Run the skills engine to apply this skill's code package. The package files are in this directory alongside this SKILL.md.
Initialize skills system (if needed)
If directory doesn't exist yet:
.nanoclaw/bash
npx tsx scripts/apply-skill.ts --initApply the skill
bash
npx tsx scripts/apply-skill.ts .claude/skills/add-feishuThis deterministically:
- Adds (FeishuChannel class with self-registration via
src/channels/feishu.ts)registerChannel - Adds (unit tests)
src/channels/feishu.test.ts - Appends to the channel barrel file
import './feishu.js'src/channels/index.ts - Installs the npm dependency
@larksuiteoapi/node-sdk - Updates with
.env.exampleandFEISHU_APP_IDFEISHU_APP_SECRET - Records the application in
.nanoclaw/state.yaml
If the apply reports merge conflicts, read the intent file:
- — what changed and invariants
modify/src/channels/index.ts.intent.md
Validate code changes
bash
npm test
npm run buildAll tests must pass (including the new feishu tests) and build must be clean before proceeding.
Phase 3: Setup
Create Feishu App (if needed)
If the user doesn't have an app, tell them:
I need you to create a Feishu app:
- Go to Feishu Open Platform (or Lark Open Platform for international)
- Click Create App → Custom App
- Fill in app name and description (e.g., "NanoClaw Assistant")
- Go to Credentials & Basic Info — copy the App ID and App Secret
- Go to Event Subscriptions → Add Events → search and add:
(Receive messages — v2.0)im.message.receive_v1- Go to Permissions & Scopes → add the following permissions:
(Send & receive messages)im:message (Send messages as bot)im:message:send_as_bot (Read chat info)im:chat (Read chat members)im:chat.members:read- Go to Bot tab → enable the bot feature
- Click Publish / Apply for Release
Note: For enterprise use, your IT admin may need to approve the app.
Wait for the user to provide the App ID (format: ) and App Secret.
cli_xxxxxxxxxxxxxxxxxxConfigure environment
Add to :
.envbash
FEISHU_APP_ID=cli_xxxxxxxxxxxxxxxxxx
FEISHU_APP_SECRET=your_app_secret_hereChannels auto-enable when their credentials are present — no extra configuration needed.
Sync to container environment:
bash
mkdir -p data/env && cp .env data/env/envThe container reads environment from , not directly.
data/env/env.envBuild and restart
bash
npm run build
launchctl kickstart -k gui/$(id -u)/com.nanoclaw # macOS
# Linux: systemctl --user restart nanoclawPhase 4: Registration
Get Chat ID
Tell the user:
To register a Feishu chat with NanoClaw, I need the chat's ID:For a direct (p2p) chat:
- Add the bot to your Feishu contacts
- Open a direct message to the bot
- Send any message — NanoClaw will log the JID as
fs:p2p:<your_open_id>- Check
for:logs/nanoclaw.logMessage from unregistered Feishu chatFor a group chat:
- Add the bot to the group: Group Settings → Members → Add Bot
- Send any message in the group (or @mention the bot)
- NanoClaw will log the JID as
fs:oc_<chat_id>- Check
for:logs/nanoclaw.logMessage from unregistered Feishu chat
Tell user to check the log:
bash
tail -f logs/nanoclaw.log | grep "unregistered Feishu"Wait for the user to provide the JID (format: or ).
fs:oc_xxxxxfs:p2p:ou_xxxxxRegister the chat
For a main chat (responds to all messages):
typescript
registerGroup("fs:<chat-id>", {
name: "<chat-name>",
folder: "feishu_main",
trigger: `@${ASSISTANT_NAME}`,
added_at: new Date().toISOString(),
requiresTrigger: false,
isMain: true,
});For additional chats (trigger-based, responds only when @mentioned or triggered):
typescript
registerGroup("fs:<chat-id>", {
name: "<chat-name>",
folder: "feishu_<group-name>",
trigger: `@${ASSISTANT_NAME}`,
added_at: new Date().toISOString(),
requiresTrigger: true,
});Phase 5: Verify
Test the connection
Tell the user:
Send a message to your registered Feishu chat:
- For main chat: Any message works
- For non-main: @mention the bot or include a question/request keyword
The bot should respond within a few seconds.
Check logs if needed
bash
tail -f logs/nanoclaw.logTroubleshooting
Bot not receiving messages
Check:
- event is added in the app's Event Subscriptions
im.message.receive_v1 - App is published / enabled (enterprise apps need admin approval)
- For groups: the bot is added as a member of the group
- and
FEISHU_APP_IDare set inFEISHU_APP_SECRETAND synced to.envdata/env/env - Service is running: (macOS) or
launchctl list | grep nanoclaw(Linux)systemctl --user status nanoclaw
Bot not responding in groups
By default, NanoClaw only responds in groups when:
- The bot is @mentioned
- The message contains a request keyword (帮, 请, 分析, etc.)
- The message ends with ? or ?
To make the bot respond to all messages in a group, register it with .
requiresTrigger: false"Message from unregistered Feishu chat" in logs
This is normal — it means the bot is receiving messages, but the chat isn't registered yet. Follow Phase 4 to register.
Finding the JID
If the log message is hard to find:
bash
sqlite3 store/messages.db "SELECT DISTINCT chat_jid FROM chats WHERE channel = 'feishu'"App Secret security
The App Secret is sensitive. Store it only in and . Do NOT commit these files to version control.
.envdata/env/envJID Format Reference
| Chat type | JID format | Example |
|---|---|---|
| Group chat | | |
| Direct (p2p) | | |
After Setup
If running while the service is active:
npm run devbash
# macOS:
launchctl unload ~/Library/LaunchAgents/com.nanoclaw.plist
npm run dev
# When done testing:
launchctl load ~/Library/LaunchAgents/com.nanoclaw.plist
# Linux:
# systemctl --user stop nanoclaw
# npm run dev
# systemctl --user start nanoclawRemoval
To remove Feishu integration:
- Delete and
src/channels/feishu.tssrc/channels/feishu.test.ts - Remove from
import './feishu.js'src/channels/index.ts - Remove and
FEISHU_APP_IDfromFEISHU_APP_SECRET.env - Remove Feishu registrations from SQLite:
sqlite3 store/messages.db "DELETE FROM registered_groups WHERE jid LIKE 'fs:%'" - Uninstall:
npm uninstall @larksuiteoapi/node-sdk - Rebuild: (macOS) or
npm run build && launchctl kickstart -k gui/$(id -u)/com.nanoclaw(Linux)npm run build && systemctl --user restart nanoclaw