CRITICAL — Before starting, you MUST first use the Read tool to read ../lark-shared/SKILL.md, which contains authentication and permission handling
Applicable Scenarios
- "Who contacted me last month?" / "Who have I interacted with recently"
- "What was the last thing I talked about with the person from Company XX?" / "How is my relationship with Zhang San"
- "Are there any important relationships I haven't contacted in over 3 months?" / "Who should I follow up with"
- "Help me create contact profiles" / "Import contacts from email/calendar"
- "What is this person's heat score" / "Update contact information"
Prerequisites
Only supports user identity. Before execution, ensure authorization has been granted:
lark-cli auth login --domain mail,calendar,contact,base,im
Email module degradation note: If the user has not enabled Feishu email (the
- The "import from email" mode is unavailable; skip the email scanning step
- Use "import from calendar" and "supplement from contacts" as the main data sources
- Note in the briefing that "email is not enabled; contact data comes only from calendar and contacts"
Workflow Overview
数据导入:
├── mail +messages ───────► 扫描邮箱 → 提取联系人 + 互动记录
├── calendar +agenda ─────► 扫描日历 → 提取会议参与者 + 互动记录
└── contact +search-user ─► 补充飞书通讯录信息
数据存储:
└── base +record-upsert ──► 多维表格(联系人 + 互动记录)
数据查询:
└── base +record-list ────► 自然语言查询联系人
智能提醒:
└── base +data-query ────► 筛选冷门联系人
└── im +messages-send ───► 飞书消息提醒
Data Initialization
On first use, create the multi-dimensional table data structure:
Base Table Structure
Table 1: Contacts Main Table (contacts)
| Field Name | Type | Description |
|---|---|---|
| Name | Text | Contact name |
| Company | Text | Company/organization |
| Position | Text | Position/role |
| Text | Email address | |
| Mobile | Text | Contact information |
| Source | Single select | Email/Calendar/Contacts/Manual |
| Relationship Type | Single select | Client/Partner/Colleague/Friend/Industry connection/Other |
| Importance Level | Single select | High/Medium/Low |
| Heat Score | Number | 0-100, calculated based on interaction frequency and most recent interaction time |
| Last Contact Time | Date | Time of the most recent interaction |
| Last Contact Content | Text | Summary of the most recent interaction |
| Notes | Text | Free-form notes |
| Creation Time | Date | First entry time |
Table 2: Interaction Records (interactions)
| Field Name | Type | Description |
|---|---|---|
| Related Contact | Association | Associate with "Contacts Main Table" |
| Interaction Time | Date | Time when the interaction occurred |
| Interaction Type | Single select | Email (Sent) / Email (Received) / Meeting / Message / Phone Call / Other |
| Interaction Summary | Text | A brief description of the interaction content |
| Topics Involved | Text | Topics or projects discussed |
| Email ID | File | The associated email message_id (if any) |
| Meeting ID | Text | The associated meeting_id (if any) |
Initialization Command
# 1. 创建多维表格
# 注意:+table-create 可能部分成功(表创建成功但字段创建失败),需捕获错误后用 +field-create 补字段
# 注意:连续创建字段会触发限流(错误码 800004135),每次调用间隔至少 1 秒
lark-cli base +table-create --name "联系人" --fields '[
{"name":"姓名","type":"text"},
{"name":"公司","type":"text"},
{"name":"职位","type":"text"},
{"name":"邮箱","type":"text"},
{"name":"手机","type":"text"},
{"name":"来源","type":"select","multiple":false,"options":[{"name":"邮件"},{"name":"日历"},{"name":"通讯录"},{"name":"手动"}]},
{"name":"关系类型","type":"select","multiple":false,"options":[{"name":"客户"},{"name":"合作伙伴"},{"name":"同事"},{"name":"朋友"},{"name":"行业人脉"},{"name":"其他"}]},
{"name":"重要程度","type":"select","multiple":false,"options":[{"name":"高"},{"name":"中"},{"name":"低"}]},
{"name":"热度分","type":"number"},
{"name":"最后联系时间","type":"datetime"},
{"name":"最后联系内容","type":"text"},
{"name":"备注","type":"text"},
{"name":"创建时间","type":"datetime"}
]'
lark-cli base +table-create --name "互动记录" --fields '[
{"name":"互动时间","type":"datetime"},
{"name":"互动类型","type":"select","multiple":false,"options":[{"name":"邮件(发)"},{"name":"邮件(收)"},{"name":"会议"},{"name":"消息"},{"name":"电话"},{"name":"其他"}]},
{"name":"互动摘要","type":"text"},
{"name":"涉及主题","type":"text"},
{"name":"邮件ID","type":"text"},
{"name":"会议ID","type":"text"}
]'
# 注:关联联系人字段需单独用 +field-create 创建(type="lookup" 需要关联目标表 ID)
# 2. 记录 base_token 和各 table_id
On first use, prompt the user to provide a Base URL or create a new multi-dimensional table.
Rate Limit Handling: If +table-create partially fails due to rate limiting, the table will still be created successfully. In this case:
- Use
base +table-listto get the table_id- Use
base +field-create --table-id <id> --json '{"name":"字段名","type":"text"}'to add fields one by one, with an interval of 1-2 seconds each time
Mode 1: Data Import
Import from Mailbox
# 搜索指定时间范围的邮件
lark-cli mail +messages --folder INBOX --start-date "<YYYY-MM-DD>" --end-date "<YYYY-MM-DD>"
AI Processing Logic:
- Extract contact information from senders and recipients (name, email, company signature)
- Analyze email subject and body to generate an interaction summary (1-2 sentences)
- Identify interaction topics (project names, topic keywords)
- For each new contact: create a contact record
- For each interaction: create an interaction record and associate it with the contact
Filtering Rules:
- Automatically filter out advertising emails, system notifications, and noreply addresses
- Filter out internal automated notifications (CI/CD, calendar invitations, etc.)
- Keep interpersonal communications with substantive content
Import from Calendar
# 获取指定时间范围的日程
lark-cli calendar +agenda --start "<ISO8601>" --end "<ISO8601>"
AI Processing Logic:
- Extract contacts from the event's participant list
- Use
contact +search-userto supplement Feishu contacts information (position, department, etc.) - Generate an interaction summary (meeting topic)
- Create/update contact records and interaction records
Supplement from Feishu Contacts
lark-cli contact +search-user --query "<联系人姓名>"
When contact information is incomplete, supplement company, position, and other information through Feishu Contacts.
Mode 2: Heat Score Calculation
Heat score calculation formula (0-100):
热度分 = 频率分(0-40) + 近期分(0-40) + 重要度分(0-20)
频率分(过去 90 天互动次数):
0次 → 0分
1-3次 → 10分
4-10次 → 20分
11-20次 → 30分
20次以上 → 40分
近期分(最后一次互动距今天数):
7天内 → 40分
14天内 → 32分
30天内 → 24分
60天内 → 16分
90天内 → 8分
90天以上 → 0分
重要度分:
高 → 20分
中 → 12分
低 → 4分
The heat score is automatically recalculated after each import of new interactions.
Mode 3: Natural Language Query
Supported natural language query types:
| Query Type | Example | Query Method |
|---|---|---|
| By time | "Who contacted me last month?" | base +record-list Interaction records table + time filter |
| By company | "What have I discussed with people from Company XX?" | base +record-list Contacts table + company filter |
| By person name | "How has Zhang San been lately?" | base +record-list Contacts table + name filter |
| By heat | "Who should I follow up with?" | base +data-query Contacts with heat score < 30 |
| By topic | "What discussions are there about the AI project?" | base +record-list Interaction records table + topic keywords |
| Comprehensive query | "Are there any important relationships that haven't been contacted in over 3 months?" | base +data-query Last contact > 90 days AND importance level = "High" |
Query execution example
# 查询冷门联系人(聚合查询)
lark-cli base +data-query --base-token "<base_token>" --dsl '{
"datasource": {"type": "table", "table": {"tableId": "<contacts_table_id>"}},
"dimensions": [{"field_name": "姓名", "alias": "name"}, {"field_name": "重要程度", "alias": "importance"}],
"measures": [{"field_name": "热度分", "aggregation": "avg", "alias": "avg_score"}],
"filters": {"type": 1, "conjunction": "and", "conditions": [{"field_name": "重要程度", "operator": "is", "value": ["高"]}, {"field_name": "热度分", "operator": "isLess", "value": ["30"]}]},
"shaper": {"format": "flat"}
}'
# 查询特定公司的联系人
lark-cli base +record-list --table-id "<contacts_table_id>" --filter '...公司 = "XX公司"'
# 查询最近互动
lark-cli base +record-list --table-id "<interactions_table_id>" --sort '互动时间 DESC' --page-size 20
Pattern 4: Smart reminders
Scheduled reminders
Filter contacts that need follow-up:
lark-cli base +data-query --base-token "<base_token>" --dsl '{
"datasource": {"type": "table", "table": {"tableId": "<contacts_table_id>"}},
"dimensions": [{"field_name": "姓名", "alias": "name"}],
"measures": [{"field_name": "热度分", "aggregation": "avg", "alias": "avg_score"}],
"filters": {"type": 1, "conjunction": "and", "conditions": [{"field_name": "重要程度", "operator": "isNot", "value": ["低"]}, {"field_name": "热度分", "operator": "isLess", "value": ["30"]}]},
"shaper": {"format": "flat"}
}'
Generate reminder messages and send them via Feishu:
lark-cli im +messages-send --chat-id "<chat_id>" --markdown "..."
Reminder message format:
关系维护提醒
以下联系人已超过 60 天未联系:
| 姓名 | 公司 | 最后联系 | 热度分 | 建议 |
|------|------|---------|--------|------|
| 张三 | XX科技 | 75天前 | 12 | 发个消息打个招呼 |
| 李四 | YY投资 | 90天前 | 4 | 约个会议聊聊近况 |
Pattern 5: Manual operations
Add/update contacts
lark-cli base +record-upsert --table-id "<contacts_table_id>" --json '{"字段名":"值"}'
Manually add interaction records
lark-cli base +record-upsert --table-id "<interactions_table_id>" --json '{"字段名":"值"}'
Permissions table
| Command | Required scope |
|---|---|
mail +messages |
mail:mail:read |
calendar +agenda |
calendar:calendar.event:read |
contact +search-user |
contact:employee.id:readonly |
contact +get-user |
contact:employee.id:readonly |
base +table-create |
bitable:app |
base +record-list |
bitable:app:read |
base +record-upsert |
bitable:app:write |
base +data-query |
bitable:app:read |
im +messages-send |
im:message:send_as_bot |
Reference
lark-shared— Authentication, permissions (required reading)lark-mail— Email reading, security ruleslark-calendar—+agendaDetailed usagelark-contact—+search-user、+get-userDetailed usagelark-base—+table-create、+record-list、+record-upsert、+data-queryDetailed usagelark-im—+messages-sendDetailed usage