WhatsApp Message Monitor Skill
Overview
This skill enables automated monitoring of WhatsApp conversations, filtering for specific keywords, and batch exporting matching messages to Feishu (Lark) multi-dimensional tables.
Core Features
- - Target Monitoring: Configure WhatsApp contacts or groups to monitor
- Keyword Filtering: Define keywords or patterns to watch for
- Batch Collection: Accumulate messages until threshold is reached
- Scheduled Export: Periodically push collected messages to Feishu tables
- Real-time Alerts: Optional immediate notification for high-priority keywords
快速开始
1. 前提条件
使用此技能前,请确保:
- - ✅ WhatsApp 访问权限:个人或商业账户
- ✅ 飞书/Lark 账户:具备 API 访问权限
- ✅ 飞书多维表格应用:已安装和配置
- ✅ OpenClaw WhatsApp 渠道:已配置并配对设备
2. OpenClaw 集成步骤
- 1. 配置 WhatsApp 渠道
CODEBLOCK0
- 2. 配对 WhatsApp 设备
- 打开浏览器访问 WhatsApp Web (web.whatsapp.com)
- 扫描二维码配对设备
- 确保设备状态显示为“已连接”
- 3. 安装技能依赖
CODEBLOCK1
- 4. 配置监控目标
CODEBLOCK2
- 5. 配置飞书集成
- 获取飞书应用凭证 (App ID, App Secret)
- 创建多维表格并获取 Table Token
- 更新 INLINECODE0
3. 首次运行
测试配置:
CODEBLOCK3
启动监控:
CODEBLOCK4
查看状态:
CODEBLOCK5
2. Configuration Files
This skill uses two main configuration files:
- -
config/whatsapp-targets.json - Define WhatsApp contacts/groups to monitor - INLINECODE2 - Configure Feishu API and table settings
Configuration
WhatsApp Targets
Create config/whatsapp-targets.json:
CODEBLOCK6
Feishu Settings
Create config/feishu-settings.json:
CODEBLOCK7
使用工作流
设置阶段
- 1. 初始化配置 - 设置监控目标和飞书凭证
CODEBLOCK8
- 2. 测试连接 - 验证 WhatsApp 和飞书 API 连接
CODEBLOCK9
- 3. 启动监控 - 开始扫描配置的聊天
CODEBLOCK10
OpenClaw Skill 集成
在 OpenClaw 中使用此技能:
CODEBLOCK11
定时任务设置
通过 OpenClaw cron 设置定时监控:
CODEBLOCK12
实时通知配置
配置实时告警(当匹配到高优先级关键词时):
- 1. 在
config/whatsapp-targets.json 中设置:
CODEBLOCK13
- 2. 配置通知渠道(可选):
- 飞书机器人消息
- 电子邮件通知
- 短信告警
Monitoring Phase
The system will:
- 1. Periodically check configured WhatsApp chats
- Filter messages for keyword matches
- Store matching messages locally
- Export to Feishu when batch threshold is reached or on schedule
Export Phase
When ready to export, the system will:
- 1. Format collected messages according to table schema
- Push to Feishu multi-dimensional table
- Clear local cache after successful export
- Log export status and any errors
Tools and Scripts
Core Monitoring Script
See scripts/monitor.py for the main monitoring logic.
Configuration Management
See scripts/config.py for handling configuration files.
Feishu API Integration
See scripts/feishu_client.py for Feishu table operations.
WhatsApp Web Automation
See scripts/whatsapp_web.py for WhatsApp Web interaction.
Advanced Features
Custom Filters
Beyond simple keywords, you can implement:
- - Regular expression patterns
- Sentiment analysis
- Time-based rules
- Sender-specific filters
Alerting Options
Configure additional alert channels:
- - Email notifications
- Slack/Teams messages
- SMS alerts
- Push notifications
Data Enrichment
Enhance collected messages with:
- - Sentiment scores
- Entity extraction
- Topic classification
- Translation services
Troubleshooting
Common Issues
- 1. WhatsApp Web Connection - Ensure browser automation is working
- Feishu API Permissions - Verify app has correct table permissions
- Keyword Matching - Check for case sensitivity and special characters
Monitoring Status
Check monitoring logs in logs/whatsapp-monitor.log for operational details and errors.
Integration Examples
Combine with Other Skills
This skill can be combined with:
- - Calendar Integration - Trigger calendar events based on messages
- Task Management - Create tasks from important messages
- CRM Systems - Update customer records from support chats
Automated Reporting
Set up automated reports:
- - Daily summary reports
- Weekly keyword trend analysis
- Monthly activity reports
Security Considerations
- - Store sensitive credentials securely (use environment variables)
- Implement rate limiting for API calls
- Regularly audit access logs
- Consider data retention policies
Performance Optimization
For high-volume monitoring:
- - Implement message deduplication
- Use batch API calls for Feishu
- Optimize keyword matching algorithms
- Consider distributed monitoring for multiple accounts
Maintenance
Regular maintenance tasks:
- - Update keyword lists periodically
- Review export success rates
- Monitor API rate limits
- Backup configuration and logs
References
For detailed API documentation and additional resources, see:
Quick Commands
Start Monitoring
CODEBLOCK14
Force Export
CODEBLOCK15
View Status
CODEBLOCK16
Test Configuration
CODEBLOCK17
Support
For assistance or feature requests, refer to the troubleshooting section or contact the skill maintainer.
WhatsApp 消息监控技能
概述
该技能能够自动监控 WhatsApp 对话,过滤特定关键词,并将匹配的消息批量导出到飞书多维表格。
核心功能
- - 目标监控:配置要监控的 WhatsApp 联系人或群组
- 关键词过滤:定义要监控的关键词或模式
- 批量收集:累积消息直至达到阈值
- 定时导出:定期将收集的消息推送到飞书表格
- 实时告警:可选的高优先级关键词即时通知
快速开始
1. 前提条件
使用此技能前,请确保:
- - ✅ WhatsApp 访问权限:个人或商业账户
- ✅ 飞书/Lark 账户:具备 API 访问权限
- ✅ 飞书多维表格应用:已安装和配置
- ✅ OpenClaw WhatsApp 渠道:已配置并配对设备
2. OpenClaw 集成步骤
- 1. 配置 WhatsApp 渠道
bash
# 在 OpenClaw 中设置 WhatsApp 渠道
openclaw channels enable whatsapp
- 2. 配对 WhatsApp 设备
- 打开浏览器访问 WhatsApp Web (web.whatsapp.com)
- 扫描二维码配对设备
- 确保设备状态显示为已连接
- 3. 安装技能依赖
bash
cd ~/whatsapp-monitor # 或你的克隆目录,例如 /opt/whatsapp-monitor
pip install -r requirements.txt
- 4. 配置监控目标
bash
# 编辑配置文件
python scripts/setup.py
- 5. 配置飞书集成
- 获取飞书应用凭证 (App ID, App Secret)
- 创建多维表格并获取 Table Token
- 更新 config/feishu-settings.json
3. 首次运行
测试配置:
bash
python scripts/monitor.py --test-config
启动监控:
bash
python scripts/monitor.py --start
查看状态:
bash
python scripts/monitor.py --status
2. 配置文件
此技能使用两个主要配置文件:
- - config/whatsapp-targets.json - 定义要监控的 WhatsApp 联系人/群组
- config/feishu-settings.json - 配置飞书 API 和表格设置
配置
WhatsApp 目标
创建 config/whatsapp-targets.json:
json
{
version: 1.0,
targets: [
{
name: 项目团队聊天,
type: group, // contact 或 group
identifier: 1234567890-1234567890@g.us, // WhatsApp 群组 ID
enabled: true,
keywords: [紧急, 截止日期, 阻塞, 问题],
priority: high
},
{
name: 客户支持,
type: contact,
identifier: +1234567890@c.us, // WhatsApp 联系人 ID
enabled: true,
keywords: [投诉, 升级, 关键, 中断],
priority: medium
}
],
monitoring: {
scanintervalminutes: 5,
batch_size: 10,
maxagehours: 24,
alertonhigh_priority: true
}
}
飞书设置
创建 config/feishu-settings.json:
json
{
feishu: {
app_id: 你的应用ID,
app_secret: 你的应用密钥,
tableapptoken: 你的表格应用令牌,
table_token: 你的表格令牌
},
table: {
name: WhatsApp 监控日志,
fields: [
{name: 时间戳, type: datetime},
{name: 来源, type: text},
{name: 发送者, type: text},
{name: 消息, type: text},
{name: 匹配关键词, type: text},
{name: 优先级, type: text}
]
},
export: {
batch_threshold: 10,
schedule: 每30分钟,
retryonfailure: true,
max_retries: 3
}
}
使用工作流
设置阶段
- 1. 初始化配置 - 设置监控目标和飞书凭证
bash
python scripts/setup.py
- 2. 测试连接 - 验证 WhatsApp 和飞书 API 连接
bash
python scripts/monitor.py --test-config
- 3. 启动监控 - 开始扫描配置的聊天
bash
python scripts/monitor.py --start
OpenClaw 技能集成
在 OpenClaw 中使用此技能:
bash
加载技能(路径改为本机 Linux 上的技能目录)
openclaw skills load ~/whatsapp-monitor
或直接调用技能函数
openclaw skills run whatsapp-monitor --start
定时任务设置
通过 OpenClaw cron 设置定时监控:
yaml
创建定时任务
schedule:
kind: cron
expr:
/5 * # 每5分钟运行一次
payload:
kind: agentTurn
message: 运行 WhatsApp 消息监控
sessionTarget: isolated
实时通知配置
配置实时告警(当匹配到高优先级关键词时):
- 1. 在 config/whatsapp-targets.json 中设置:
json
{
monitoring: {
alert
onhigh_priority: true
}
}
- 2. 配置通知渠道(可选):
- 飞书机器人消息
- 电子邮件通知
- 短信告警
监控阶段
系统将:
- 1. 定期检查配置的 WhatsApp 聊天
- 过滤匹配关键词的消息
- 在本地存储匹配的消息
- 当达到批量阈值或按计划导出到飞书
导出阶段
准备导出时,系统将:
- 1. 根据表格模式格式化收集的消息
- 推送到飞书多维表格
- 成功导出后清除本地缓存
- 记录导出状态和任何错误
工具和脚本
核心监控脚本
参见 scripts/monitor.py 了解主要监控逻辑。
配置管理
参见 scripts/config.py 了解配置文件处理。
飞书 API 集成
参见 scripts/feishu_client.py 了解飞书表格操作。
WhatsApp Web 自动化
参见 scripts/whatsapp_web.py 了解 WhatsApp Web 交互。
高级功能
自定义过滤器
除了简单关键词外,还可以实现:
- - 正则表达式模式
- 情感分析
- 基于时间的规则
- 特定发送者过滤器
告警选项
配置额外的告警渠道:
- - 电子邮件通知
- Slack/Teams 消息
- 短信告警
- 推送通知
数据增强
增强收集的消息:
故障排除
常见问题
- 1. WhatsApp Web 连接 - 确保浏览器自动化正常工作
- 飞书 API 权限 - 验证应用具有正确的表格权限
- 关键词匹配 - 检查大小写敏感性和特殊字符
监控状态
查看 logs/whatsapp-monitor.log 中的监控日志,了解操作详情和错误信息。
集成示例
与其他技能结合
此技能可与以下功能结合:
- - 日历集成 - 根据消息触发日历事件
- 任务管理 - 从重要消息创建任务
- CRM 系统 - 从支持聊天更新客户记录
自动报告
设置自动报告:
安全考虑
- - 安全存储敏感凭证(使用环境变量)
- 对 API 调用实施速率限制
- 定期审计访问日志
- 考虑数据保留策略
性能优化
对于高流量监控:
- - 实施消息去重
- 对飞书使用批量 API 调用
- 优化关键词匹配算法
- 考虑对多个账户进行分布式监控
维护
定期维护任务:
- - 定期更新关键词列表
- 审查导出成功率
- 监控 API 速率限制
- 备份配置和日志
参考
有关详细的 API 文档和其他资源,请参见:
- - [飞书开放平台 API 参考](references/fe