Operate WeCom smart sheets and documents through wecom-cli to record diet and physical condition, and discover hidden correlations between diet and health.
Initial configuration (automatic initialization)
Before performing any operation, first check whether the health diary configuration already exists in memory. If not, automatically create it according to the following process:
Step 1: Create a smart sheet
wecom-cli doc create_doc '{"doc_type": 10, "doc_name": "健康日记"}'
Obtain from the returned result docid。
Step 2: Create sub-sheets and fields
# 创建子表1: 饮食记录
wecom-cli doc smartsheet_add_sheet '{"docid": "<DOCID>", "sheet_name": "饮食记录"}'
# 创建子表2: 身体状态
wecom-cli doc smartsheet_add_sheet '{"docid": "<DOCID>", "sheet_name": "身体状态"}'
# 创建子表3: 关联分析
wecom-cli doc smartsheet_add_sheet '{"docid": "<DOCID>", "sheet_name": "关联分析"}'
Obtain the sheet_idof each sub-sheet, then add fields for each sub-sheet:
Diet record fields:
wecom-cli doc smartsheet_add_fields '{"docid": "<DOCID>", "sheet_id": "<SHEET_ID>", "fields": [
{"field_title": "日期", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "餐次", "field_type": "FIELD_TYPE_SINGLE_SELECT"},
{"field_title": "食物列表", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "份量说明", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "热量估算", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "备注", "field_type": "FIELD_TYPE_TEXT"}
]}'
Physical condition fields:
wecom-cli doc smartsheet_add_fields '{"docid": "<DOCID>", "sheet_id": "<SHEET_ID>", "fields": [
{"field_title": "记录时间", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "状态描述", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "严重程度", "field_type": "FIELD_TYPE_SINGLE_SELECT"},
{"field_title": "持续时长", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "备注", "field_type": "FIELD_TYPE_TEXT"}
]}'
Correlation analysis fields:
wecom-cli doc smartsheet_add_fields '{"docid": "<DOCID>", "sheet_id": "<SHEET_ID>", "fields": [
{"field_title": "食物", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "状态", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "出现次数", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "典型时间差", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "关联强度", "field_type": "FIELD_TYPE_SINGLE_SELECT"}
]}'
Step 3: Save the configuration to memory
Save the following information to the memory file health-diary-config.md:
---
name: health-diary-config
description: 健康日记智能表格配置信息,包含 docid、各子表 sheet_id
type: project
---
## 健康日记表配置
- docid: <DOCID>
- url: <创建时返回的URL>
- 表格名称: 健康日记
- 饮食记录 sheet_id: <SHEET_ID>
- 身体状态 sheet_id: <SHEET_ID>
- 关联分析 sheet_id: <SHEET_ID>
After the configuration is saved, all operations read directly from memory without asking again.
Operation process
In the following commands
<DOCID>and each<SHEET_ID>are read from health-diary-config in memory.
Mode 1: Record diet by text description
The user describes food in natural language, and AI records it in the smart sheet.
Interaction process:
- User: "I had braised beef noodles and an iced Americano for lunch"
- AI confirms the food and portion size
- After the user confirms, write to the smart sheet
wecom-cli doc smartsheet_add_records '{"docid": "<DOCID>", "sheet_id": "<饮食记录SHEET_ID>", "records": [{"values": {
"日期": [{"type": "text", "text": "2026-04-02"}],
"餐次": [{"text": "午餐"}],
"食物列表": [{"type": "text", "text": "红烧牛肉面, 冰美式"}],
"份量说明": [{"type": "text", "text": "一大碗, 大杯"}],
"备注": [{"type": "text", "text": ""}]
}}]}'
Mode 2: Record by photo recognition
The user sends a food photo to WeCom, and AI records it after recognition.
Interaction process:
- The user sends a food photo via WeCom
- AI recognizes the food using multimodal capabilities
- After confirming the food and portion size, write it in
# 获取最近消息中的图片
wecom-cli msg get_message '{"chat_type": 1, "chatid": "<USERID>", "begin_time": "<5分钟前>", "end_time": "<现在>"}'
# 下载图片后用 Claude 视觉能力识别
# 识别完成后写入饮食记录(命令同模式1)
Mode 3: Record physical condition
The user reports physical discomfort, and AI records it and proactively checks whether there is a dietary correlation.
Interaction process:
- User: "My stomach is a little uncomfortable in the afternoon"
- AI queries recent diet records and checks whether there is a known food-condition correlation
- If a risk food is found, proactively remind
- Write the physical condition record
# 写入身体状态
wecom-cli doc smartsheet_add_records '{"docid": "<DOCID>", "sheet_id": "<身体状态SHEET_ID>", "records": [{"values": {
"记录时间": [{"type": "text", "text": "2026-04-02 15:00"}],
"状态描述": [{"type": "text", "text": "胃部不适"}],
"严重程度": [{"text": "轻微"}],
"持续时长": [{"type": "text", "text": ""}],
"备注": [{"type": "text", "text": ""}]
}}]}'
# 查询最近饮食记录检查关联
wecom-cli doc smartsheet_get_records '{"docid": "<DOCID>", "sheet_id": "<饮食记录SHEET_ID>"}'
# 查询已有关联分析
wecom-cli doc smartsheet_get_records '{"docid": "<DOCID>", "sheet_id": "<关联分析SHEET_ID>"}'
Proactive reminder logic:
- Query records in the correlation analysis sheet where "correlation strength"="high"
- Compare with the user's diet records in the last 6 hours
- If a high-risk food is matched, send a reminder message
Mode 4: Correlation analysis
AI analyzes diet records and physical condition records to discover hidden correlation patterns.
Analysis logic:
- Obtain all diet records and physical condition records
- For each physical condition record, trace back the diet within 6-8 hours
- Count the frequency of occurrence of "food X → condition Y"
- Occurrence of 2 or more times is marked as "medium", and 3 or more times is marked as "high"
- Calculate the typical time difference (the average time from food intake to symptom onset)
# 读取所有饮食记录
wecom-cli doc smartsheet_get_records '{"docid": "<DOCID>", "sheet_id": "<饮食记录SHEET_ID>"}'
# 读取所有身体状态
wecom-cli doc smartsheet_get_records '{"docid": "<DOCID>", "sheet_id": "<身体状态SHEET_ID>"}'
# 读取已有关联分析
wecom-cli doc smartsheet_get_records '{"docid": "<DOCID>", "sheet_id": "<关联分析SHEET_ID>"}'
# AI 执行关联分析后,更新关联分析表
wecom-cli doc smartsheet_update_records '{"docid": "<DOCID>", "sheet_id": "<关联分析SHEET_ID>", "key_type": "CELL_VALUE_KEY_TYPE_FIELD_TITLE", "records": [{"record_id": "RECORD_ID", "values": {
"出现次数": [{"type": "text", "text": "3"}],
"关联强度": [{"text": "高"}]
}}]}'
Mode 5: Generate a weekly health report
Generate a health report every week and save it as a WeCom document.
Report content:
- Diet Overview (recording days, total meals, dietary regularity)
- Physical Condition (number of discomforts, main symptoms)
- Correlation Findings (food-condition correlation table)
- Recommendations (based on correlation analysis)
# 读取本周数据(假设 7 天)
wecom-cli doc smartsheet_get_records '{"docid": "<DOCID>", "sheet_id": "<饮食记录SHEET_ID>"}'
wecom-cli doc smartsheet_get_records '{"docid": "<DOCID>", "sheet_id": "<身体状态SHEET_ID>"}'
wecom-cli doc smartsheet_get_records '{"docid": "<DOCID>", "sheet_id": "<关联分析SHEET_ID>"}'
# AI 汇总分析后,创建报告文档
wecom-cli doc create_doc '{"doc_type": 3, "doc_name": "健康周报 2026-W14"}'
# 写入报告内容
wecom-cli doc edit_doc_content '{"docid": "<报告DOCID>", "content": "# 健康周报(3/27-4/2)\n\n## 饮食概览\n...\n\n## 身体状态\n...\n\n## 关联发现\n...\n\n## 建议\n...", "content_type": 1}'
Heat Score Calculation Rules (correlation strength)
| Condition | Correlation Strength |
|---|---|
| Occurs 1 time | Low |
| Occurs 2-3 times | Medium |
| Occurs 4 or more times | High |
Field Type Writing Format (general rules)
For the complete field type format description, see crm-schema
| Field Type | Writing Format | Example |
|---|---|---|
| TEXT | [{"type":"text","text":"值"}] |
Text fields such as food list, date, notes |
| SINGLE_SELECT | [{"text":"选项文本"}] |
Single-select fields such as meal, severity, correlation strength |
Practical Notes
Common Pitfalls
- Not passing key_type when updating — the field title cannot be recognized; it must include
"key_type": "CELL_VALUE_KEY_TYPE_FIELD_TITLE" - When an API call fails — check the error code: 301085 means docid is invalid (use url instead); 2022004 means field not found (call add_fields first); 2022003 means record does not exist (call add_records first). When encountering an error, first use
smartsheet_get_sheet '{"url": "<URL>"}'to verify the table structure. - SINGLE_SELECT option mismatch — the text passed must exactly match an existing option in the table
- SINGLE_SELECT options do not take effect at creation time —
smartsheet_add_fieldsTheproperty.optionspassed in will not pre-create options; options are automatically created via[{"text": "选项"}]when a record is written for the first time. When creating a field, you can omit thepropertyparameter and directly write"field_type": "FIELD_TYPE_SINGLE_SELECT". - Date format — uniformly use the
YYYY-MM-DDformat, and useYYYY-MM-DD HH:MM - Timing of correlation analysis — it is recommended to trigger correlation checks each time a physical condition is recorded, and generate a complete weekly report every Sunday
- Photo recognition — the user needs to first send a photo via WeCom, then retrieve it via msg get_message
Scheduled Automation Recommendations
| Task | Recommended Time | Cron |
|---|---|---|
| Health weekly report generation | Every Sunday at 20:00 | 0 20 * * 0 |
| Correlation analysis update | Daily at 22:00 | 0 22 * * * |
Data Linkage
- This Skill runs independently and does not depend on other Skills
- The health weekly report can be sent to WeCom to notify the user