名称: google-messages
描述: 通过 Google Messages 网页界面 (messages.google.com) 发送和接收短信/RCS 消息。当被要求“发送短信”、“查看短信”、“SMS”、“文本消息”、“Google Messages”或将收到的短信转发到其他频道时使用。
元数据: {"openclaw": {"emoji": "💬", "requires": {"tools": ["browser"], "bins": ["node"], "env": ["SMS_NOTIFICATION_TARGET", "SMS_NOTIFICATION_CHANNEL"]}}}
使用 browser 工具,通过 messages.google.com 自动化短信/RCS 消息收发。
Google Messages for Web 允许您通过浏览器从 Android 手机发送/接收短信。本技能旨在自动化该界面。
要求:
- 安装 Google Messages 应用的 Android 手机
- 手机和电脑处于同一网络(用于初始二维码配对)
- 具有持久会话的浏览器配置文件(使用 openclaw 或您偏好的配置文件)
注意: 如果使用不同的浏览器配置文件,请将示例中的 profile=openclaw 替换为您偏好的配置文件。
| 操作 | 命令 |
|---|---|
| 打开配对页面 | browser action=open profile=openclaw targetUrl="https://messages.google.com/web/authentication" |
| 检查会话状态 | browser action=snapshot profile=openclaw — 查看是显示对话列表还是二维码 |
| 截图 | browser action=screenshot profile=openclaw |
首次设置需要扫描二维码:
打开 Google Messages 网页版
browser action=open profile=openclaw targetUrl="https://messages.google.com/web/authentication"
截图二维码并分享给用户
browser action=screenshot profile=openclaw
用户用手机扫描:
验证连接 — 快照应显示对话列表,而非二维码
重要: 勾选“记住此电脑”以保持会话持久化。
导航至对话列表
browser action=navigate profile=openclaw targetUrl="https://messages.google.com/web/conversations"
获取快照并找到对话
browser action=snapshot profile=openclaw
在对话列表中查找联系人,记下其 ref。
点击对话
browser action=act profile=openclaw request={"kind": "click", "ref": "<ref>"}
输入消息(从快照中查找文本框的 ref)
browser action=act profile=openclaw request={"kind": "type", "ref": "<input_ref>", "text": "您的消息"}
点击发送(查找发送按钮的 ref)
browser action=act profile=openclaw request={"kind": "click", "ref": "<send_ref>"}
本技能包含一个用于实时接收短信通知的 Webhook 系统。
设置环境变量:
bash
export SMS_NOTIFICATION_TARGET="telegram:YOUR_CHAT_ID"
export SMS_NOTIFICATION_CHANNEL="telegram"
启动 Webhook 服务器:
bash
node <skill>/sms-webhook-server.js
将观察者脚本注入浏览器(参见 references/observer-injection.md)
cp <skill>/systemd/google-messages-webhook.service ~/.config/systemd/user/
# 编辑服务文件:在 Environment= 中设置 SMS_NOTIFICATION_TARGET
systemctl --user daemon-reload
systemctl --user enable --now google-messages-webhook
查看 references/snippets.md 中的 JavaScript 代码片段,用于:
- 获取最近对话
- 获取当前对话中的消息
- 检查会话状态
| 问题 | 解决方案 |
|---|---|
| 显示二维码 | 会话已过期,请重新配对 |
| 找不到元素 | Google 更新了 UI,请检查快照以获取新的选择器 |
| 发送按钮禁用 | 消息输入为空或手机已断开连接 |
| 观察者未检测到消息 | 检查浏览器控制台的 [SMS Observer] 日志 |
| Webhook 未收到通知 | 验证服务器是否运行:curl http://127.0.0.1:19888/health |
Google Messages 使用 Angular 组件。这些选择器可能随更新而改变。
| 元素 | 选择器 |
|---|---|
| 对话列表 | mws-conversations-list |
| 对话项 | mws-conversation-list-item |
| 消息输入框 | textarea[aria-label*="message"] |
| 发送按钮 | button[aria-label*="Send"] |
| 二维码 | mw-qr-code |
Apache-2.0