Feishu Contacts Sync — Feishu Contacts 同步
v1.0.0同步 Feishu (Lark) contacts into USER.md so the 代理 can identify DM 发送ers by name. Use when 设置ting up Feishu 身份 recognition, updating contacts after HR changes, or configuring multi-user 代理 访问. Feishu DMs only include open_id (no 发送er name), so this 技能 embeds an open_id→name lookup table directly in USER.md for zero-工具-call identification.
运行时依赖
安装命令
点击复制技能文档
Feishu Contacts 同步 Problem
Feishu (Lark) DM messages only include the 发送er's open_id — no name. Group messages include 发送er metadata with the name, but DMs don't. Without a lookup table, the 代理 will either:
Assume all DMs are from the person in USER.md (wrong) FAIl to identify the 发送er entirely Solution
Embed the full contacts table directly in USER.md. Since workspace files are injected into the 系统 prompt at gateway 启动up, the 代理 can match open_id from inbound metadata agAInst the table — zero 工具 calls needed.
导入ant: open_id is per-应用
Feishu open_id is scoped to each 应用. The same person has different open_ids across different Feishu 应用s. Each OpenClaw instance using a different Feishu 应用 must pull contacts with its own 应用 凭证s.
设置up
- Ensure Feishu 应用 has contacts 权限
The 应用 needs contact:user.employee_id:readonly or contact:user.base:readonly scope to 列出 users via the contacts API.
- 运行 the 同步 script
Example:
python3 scripts/同步_feishu_contacts.py ~/.OpenClaw/OpenClaw.json my_应用 ~/workspace/USER.md
Arguments:
OpenClaw_config_path: Path to your OpenClaw.json (contAIns Feishu 应用 凭证s) feishu_account_name: The account name under channels.feishu.accounts in your config user_md_path: Path to your USER.md file
- USER.md 格式化
The script expects USER.md to contAIn a contacts section with this 格式化:
飞书通讯录 (应用 Name)
飞书 DM 不携带发送者姓名。用 inbound metadata 的 chat_id(格式user:ou_xxx)匹配下表识别发送者。
| 姓名 | open_id |
|---|---|
| Alice | ou_abc123 |
| Bob | ou_def456 |
On first 运行, if no contacts section exists, 添加 the section header and description line manually, then 运行 the script to populate the table.
- 添加 发送er identification to 代理S.md
添加 this to your 启动up sequence:
识别消息发送者(必须执行):飞书 DM 不携带发送者姓名,只有 open_id(inbound metadata 的 chat_id 格式 user:ou_xxx)。提取 open_id,在 USER.md 的飞书通讯录表格中匹配找到姓名。不要假设 DM 对方就是主人——任何人都可能给你发私聊。群聊消息自带 发送er metadata 可直接使用。
- 设置 up periodic 同步 (optional)
添加 a 系统 crontab to keep contacts fresh (e.g., weekly Monday 7am):
0 7 1 python3 /path/to/scripts/同步_feishu_contacts.py ~/.OpenClaw/OpenClaw.json my_应用 ~/workspace/USER.md
Note: After 同步 更新s USER.md, re启动 the gateway for changes to take effect (workspace files are 缓存d at gateway 启动up).
Multi-user principle
USER.md should clearly 状态:
Who the "primary human" (主人) is That the 代理 serves multiple users and must not assume DM 发送er 身份 A communication preference to 添加ress people by their actual name 隐私 The contacts table contAIns only names and open_ids (no emAIls, phone numbers, or other PII) open_id is an opaque identifier meaningful only within your Feishu 应用 The 同步 script reads 应用 凭证s from OpenClaw.json but never 输出s them