Health Auto Log
Overview
Automatically detect health metrics from user messages and record them to AX3 Personal system. Supports weight, blood sugar, and exercise time tracking with flexible input formats.
When to Use This Skill
Trigger this skill when user messages contain:
- - Weight measurements (e.g., "體重69.8公斤", "69.8kg", "69.8")
- Blood sugar readings (e.g., "血糖120", "120 mg/dL")
- Exercise time (e.g., "跑步機30分", "跑步30")
Quick Start
Use the record_health_data.py script to process any message:
CODEBLOCK0
The script will:
- 1. Extract health metrics from the message
- Validate the values are within reasonable ranges
- Record to AX3 using mcporter
- Return confirmation with record IDs
Supported Metrics
1. Weight (體重)
Habit ID: 1
Unit: kg
Range: 40-200 kg
Supported formats:
- - INLINECODE1
- INLINECODE2
- INLINECODE3 (plain number)
2. Blood Sugar (血糖)
Habit ID: 4
Unit: mg/dL
Range: 50-500 mg/dL
Supported formats:
3. Running Time (跑步機)
Habit ID: 2
Unit: minutes
Supported formats:
Workflow
Automatic Detection Flow
- 1. Receive message from WhatsApp or other channel
- Run script with message text: INLINECODE8
- Extract metrics using regex patterns
- Validate values are in reasonable ranges
- Record to AX3 via mcporter call to INLINECODE9
- Confirm with user showing what was recorded
Example Usage
CODEBLOCK1
Integration Pattern
When a user sends a health-related message:
- 1. Call the script with the message text
- Parse the JSON output to check if data was detected
- If detected, respond with confirmation (e.g., "收到!69.8 kg 已記錄 📝")
- If not detected, reply normally without mentioning the skill
Error Handling
The script includes validation:
- - Out of range values are ignored (e.g., weight of 500kg won't be recorded)
- Invalid formats are silently skipped
- mcporter failures are captured and returned in the JSON output
Resources
scripts/recordhealthdata.py
Python script that handles:
- - Pattern matching for various health data formats
- Value validation and range checking
- AX3 API calls via mcporter
- JSON output for programmatic integration
The script can be called directly or integrated into message handling workflows.
健康自动记录
概述
自动从用户消息中检测健康指标并将其记录到AX3个人系统。支持体重、血糖和运动时间追踪,输入格式灵活。
何时使用此技能
当用户消息包含以下内容时触发此技能:
- - 体重测量值(例如:體重69.8公斤、69.8kg、69.8)
- 血糖读数(例如:血糖120、120 mg/dL)
- 运动时间(例如:跑步機30分、跑步30)
快速开始
使用recordhealthdata.py脚本处理任意消息:
bash
python3 scripts/recordhealthdata.py 體重69.8公斤
脚本将:
- 1. 从消息中提取健康指标
- 验证数值是否在合理范围内
- 使用mcporter记录到AX3
- 返回包含记录ID的确认信息
支持的指标
1. 体重(體重)
习惯ID: 1
单位: kg
范围: 40-200 kg
支持的格式:
- - 體重69.8公斤
- 69.8kg
- 69.8(纯数字)
2. 血糖(血糖)
习惯ID: 4
单位: mg/dL
范围: 50-500 mg/dL
支持的格式:
3. 跑步时间(跑步機)
习惯ID: 2
单位: 分钟
支持的格式:
工作流程
自动检测流程
- 1. 接收消息 来自WhatsApp或其他渠道
- 运行脚本 使用消息文本:python3 scripts/recordhealthdata.py <消息>
- 提取指标 使用正则表达式模式
- 验证 数值在合理范围内
- 记录到AX3 通过mcporter调用ax3-personal.record_habit
- 确认 向用户显示已记录的内容
使用示例
bash
单一指标
python3 scripts/record
healthdata.py 體重69.8公斤
输出:✅ 體重 69.8 kg 已記錄
单条消息中的多个指标
python3 scripts/record
healthdata.py 體重69.8公斤 血糖120
输出:
✅ 體重 69.8 kg 已記錄
✅ 血糖 120 mg/dL 已記錄
集成模式
当用户发送与健康相关的消息时:
- 1. 使用消息文本调用脚本
- 解析JSON输出以检查是否检测到数据
- 如果检测到,回复确认信息(例如:收到!69.8 kg 已記錄 📝)
- 如果未检测到,正常回复而不提及此技能
错误处理
脚本包含验证功能:
- - 超出范围的值将被忽略(例如,500kg的体重不会被记录)
- 无效格式将被静默跳过
- mcporter失败将被捕获并在JSON输出中返回
资源
scripts/recordhealthdata.py
Python脚本,负责处理:
- - 各种健康数据格式的模式匹配
- 数值验证和范围检查
- 通过mcporter调用AX3 API
- 用于程序化集成的JSON输出
该脚本可以直接调用,也可以集成到消息处理工作流中。