简介
一个将OpenClaw AI代理连接至WhatsApp的开源桥接工具,能实现自动回复、消息管理和上下文分析,但存在严重命令注入漏洞。
原始描述
WhatsApp bridge for OpenClaw — send/receive messages, auto-reply agents, QR pairing, message search, contact sync
中文使用说明 来自收录源
openclaw-whatsapp:将AI代理无缝集成至WhatsApp的开源桥接工具
核心用法
openclaw-whatsapp 是一款基于 Go 语言开发的开源桥接工具,旨在将 OpenClaw AI 代理接入 WhatsApp 生态。用户通过简单的命令行安装和配置,即可在本地搭建一个完整的消息处理服务。其核心功能包括:通过扫码链接 WhatsApp 账号、接收和发送文本消息、基于AI代理的自动回复(支持自定义系统提示词)、消息全文搜索以及联系人同步。架构上,它采用桥接层、通知脚本和工作处理器的三层设计,实现了消息的异步处理、去重和持久化队列,避免了竞态条件并提供了崩溃恢复能力。
显著优点
该工具的安装和配置流程文档详尽,从二进制安装到systemd服务创建,为用户提供了清晰的自助指引。其架构设计考虑了并发安全(文件锁、单工作线程)和容错性(队列持久化、自断重连),适合需要稳定运行的后台服务场景。此外,通过内置的API接口和allowlist/blocklist机制,赋予用户灵活的集成与控制能力,能够将WhatsApp消息智能地分发至企业级AI工作流中,理论上可大幅提升客服、销售自动化等场景的响应效率。
潜在缺点或局限性
根据最新安全审计报告,该工具存在一个致命级高危漏洞:wa-notify-worker.sh 脚本中未使用引用型heredoc,导致攻击者可通过向绑定的WhatsApp号码发送包含命令替换语法(如 $(恶意指令))的特殊消息,在宿主服务器上执行任意系统命令。这意味着当前版本不仅无法安全使用,反而可能成为服务器被入侵的入口。同时,安装指南中使用 curl | bash 模式且未提供完整性校验,供应链风险极高。最后,作为个人开发者维护的低活跃度项目,其长期功能更新和安全响应能力存疑。
适合的目标群体
该工具适合具备较强系统管理经验的技术用户,如运维工程师或全栈开发者,他们需要在后续自行修复安全漏洞后构建私有的WhatsApp自动化方案。对需要为OpenClaw生态寻找WhatsApp接口插件的高级AI开发者亦有参考价值。鉴于当前安全风险,完全不建议普通商业用户、企业环境或无专业安全团队的角色直接采用现成代码。
使用该技能可能存在的常规风险
- 安全风险(当前极危):存在经WhatsApp消息触发的本地命令注入,可导致服务器完全沦陷。
- 供应链风险:采用未经验证的
curl | bash安装方式,源码仓库由伪匿名个人账号维护,信誉极低且无后续维护活动,代码被恶意篡改的风险长期存在。 - 隐私与权限:WhatsApp会话数据和消息历史以明文形式存储在本地磁盘,临时队列和日志文件位于全局可读的
/tmp目录,在多用户共享环境中存在数据泄露风险。 - 依赖与配置:安装过程需使用
sudo权限,且依赖 Python3、jq、curl 及 OpenClaw 等环境,部署不当可能影响系统稳定性。 - 合规风险:项目未能满足GDPR的“用户知情同意”等合规要求,直接用于处理外部客户数据可能引发法律风险。
技能正文
name: openclaw-whatsapp description: WhatsApp bridge for OpenClaw — send/receive messages, auto-reply agents, QR pairing, message search, contact sync
openclaw-whatsapp
WhatsApp bridge that connects OpenClaw agents to WhatsApp. Send messages, auto-reply to DMs with AI, search message history, and sync contacts — all from a single Go binary.
Quick Reference
# Check status
openclaw-whatsapp status
# Send a message
openclaw-whatsapp send "NUMBER@s.whatsapp.net" "Your message"
# View logs (if running as service)
journalctl --user -u openclaw-whatsapp.service -f
# View worker logs
tail -f /tmp/openclaw-wa-agent/worker.log
Full Setup (Self-Service)
Follow these steps to set up WhatsApp auto-reply from scratch.
Step 1: Install the binary
curl -fsSL https://raw.githubusercontent.com/0xs4m1337/openclaw-whatsapp/main/install.sh | bash
Verify installation:
openclaw-whatsapp version
Step 2: Find your openclaw binary path
which openclaw
# Example output: /home/USER/.nvm/versions/node/v22.22.0/bin/openclaw
Save this path — you'll need it in Step 4.
Step 3: Install relay scripts
Copy scripts from this skill directory:
SKILL_DIR="$(dirname "$(realpath "$0")")" # or use absolute path to skill
# Copy scripts
sudo cp "$SKILL_DIR/scripts/wa-notify.sh" /usr/local/bin/wa-notify.sh
sudo cp "$SKILL_DIR/scripts/wa-notify-worker.sh" /usr/local/bin/wa-notify-worker.sh
sudo chmod +x /usr/local/bin/wa-notify.sh /usr/local/bin/wa-notify-worker.sh
Or if running as agent, use the skill directory path directly:
cp ~/clawd/skills/openclaw-whatsapp/scripts/wa-notify.sh /usr/local/bin/
cp ~/clawd/skills/openclaw-whatsapp/scripts/wa-notify-worker.sh /usr/local/bin/
chmod +x /usr/local/bin/wa-notify.sh /usr/local/bin/wa-notify-worker.sh
Step 4: Configure the worker script
Edit /usr/local/bin/wa-notify-worker.sh and update the PATH line with your openclaw binary path from Step 2:
# Find this line near the top:
export PATH="/home/oussama/.nvm/versions/node/v22.22.0/bin:$PATH"
# Change it to your actual path:
export PATH="/home/YOUR_USER/.nvm/versions/node/vXX.XX.X/bin:$PATH"
Also update the worker script path in /usr/local/bin/wa-notify.sh:
# Find this line near the bottom:
nohup /home/oussama/dev/openclaw-whatsapp/scripts/wa-notify-worker.sh
# Change to:
nohup /usr/local/bin/wa-notify-worker.sh
Step 5: Create config file
mkdir -p ~/.openclaw-whatsapp
cat > ~/.openclaw-whatsapp/config.yaml << 'EOF'
port: 8555
data_dir: ~/.openclaw-whatsapp
auto_reconnect: true
reconnect_interval: 30s
log_level: info
agent:
enabled: true
mode: "command"
command: "/usr/local/bin/wa-notify.sh '{name}' '{message}' '{chat_jid}' '{message_id}'"
ignore_from_me: true
dm_only: true
timeout: 30s
system_prompt: |
You are a helpful WhatsApp assistant. Be concise and natural.
EOF
Step 6: Create systemd service (recommended)
mkdir -p ~/.config/systemd/user
cat > ~/.config/systemd/user/openclaw-whatsapp.service << 'EOF'
[Unit]
Description=OpenClaw WhatsApp Bridge
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/openclaw-whatsapp start -c %h/.openclaw-whatsapp/config.yaml
Restart=always
RestartSec=5
[Install]
WantedBy=default.target
EOF
systemctl --user daemon-reload
systemctl --user enable openclaw-whatsapp.service
systemctl --user start openclaw-whatsapp.service
Step 7: Link WhatsApp
- Check bridge is running:
openclaw-whatsapp status - Open QR page:
http://localhost:8555/qr - On your phone: WhatsApp → Settings → Linked Devices → Link a Device
- Scan the QR code
Step 8: Test
Send a WhatsApp message to the linked number from another phone. Check:
# Bridge logs
journalctl --user -u openclaw-whatsapp.service -n 20
# Worker logs
cat /tmp/openclaw-wa-agent/worker.log
Architecture
WhatsApp DM → Bridge → wa-notify.sh (enqueue)
→ wa-notify-worker.sh (background, file-locked)
→ Fetches last 10 messages for context
→ openclaw agent (processes message)
→ openclaw-whatsapp send <JID> <reply>
→ WhatsApp reply sent
Key features:
- Fast enqueue — bridge doesn't wait for agent processing
- Deduplication — message IDs tracked to prevent double-replies
- Single worker — file-locked, sequential processing, no race conditions
- Crash resilience — queue persists across restarts
Customizing System Prompt
Edit ~/.openclaw-whatsapp/config.yaml and update the system_prompt field:
agent:
system_prompt: |
You are a sales assistant for Acme Corp.
Be friendly and professional.
When someone wants to book a demo:
- Book via: mcporter call composio.GOOGLECALENDAR_CREATE_EVENT ...
- Notify team via: message action=send channel=telegram target=CHAT_ID ...
Restart after changes:
systemctl --user restart openclaw-whatsapp.service
Allowlist / Blocklist
Restrict which numbers the agent responds to:
agent:
allowlist: ["971586971337"] # only these (empty = all)
blocklist: ["spammer123"] # never these
CLI Reference
openclaw-whatsapp start [-c config.yaml] # Start the bridge
openclaw-whatsapp status [--addr URL] # Check connection status
openclaw-whatsapp send NUMBER MESSAGE # Send a message
openclaw-whatsapp stop # Stop the bridge
openclaw-whatsapp version # Print version
Troubleshooting
| Problem | Solution |
|---|---|
| QR expired | Refresh http://localhost:8555/qr — auto-refreshes every 3s |
| Bridge disconnected | openclaw-whatsapp status; auto-reconnects by default |
| Agent not replying | Check /tmp/openclaw-wa-agent/worker.log for errors |
| "stream replaced" errors | Multiple bridge instances — ensure only one runs (systemctl --user status openclaw-whatsapp + pgrep openclaw-whatsapp) |
| "openclaw: not found" | Edit wa-notify-worker.sh PATH to include openclaw binary |
| "not logged in" | Scan QR again — session expired |
Files
| Path | Description |
|---|---|
~/.openclaw-whatsapp/config.yaml |
Bridge configuration |
~/.openclaw-whatsapp/messages.db |
SQLite message store |
~/.openclaw-whatsapp/sessions/ |
WhatsApp session data |
/tmp/openclaw-wa-agent/queue.jsonl |
Message queue |
/tmp/openclaw-wa-agent/worker.log |
Worker logs |
/tmp/openclaw-wa-agent/seen_message_ids.txt |
Deduplication list |
API Endpoints
| Method | Path | Description |
|---|---|---|
GET |
/status |
Connection status |
GET |
/qr |
QR code page |
POST |
/send/text |
Send message {"to": "...", "message": "..."} |
GET |
/chats |
List all chats |
GET |
/chats/{jid}/messages?limit=10 |
Messages for a chat |
GET |
/messages/search?q=keyword |
Full-text search |
See references/api-reference.md for full API docs.
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。