SuperAPI AI Directory

dingtalk-workflow-health-diary

Office & productivity

View repository

Updated 10-15 23:59

About this skill

Health Diary (dingtalk-workflow-health-diary)

Record diet and physical condition through conversation, and AI analyzes correlation patterns between food and physical discomfort. Compared with the Feishu version, DingTalk's exclusive advantage: can integrate attendance clock-in data to indirectly infer sleep and wake patterns.

Trigger Methods

"记录饮食"  "健康日记"  "吃了什么"  "身体不舒服"  "健康追踪"  "午餐记录"

Working Modes

Mode 1: Text Description Recording

Trigger: "Had braised beef noodles and an iced Americano for lunch" / "Had a sandwich for breakfast today"

Workflow:

Step 0: 确保数据表已初始化(见下方"数据初始化"章节)
    └── dws aitable base list → 检查是否存在"健康日记" Base
        不存在 → 执行完整初始化流程(创建 Base → 创建表 → 创建字段)

Step 1: 解析用户输入
├── 提取餐次(早餐/午餐/晚餐/加餐)
├── 提取食物列表和份量
└── 推断日期("昨天"→-1天、"前天"→-2天,默认今天)

Step 2: AI 检查关联风险
└── dws aitable record query --base-id <hd-base-id> --table-id <correlation-table-id> --keyword "<食物名>" --yes -f json
    如果有高风险食物(关联强度="高") → 立即提醒

Step 3: 写入饮食记录(⚠️ 必须包含"标题"主字段)
└── dws aitable record create --base-id <hd-base-id> --table-id <diet-table-id> --records '[{"cells":{"标题":"2026-04-06 午餐","日期":"2026-04-06","餐次":"午餐","食物列表":"红烧牛肉面, 冰美式"}}]' --yes -f json

Step 4: 如果有风险,发送提醒
└── dws ding message send --robot-code "bot_code" --users "manager6950" --content "..." --type "1" --yes

Output Format:

已记录饮食:
| 日期 | 餐次 | 食物 |
|------|------|------|
| 2026-04-06 | 午餐 | 红烧牛肉面(一大碗), 冰美式(大杯) |

⚠️ 提醒:之前 3 次喝冰美式后 1-2 小时内都出现了胃部不适,请注意观察。

Mode 2: Physical Condition Recording

Trigger: "My stomach feels a bit uncomfortable in the afternoon" / "I didn't sleep well today" / "I feel a bit dizzy"

Workflow:

Step 1: 解析身体状态
├── 状态描述(胃部不适/头痛/疲劳/失眠等)
├── 严重程度(轻微/中度/严重)
└── 时间(自动记录当前时间,格式 "YYYY-MM-DDTHH:mm:ss")

Step 2: AI 回溯检查今日饮食
└── dws aitable record query --base-id <hd-base-id> --table-id <diet-table-id> --limit 50 --yes -f json
    → 从中筛选今日记录,检查时间差

Step 3: 查询历史关联模式
└── dws aitable record query --base-id <hd-base-id> --table-id <correlation-table-id> --limit 50 --yes -f json
    → 查看是否有食物关联

Step 4: 写入身体状态记录
└── dws aitable record create --base-id <hd-base-id> --table-id <health-table-id> --records '[{"cells":{"标题":"2026-04-06 胃部不适","时间":"2026-04-06T15:00:00","状态描述":"胃部不适","严重程度":"轻微"}}]' --yes -f json

Step 5: 如果发现新的关联模式,更新关联分析表
└── dws aitable record create --base-id <hd-base-id> --table-id <correlation-table-id> --records '[{"cells":{"标题":"冰美式-胃部不适","食物":"冰美式","状态":"胃部不适","时间差":"1-2小时","出现次数":1,"关联强度":"中"}}]' --yes -f json
    或更新已有记录:
    dws aitable record update --base-id <hd-base-id> --table-id <correlation-table-id> --records '[{"recordId":"<id>","cells":{"出现次数":3,"关联强度":"高"}}]' --yes -f json

Mode 3: Correlation Analysis

Trigger: "What foods tend to make my stomach uncomfortable?" / "Analyze the relationship between diet and health" / "Are there any food correlations"

Workflow:

Step 1: 查询所有饮食记录和身体状态记录
├── dws aitable record query --base-id <hd-base-id> --table-id <diet-table-id> --limit 100 --yes -f json
└── dws aitable record query --base-id <hd-base-id> --table-id <health-table-id> --limit 100 --yes -f json

Step 2: 查询已有关联分析
└── dws aitable record query --base-id <hd-base-id> --table-id <correlation-table-id> --limit 50 --yes -f json

Step 3: AI 执行关联分析
├── 按食物分组统计身体状态出现频率
├── 计算时间差模式(吃X后多久出现症状)
├── 计算关联强度(高/中/低,基于出现次数和时间一致性)
└── 排除偶然关联(出现次数 < 2 的不报告)

Step 4: 更新关联分析表并输出报告
└── 对每对新的食物-状态关联,写入或更新 correlation 表

Mode 4: Weekly Report Generation

Trigger: "Generate this week's health report" / "Health weekly report"

Workflow:

Step 1: 查询本周数据
├── dws aitable record query --base-id <hd-base-id> --table-id <diet-table-id> --limit 100 --yes -f json
├── dws aitable record query --base-id <hd-base-id> --table-id <health-table-id> --limit 100 --yes -f json
└── dws aitable record query --base-id <hd-base-id> --table-id <correlation-table-id> --limit 50 --yes -f json

Step 2: 查询考勤数据(钉钉独有)
└── dws attendance record get --user "manager6950" --date "2026-04-06" --yes -f json
    → 推断作息规律(上班时间 → 间接了解起床时间)
    → 注意:dws attendance summary 不可用,仅使用 record get 获取考勤数据

Step 3: AI 生成周报

Weekly Report Format:

## 健康周报(MM/DD - MM/DD)

### 饮食概览
- 记录天数:N 天
- 总餐次:M 次
- 饮食规律性:较好/一般/较差

### 身体状态
- 不适记录:N 次
- 主要症状:胃部不适 X 次、疲劳 Y 次

### 作息规律(钉钉独有)
- 平均上班打卡时间:HH:MM
- 平均下班打卡时间:HH:MM
- 工作时长:约 N 小时

### 关联发现
| 食物 | 状态 | 出现次数 | 典型时间差 | 关联强度 |
|------|------|---------|-----------|---------|
| 冰美式 | 胃部不适 | 3次 | 1-2小时 | 高 |
| 辣味火锅 | 失眠 | 1次 | 6-8小时 | 中 |

### 建议
- 冰美式与胃部不适有强关联,建议减少摄入或改用热饮
- 辣味火锅建议避免晚餐食用

Mode 5: Proactive Reminder

Trigger: Automatically triggered when the user records a meal containing high-risk foods (embedded in Step 2 of Mode 1)

Workflow:

Step 1: 用户记录饮食 → 提取食物名称关键词

Step 2: 查询关联分析表
└── dws aitable record query --base-id <hd-base-id> --table-id <correlation-table-id> --keyword "<食物名>" --yes -f json

Step 3: 如果发现高关联强度记录(出现次数 ≥ 3 且关联强度="高") → 立即提醒

Data Initialization

On first use, first check whether the Base already exists; if not, create it according to the complete process:

# Step 0: 检查是否已初始化
dws aitable base list --yes -f json | grep "健康日记"
# 如果不存在,执行以下步骤:

# Step 1: 创建 Base
dws aitable base create --name "健康日记" --yes -f json
# 返回 baseId,记为 <hd-base-id>

# Step 2: 创建 3 张表(⚠️ 每张表自动创建一个 primaryDoc 类型的"标题"主字段)
dws aitable table create --base-id <hd-base-id> --name "饮食记录" --yes -f json
# 返回 tableId,记为 <diet-table-id>
dws aitable table create --base-id <hd-base-id> --name "身体状态" --yes -f json
# 返回 tableId,记为 <health-table-id>
dws aitable table create --base-id <hd-base-id> --name "关联分析" --yes -f json
# 返回 tableId,记为 <correlation-table-id>

# Step 3: 为每张表添加业务字段
# ⚠️ 字段类型必须用英文名: text / date / number / select / multiselect
# ⚠️ 字段参数名必须用 "fieldName"(不是 "name")

# 饮食记录表
dws aitable field create --base-id <hd-base-id> --table-id <diet-table-id> \
  --fields '[{"fieldName":"日期","type":"date"},{"fieldName":"餐次","type":"text"},{"fieldName":"食物列表","type":"text"}]' \
  --yes -f json

# 身体状态表
dws aitable field create --base-id <hd-base-id> --table-id <health-table-id> \
  --fields '[{"fieldName":"时间","type":"text"},{"fieldName":"状态描述","type":"text"},{"fieldName":"严重程度","type":"text"},{"fieldName":"睡眠质量","type":"text"}]' \
  --yes -f json

# 关联分析表
dws aitable field create --base-id <hd-base-id> --table-id <correlation-table-id> \
  --fields '[{"fieldName":"食物","type":"text"},{"fieldName":"状态","type":"text"},{"fieldName":"时间差","type":"text"},{"fieldName":"出现次数","type":"number"},{"fieldName":"关联强度","type":"text"}]' \
  --yes -f json

Table Structure Overview

Table 1: Diet Records — tableId: <diet-table-id>

Field Name Type Source Description
Title primaryDoc Auto-created Primary field, recommended to fill in "YYYY-MM-DD meal"
Date date Manually created Record date, format "YYYY-MM-DD"
Meal text Manually created Breakfast/Lunch/Dinner/Snack
Food List text Manually created Food names and portions, separated by commas

Table 2: Physical Condition — tableId: <health-table-id>

Field Name Type Source Description
Title primaryDoc Auto-created Primary field, recommended to fill in "YYYY-MM-DD condition description"
Time text Manually created Condition record time, format "YYYY-MM-DDTHH:mm:ss"
Condition Description text Manually created Such as "stomach discomfort", "fatigue"
Severity text Manually created Mild/Moderate/Severe
Sleep Quality text Manually created Good/Average/Poor (optional, requires the user to provide it proactively)

Table 3: Correlation Analysis — tableId: <correlation-table-id>

Field Name Type Source Description
Title primaryDoc Auto-created Primary field, recommended to fill in "Food - Status"
Food text Manually created Associated food
Status text Manually created Associated body status
Time difference text Manually created Typical delay (e.g., "1-2 hours")
Occurrence count number Manually created Associated occurrence count
Association strength text Manually created High/Medium/Low

dws CLI command reference

Create health diary (full initialization)

# 1. 创建 Base
dws aitable base create --name "健康日记" --yes -f json

# 2. 创建表(每张表自动生成"标题"主字段)
dws aitable table create --base-id <hd-base-id> --name "饮食记录" --yes -f json
dws aitable table create --base-id <hd-base-id> --name "身体状态" --yes -f json
dws aitable table create --base-id <hd-base-id> --name "关联分析" --yes -f json

# 3. 创建业务字段(类型用英文: text/date/number,参数用 fieldName)
dws aitable field create --base-id <hd-base-id> --table-id <diet-table-id> \
  --fields '[{"fieldName":"日期","type":"date"},{"fieldName":"餐次","type":"text"},{"fieldName":"食物列表","type":"text"}]' --yes -f json
dws aitable field create --base-id <hd-base-id> --table-id <health-table-id> \
  --fields '[{"fieldName":"时间","type":"text"},{"fieldName":"状态描述","type":"text"},{"fieldName":"严重程度","type":"text"},{"fieldName":"睡眠质量","type":"text"}]' --yes -f json
dws aitable field create --base-id <hd-base-id> --table-id <correlation-table-id> \
  --fields '[{"fieldName":"食物","type":"text"},{"fieldName":"状态","type":"text"},{"fieldName":"时间差","type":"text"},{"fieldName":"出现次数","type":"number"},{"fieldName":"关联强度","type":"text"}]' --yes -f json

Record diet (⚠️ must include the "Title" primary field)

dws aitable record create --base-id <hd-base-id> --table-id <diet-table-id> \
  --records '[{"cells":{"标题":"2026-04-06 午餐","日期":"2026-04-06","餐次":"午餐","食物列表":"红烧牛肉面(一大碗), 冰美式(大杯)"}}]' \
  --yes -f json

Record body status (⚠️ must include the "Title" primary field)

dws aitable record create --base-id <hd-base-id> --table-id <health-table-id> \
  --records '[{"cells":{"标题":"2026-04-06 胃部不适","时间":"2026-04-06T15:00:00","状态描述":"胃部不适","严重程度":"轻微"}}]' \
  --yes -f json

Query records

# 查询饮食记录
dws aitable record query --base-id <hd-base-id> --table-id <diet-table-id> --limit 50 --yes -f json

# 按关键词查询
dws aitable record query --base-id <hd-base-id> --table-id <correlation-table-id> --keyword "冰美式" --yes -f json

# 查询身体状态
dws aitable record query --base-id <hd-base-id> --table-id <health-table-id> --limit 50 --yes -f json

# 查询关联分析
dws aitable record query --base-id <hd-base-id> --table-id <correlation-table-id> --limit 50 --yes -f json

Update records

# 更新关联分析记录(需要 recordId)
dws aitable record update --base-id <hd-base-id> --table-id <correlation-table-id> \
  --records '[{"recordId":"<recordId>","cells":{"出现次数":3,"关联强度":"高"}}]' --yes -f json

Query attendance (work-rest reference, DingTalk exclusive)

# 获取打卡记录(测试通过;未设考勤组时返回空记录,属正常现象)
dws attendance record get --user "manager6950" --date "2026-04-06" --yes -f json

# 注意:dws attendance summary 服务端报"统计类型错误"(code C0002),不可用

DING urgent reminder

dws ding message send --robot-code "bot_code" --users "manager6950" --content "提醒:你刚吃了冰美式,之前多次在喝完后出现胃部不适" --type "1" --yes

Scheduled tasks

Task Cron Description
Health weekly report 0 20 * * 0 Generate weekly report every Sunday at 20:00
CronCreate: cron="0 20 * * 0", prompt="生成本周的健康报告并保存到知识库", recurring=true, durable=true

Linked Skills

Linked Skill Data interaction Description
morning-brief Provide dietary reminders Add dietary notes to the morning briefing
business-advisor Provide health data The advisory team focuses on the relationship between work efficiency and health

Notes

  1. All dws commands must include the --yes flag
  2. aitable field creation:
    • The type must use theEnglish name:text / date / number / select / multiselect(cannot use the Chinese "text" or the numeric code 1/2)
    • Parameter names must use "fieldName"(cannot use "name")
  3. Each table automatically creates a primaryDoc type "Title" primary field; when creating records,must includethis field
  4. Correlation analysis requires at least 2 data points before reporting, to avoid false positives
  5. Association strength determination: 3 or more occurrences = High, 2 occurrences = Medium, 1 occurrence = Do not report
  6. Attendance data is only used as a work-rest reference, not as a basis for health judgments
  7. DING messages are only used for high-risk food reminders, to avoid frequent interruptions
  8. The DingTalk CLI has no image recognition command (unlike Feishu); users need to describe food in text
  9. Attendance query dws attendance record get works normally, but dws attendance summary returns a server-side error and is unavailable
  10. When the organization has not set up an attendance group, attendance record get returns empty records, which is normal

Known issues

  • dws attendance summary The server reports "statistics type error" (code C0002) and is unavailable. For attendance data, use dws attendance record get instead