Status:可下载插件,通过 Google Chat API webhooks 支持私信 + 空间(仅 HTTP)。Documentation Index
Fetch the complete documentation index at: https://docs2.openclaw.ai/llms.txt
Use this file to discover all available pages before exploring further.
安装
在配置渠道之前安装 Google Chat:快速设置(初学者)
- 创建 Google Cloud 项目并启用 Google Chat API。
- 前往:Google Chat API Credentials
- 如果尚未启用该 API,请启用它。
- 创建 Service Account:
- 点击 Create Credentials > Service Account。
- 按你的需要命名(例如
openclaw-chat)。 - 权限留空(点击 Continue)。
- 有访问权限的主体留空(点击 Done)。
- 创建并下载 JSON Key:
- 在服务账号列表中,点击你刚创建的账号。
- 前往 Keys 标签页。
- 点击 Add Key > Create new key。
- 选择 JSON 并点击 Create。
- 将下载的 JSON 文件存储在你的 Gateway 网关主机上(例如
~/.openclaw/googlechat-service-account.json)。 - 在 Google Cloud Console Chat Configuration 中创建 Google Chat 应用:
- 填写 Application info:
- App name:(例如
OpenClaw) - Avatar URL:(例如
https://openclaw.ai/logo.png) - Description:(例如
Personal AI Assistant)
- App name:(例如
- 启用 Interactive features。
- 在 Functionality 下,勾选 Join spaces and group conversations。
- 在 Connection settings 下,选择 HTTP endpoint URL。
- 在 Triggers 下,选择 Use a common HTTP endpoint URL for all triggers,并将其设置为你的 Gateway 网关公共 URL,后接
/googlechat。- 提示:运行
openclaw status查找你的 Gateway 网关公共 URL。
- 提示:运行
- 在 Visibility 下,勾选 Make this Chat app available to specific people and groups in
<Your Domain>。 - 在文本框中输入你的电子邮件地址(例如
user@example.com)。 - 点击底部的 Save。
- 填写 Application info:
- 启用应用状态:
- 保存后,刷新页面。
- 查找 App status 部分(保存后通常在页面顶部或底部附近)。
- 将状态更改为 Live - available to users。
- 再次点击 Save。
- 使用服务账号路径 + webhook audience 配置 OpenClaw:
- 环境变量:
GOOGLE_CHAT_SERVICE_ACCOUNT_FILE=/path/to/service-account.json - 或配置:
channels.googlechat.serviceAccountFile: "/path/to/service-account.json"。
- 环境变量:
- 设置 webhook audience 类型 + 值(与你的 Chat 应用配置匹配)。
- 启动 Gateway 网关。Google Chat 会向你的 webhook 路径发送 POST 请求。
添加到 Google Chat
Gateway 网关运行且你的电子邮件已添加到可见性列表后:- 前往 Google Chat。
- 点击 Direct Messages 旁边的 +(加号)图标。
- 在搜索栏(你通常添加人员的位置)中,输入你在 Google Cloud Console 中配置的 App name。
- 注意:这个 bot 不会出现在“Marketplace”浏览列表中,因为它是私有应用。你必须按名称搜索它。
- 从结果中选择你的 bot。
- 点击 Add 或 Chat 开始一对一对话。
- 发送“Hello”以触发助手!
公共 URL(仅 Webhook)
Google Chat webhooks 需要公共 HTTPS endpoint。出于安全考虑,只将/googlechat 路径暴露到互联网。将 OpenClaw dashboard 和其他敏感 endpoint 保留在你的私有网络中。
选项 A:Tailscale Funnel(推荐)
使用 Tailscale Serve 处理私有 dashboard,并使用 Funnel 处理公共 webhook 路径。这样会保持/ 私有,同时只暴露 /googlechat。
-
检查你的 Gateway 网关绑定到了什么地址:
记下 IP 地址(例如
127.0.0.1、0.0.0.0,或你的 Tailscale IP,如100.x.x.x)。 -
仅向 tailnet 暴露 dashboard(端口 8443):
-
仅公开暴露 webhook 路径:
- 授权该节点使用 Funnel 访问: 如果系统提示,请访问输出中显示的授权 URL,在你的 tailnet 策略中为此节点启用 Funnel。
-
验证配置:
https://<node-name>.<tailnet>.ts.net/googlechat
你的私有 dashboard 保持仅 tailnet 可访问:
https://<node-name>.<tailnet>.ts.net:8443/
在 Google Chat 应用配置中使用公共 URL(不带 :8443)。
注意:此配置会在重启后保留。之后若要移除它,请运行tailscale funnel reset和tailscale serve reset。
选项 B:反向代理(Caddy)
如果你使用 Caddy 这样的反向代理,只代理特定路径:your-domain.com/ 的任何请求都会被忽略或返回 404,而 your-domain.com/googlechat 会被安全地路由到 OpenClaw。
选项 C:Cloudflare Tunnel
配置你的 tunnel ingress 规则,使其只路由 webhook 路径:- Path:
/googlechat->http://localhost:18789/googlechat - Default Rule:HTTP 404(Not Found)
工作原理
- Google Chat 向 Gateway 网关发送 webhook POST。每个请求都包含
Authorization: Bearer <token>header。- 当 header 存在时,OpenClaw 会在读取/解析完整 webhook body 之前验证 bearer auth。
- 支持在 body 中携带
authorizationEventObject.systemIdToken的 Google Workspace Add-on 请求,并使用更严格的预认证 body 预算。
- OpenClaw 根据配置的
audienceType+audience验证 token:audienceType: "app-url"→ audience 是你的 HTTPS webhook URL。audienceType: "project-number"→ audience 是 Cloud 项目编号。
- 消息按空间路由:
- 私信使用会话键
agent:<agentId>:googlechat:direct:<spaceId>。 - 空间使用会话键
agent:<agentId>:googlechat:group:<spaceId>。
- 私信使用会话键
- 默认情况下,私信访问需要配对。未知发送者会收到配对码;使用以下命令批准:
openclaw pairing approve googlechat <code>
- 群组空间默认需要 @ 提及。如果提及检测需要应用的用户名,请使用
botUser。
目标
使用这些标识符进行投递和 allowlists:- 私信:
users/<userId>(推荐)。 - 原始电子邮件
name@example.com是可变的,并且仅在channels.googlechat.dangerouslyAllowNameMatching: true时用于直接 allowlist 匹配。 - 已弃用:
users/<email>被视为用户 ID,而不是电子邮件 allowlist。 - 空间:
spaces/<spaceId>。
配置要点
- 服务账号凭据也可以通过
serviceAccount(JSON 字符串)内联传递。 - 也支持
serviceAccountRef(环境变量/文件 SecretRef),包括channels.googlechat.accounts.<id>.serviceAccountRef下的按账号 refs。 - 如果未设置
webhookPath,默认 webhook 路径为/googlechat。 dangerouslyAllowNameMatching会重新启用可变电子邮件主体匹配以用于 allowlists(应急兼容模式)。- 启用
actions.reactions后,可以通过reactions工具和channels action使用 reactions。 - 消息操作暴露
send用于文本,暴露upload-file用于显式附件发送。upload-file接受media/filePath/path,以及可选的message、filename和 thread 目标。 typingIndicator支持none、message(默认)和reaction(reaction 需要用户 OAuth)。- 附件通过 Chat API 下载,并存储在媒体 pipeline 中(大小受
mediaMaxMb限制)。
故障排除
405 Method Not Allowed
如果 Google Cloud Logs Explorer 显示如下错误:-
渠道未配置:你的配置中缺少
channels.googlechat部分。使用以下命令验证:如果返回“Config path not found”,请添加配置(参见配置要点)。 -
插件未启用:检查插件状态:
如果显示“disabled”,请将
plugins.entries.googlechat.enabled: true添加到你的配置。 -
Gateway 网关未重启:添加配置后,重启 Gateway 网关:
其他问题
- 检查
openclaw channels status --probe,查看认证错误或缺失的 audience 配置。 - 如果没有收到消息,请确认 Chat 应用的 webhook URL + event subscriptions。
- 如果提及门控阻止回复,请将
botUser设置为应用的用户资源名称,并验证requireMention。 - 发送测试消息时使用
openclaw logs --follow,查看请求是否到达 Gateway 网关。