WhatsApp Diagnostics Skill
Minimum Model
Any model. All diagnostics are CLI-based — follow the decision tree.
Diagnostic Tree (Start Here)
CODEBLOCK0
Case 1 — Connection Issue (WhatsApp not linked)
Symptom: Dashboard shows disconnected or no channel configured.
Fix:
- 1. Open agent settings in OpenClaw platform
- Go to Channels → WhatsApp → click Connect or Re-link
- Scan the QR code with WhatsApp Business app
- Confirm the phone number matches
- Wait 30 seconds for status to update
Most common cause: WhatsApp session expired (happens after ~14 days of inactivity or after a phone restart).
Case 2 — Ingest Issue (Connected but Messages = 0)
Symptom: Dashboard shows "Connected and listening" but message count stays at 0.
Meaning: WhatsApp is connected at protocol level, but messages are not reaching the agent runtime.
Fix:
CODEBLOCK1
What to look for in logs:
- - INLINECODE0
- INLINECODE1
- INLINECODE2
If any of these appear → escalate to platform admin. This is an infrastructure issue.
Case 3 — Runtime Issue (Messages arriving, no reply)
Symptom: Message count increments, but agent doesn't respond.
Meaning: Messages reach the agent, but the agent runtime is failing.
Fix:
CODEBLOCK2
Interpret results:
- -
200 → API key is valid. Problem is elsewhere (check Step 4). - INLINECODE4 → Invalid API key. Update the key in agent settings.
- INLINECODE5 → Billing error. Follow the billing-monitor skill.
Quick Health Check Script
CODEBLOCK3
When to Escalate to Platform Admin
Escalate if:
- - Gateway restart does NOT fix Messages = 0
- Logs show
socket, binding, or session errors - Multiple agents on the same server are affected at the same time
Include in your escalation message:
- - Agent name and phone number
- Time the issue started
- Output of INLINECODE9
- Messages count shown in dashboard
Prevention
| Action | Why |
|---|
| Send at least one message every 7 days | Prevents WhatsApp session expiry |
| Check Messages count during heartbeat |
Catches ingest issues early |
| Keep the phone number on record | Needed for QR re-linking |
| Don't use the same number on two devices | WhatsApp only allows one active session |
Cost Tips
- - Very cheap: All diagnostics use CLI + curl — no LLM tokens needed
- Small model OK: Any model can follow this decision tree and interpret curl output
- Avoid: Don't run diagnostics on every heartbeat — only run when the agent is not responding
- Batch: Run the Quick Health Check script once to get all info, rather than running each check separately
WhatsApp 诊断技能
最低模型要求
任意模型均可。所有诊断均基于命令行——请遵循决策树。
诊断树(从这里开始)
PA 无响应?
│
├─ 仪表盘显示已连接并监听中?
│ ├─ 是 → 检查消息数量
│ │ ├─ 消息数 = 0 → 数据摄取问题 → 转至案例 2
│ │ └─ 消息数 > 0 → 运行时问题 → 转至案例 3
│ └─ 否 → 连接问题 → 转至案例 1
│
└─ 平台中存在 Agent?
├─ 是 → 遵循案例 1
└─ 否 → 需要完整设置(参见 pa-onboarding 技能)
案例 1 — 连接问题(WhatsApp 未关联)
症状: 仪表盘显示未连接或未配置频道。
修复方法:
- 1. 在 OpenClaw 平台中打开 Agent 设置
- 进入频道 → WhatsApp → 点击连接或重新关联
- 使用 WhatsApp Business 应用扫描二维码
- 确认手机号码匹配
- 等待 30 秒让状态更新
最常见原因: WhatsApp 会话过期(约 14 天不活动或手机重启后发生)。
案例 2 — 数据摄取问题(已连接但消息数 = 0)
症状: 仪表盘显示已连接并监听中,但消息计数始终为 0。
含义: WhatsApp 在协议层面已连接,但消息未到达 Agent 运行时。
修复方法:
bash
步骤 1:检查网关状态
openclaw gateway status
步骤 2:重启网关
openclaw gateway restart
步骤 3:发送一条测试消息,等待 30 秒
步骤 4:如果计数仍为 0,检查网关日志
openclaw gateway logs --last 50
日志中需关注的内容:
- - binding failed(绑定失败)
- session dropped(会话断开)
- ingest error(摄取错误)
如果出现以上任何内容 → 升级至平台管理员。这是基础设施问题。
案例 3 — 运行时问题(消息已到达,无回复)
症状: 消息计数增加,但 Agent 不响应。
含义: 消息已到达 Agent,但 Agent 运行时出现故障。
修复方法:
bash
步骤 1:检查 Agent 日志中的计费错误
grep -i billing\|402\|credits ~/.openclaw/logs/agent.log | tail -20
如果发现计费错误 → 参见 billing-monitor 技能
步骤 2:检查 Agent 状态
openclaw status
步骤 3:验证 API 密钥(根据下方选择您的提供商)
针对 Anthropic:
curl -s -o /dev/null -w %{http_code} \
-H x-api-key: $ANTHROPIC
APIKEY \
-H anthropic-version: 2023-06-01 \
https://api.anthropic.com/v1/models
针对 OpenAI:
curl -s -o /dev/null -w %{http_code} \
-H Authorization: Bearer $OPENAI
APIKEY \
https://api.openai.com/v1/models
针对 Google:
curl -s -o /dev/null -w %{http_code} \
https://generativelanguage.googleapis.com/v1beta/models?key=$GOOGLE
APIKEY
预期结果:200。如果为 401 → 密钥无效。如果为 402 → 计费错误。
步骤 4:检查最近的运行时错误
openclaw logs --last 100 | grep -i error
结果解读:
- - 200 → API 密钥有效。问题出在其他地方(检查步骤 4)。
- 401 → API 密钥无效。在 Agent 设置中更新密钥。
- 402 → 计费错误。遵循 billing-monitor 技能。
快速健康检查脚本
bash
#!/bin/bash
whatsapp-health-check.sh
当 Agent 无响应时运行此脚本,快速获取状态概览。
echo === WhatsApp 诊断 ===
检查网关状态
echo -n 网关:
openclaw gateway status 2>&1 | grep -o running\|stopped\|error | head -1 || echo 未知
检查 API 密钥 — 从环境变量检测提供商
echo -n API 密钥:
if [ -n ${ANTHROPICAPIKEY:-} ]; then
PROVIDER=Anthropic
# 向 models 端点发送最小请求进行测试
STATUS=$(curl -s -o /dev/null -w %{http_code} \
-H x-api-key: ${ANTHROPICAPIKEY} \
-H anthropic-version: 2023-06-01 \
https://api.anthropic.com/v1/models 2>/dev/null)
elif [ -n ${OPENAIAPIKEY:-} ]; then
PROVIDER=OpenAI
STATUS=$(curl -s -o /dev/null -w %{http_code} \
-H Authorization: Bearer ${OPENAIAPIKEY} \
https://api.openai.com/v1/models 2>/dev/null)
elif [ -n ${GOOGLEAPIKEY:-} ]; then
PROVIDER=Google
STATUS=$(curl -s -o /dev/null -w %{http_code} \
https://generativelanguage.googleapis.com/v1beta/models?key=${GOOGLEAPIKEY} 2>/dev/null)
else
echo ⚠️ 未找到 API 密钥环境变量
PROVIDER=
STATUS=
fi
解读 HTTP 状态码
if [ -n $STATUS ]; then
case $STATUS in
200) echo ✅ 有效($PROVIDER) ;;
401) echo ❌ 密钥无效($PROVIDER) ;;
402) echo ⚠️ 计费错误($PROVIDER)— 参见 billing-monitor 技能 ;;
*) echo ? HTTP $STATUS($PROVIDER) ;;
esac
fi
统计 Agent 日志中的近期错误数
echo -n 近期错误数:
ERROR_COUNT=$(openclaw logs --last 100 2>/dev/null | grep -ic error || echo 0)
echo 发现 $ERROR_COUNT 个
echo === 完成 ===
何时升级至平台管理员
以下情况请升级:
- - 重启网关无法解决消息数 = 0 的问题
- 日志显示 socket、binding 或 session 错误
- 同一服务器上的多个 Agent 同时受到影响
升级消息中需包含:
- - Agent 名称和手机号码
- 问题开始时间
- openclaw gateway status 的输出
- 仪表盘中显示的消息计数
预防措施
| 操作 | 原因 |
|---|
| 每 7 天至少发送一条消息 | 防止 WhatsApp 会话过期 |
| 心跳检测时检查消息计数 |
及早发现数据摄取问题 |
| 保留手机号码记录 | 二维码重新关联时需要 |
| 不要在两台设备上使用同一号码 | WhatsApp 只允许一个活跃会话 |
成本提示
- - 非常便宜: 所有诊断均使用 CLI + curl — 无需 LLM 令牌
- 小模型可用: 任何模型都能遵循此决策树并解读 curl 输出
- 避免: 不要在每次心跳检测时运行诊断 — 仅在 Agent 无响应时运行
- 批量处理: 一次性运行快速健康检查脚本获取所有信息,而非分别运行每个检查