wacli:用于自动化和历史记录查询的 WhatsApp CLI - Openclaw Skills

作者:互联网

2026-04-14

AI教程

什么是 wacli?

wacli 提供了一个通过命令行与 WhatsApp 交互的专用接口,专门用于增强 Openclaw Skills 的外部消息传递能力。它绕过了标准的聊天界面,允许以程序化方式联系第三方、自动化文件传输以及从现有消息日志中提取深度数据。

通过在 CLI 和 WhatsApp 协议之间架起桥梁,它使开发者能够构建更具沟通力和数据感知能力的代理工作流。无论是管理群组通知还是检索历史聊天上下文,该工具都能确保您的代理在 WhatsApp 生态系统中拥有所需的覆盖范围。

下载入口:https://github.com/openclaw/skills/tree/main/skills/steipete/wacli

安装与下载

1. ClawHub CLI

从源直接安装技能的最快方式。

npx clawhub@latest install wacli

2. 手动安装

将技能文件夹复制到以下位置之一

全局模式 ~/.openclaw/skills/ 工作区 /skills/

优先级:工作区 > 本地 > 内置

3. 提示词安装

将此提示词复制到 OpenClaw 即可自动安装。

请帮我使用 Clawhub 安装 wacli。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。

wacli 应用场景

  • 向外部 WhatsApp 联系人发送自动化通知或报告。
  • 在过往对话中搜索特定信息,如发票或日期。
  • 回填历史记录,用于 AI 任务中的数据分析或上下文检索。
  • 以程序化方式向群聊或个人发送文件和文档。
  • 将 WhatsApp 数据同步到本地环境以进行长期存储。
wacli 工作原理
  1. 使用 auth 命令扫描二维码进行安全身份验证,以绑定您的账号。
  2. 执行初始同步或运行持续的后台同步,以保持本地聊天数据为最新状态。
  3. 通过查询聊天列表获取特定接收者或群组的 JID。
  4. 通过标准化的 CLI 标志触发消息操作,如发送文本或文件。
  5. 利用 JSON 输出将数据传递到 Openclaw Skills 设置的其他部分进行进一步处理。

wacli 配置指南

在您的系统上安装 wacli,以便开始在 Openclaw Skills 中使用它。您可以在 macOS 上使用 Homebrew,或在任何平台上使用 Go:

# 通过 Homebrew 安装
brew tap steipete/tap
brew install wacli

# 通过 Go 安装
go install github.com/steipete/wacli/cmd/wacli@latest

安装完成后,验证您的会话以启用完整功能:

wacli auth

wacli 数据架构与分类体系

Openclaw Skills 的 wacli 集成默认使用位于 ~/.wacli 的结构化本地存储系统。数据组织如下:

组件 标识 说明
个人 JID number@s.whatsapp.net 直接消息的标准格式。
群组 JID id@g.us WhatsApp 群组的唯一标识符。
JSON 输出 --json 标志 确保数据可由代理和脚本解析。
历史存储 本地目录 包含同步的消息数据和媒体元数据。
name: wacli
description: Send WhatsApp messages to other people or search/sync WhatsApp history via the wacli CLI (not for normal user chats).
homepage: https://wacli.sh
metadata: {"clawdbot":{"emoji":"??","requires":{"bins":["wacli"]},"install":[{"id":"brew","kind":"brew","formula":"steipete/tap/wacli","bins":["wacli"],"label":"Install wacli (brew)"},{"id":"go","kind":"go","module":"github.com/steipete/wacli/cmd/wacli@latest","bins":["wacli"],"label":"Install wacli (go)"}]}}

wacli

Use wacli only when the user explicitly asks you to message someone else on WhatsApp or when they ask to sync/search WhatsApp history. Do NOT use wacli for normal user chats; Clawdbot routes WhatsApp conversations automatically. If the user is chatting with you on WhatsApp, you should not reach for this tool unless they ask you to contact a third party.

Safety

  • Require explicit recipient + message text.
  • Confirm recipient + message before sending.
  • If anything is ambiguous, ask a clarifying question.

Auth + sync

  • wacli auth (QR login + initial sync)
  • wacli sync --follow (continuous sync)
  • wacli doctor

Find chats + messages

  • wacli chats list --limit 20 --query "name or number"
  • wacli messages search "query" --limit 20 --chat
  • wacli messages search "invoice" --after 2025-01-01 --before 2025-12-31

History backfill

  • wacli history backfill --chat --requests 2 --count 50

Send

  • Text: wacli send text --to "+14155551212" --message "Hello! Are you free at 3pm?"
  • Group: wacli send text --to "1234567890-123456789@g.us" --message "Running 5 min late."
  • File: wacli send file --to "+14155551212" --file /path/agenda.pdf --caption "Agenda"

Notes

  • Store dir: ~/.wacli (override with --store).
  • Use --json for machine-readable output when parsing.
  • Backfill requires your phone online; results are best-effort.
  • WhatsApp CLI is not needed for routine user chats; it’s for messaging other people.
  • JIDs: direct chats look like @s.whatsapp.net; groups look like @g.us (use wacli chats list to find).