OpenClaw Google Chat 渠道
通过 Google Chat API 的 HTTP 端点将 OpenClaw 连接到 Google Chat。此企业级集成让你的 AI 助手可以在 Google Workspace 中运行 — 处理私聊消息和空间(Space)对话。机器人通过接收来自 Google Chat 的 HTTP POST 请求,使用服务账号验证 Bearer 令牌,并通过 OpenClaw Gateway 路由消息。
Google Chat 支持的功能
文本消息
支持
媒体与文件
支持
消息反应
支持
消息线程
支持
语音消息
不支持
群聊
支持
Google Chat 前置条件
- Google Workspace 账号(Business 或 Enterprise 版本)。域管理员权限可能在授权范围审批和应用可见性设置时需要
- 已启用 Google Chat API 的 Google Cloud 项目
- 已创建服务账号并生成 JSON 密钥文件
- OpenClaw Gateway 已运行并配置
- 可公开访问的 HTTPS 端点用于 Webhook(如 Tailscale Funnel、Caddy 或 Cloudflare Tunnel)
Google Chat 快速设置
启用 Google Chat API 并创建服务账号
前往 Google Cloud Console,启用 Google Chat API。创建新的服务账号(如 'openclaw-chat'),跳过权限配置,然后生成并下载 JSON 密钥文件。将文件存储在 Gateway 主机上(如 ~/.openclaw/googlechat-service-account.json)。
在 Google Cloud Console 配置 Chat 应用
在 Google Cloud Console 的 Chat 配置页面,设置应用名称、头像 URL 和描述。启用交互式功能,允许应用加入空间和群组对话。选择 'HTTP 端点 URL' 作为连接设置,输入 Gateway 的公网 URL 加上 '/googlechat'(使用 'openclaw status' 查看 Gateway URL)。
设置可见性、启用应用并测试
将应用可见性限制为域内的特定用户或群组。保存配置,刷新页面,将应用状态更改为「上线 — 对用户可用」。在 Google Chat 中,点击「私信」旁的「+」图标,搜索你的应用名称,发送测试消息。
Google Chat 配置示例
{
"channels": {
"googlechat": {
"serviceAccountFile": "~/.openclaw/googlechat-service-account.json",
"webhookPath": "/googlechat"
}
}
}Google Chat 深入了解
架构概述
服务账号设置
{
"channels": {
"googlechat": {
"serviceAccountFile": "~/.openclaw/googlechat-service-account.json"
}
}
}Chat 应用配置
公网 URL 与 Webhook 配置
# Tailscale Funnel 示例:
tailscale funnel --set-path=/googlechat localhost:18789
# Caddy 示例:
reverse_proxy /googlechat* localhost:18789
# Cloudflare Tunnel 入口配置:
- hostname: your-domain.com
path: /googlechat
service: http://localhost:18789
- service: http_status:404私聊与群组策略
{
"channels": {
"googlechat": {
"dmPolicy": "pairing",
"groupPolicy": "allowlist",
"groupAllowList": ["spaces/AAAA1234"]
}
}
}目标与会话路由
{
"channels": {
"googlechat": {
"botUser": "users/123456789",
"spaces": {
"spaces/AAAA1234": {
"systemPrompt": "你是工程团队的得力助手。"
}
}
}
}
}Google Chat 配置参考
| Key | Type | Default | Description |
|---|---|---|---|
| serviceAccountFile | string | "" | Google Cloud 服务账号 JSON 密钥文件路径 |
| audience | string | "app-url" | Bearer 令牌验证的受众类型。设为 app-url 时,Google Chat 发送 OIDC ID token;设为 project-number 时,发送自签名 JWT。选项:app-url、project-number |
| audienceValue | string | "" | 用于令牌验证的受众值(URL 或项目编号) |
| webhookPath | string | "/googlechat" | 接收 Google Chat Webhook 的 HTTP 端点路径 |
| botUser | string | "" | 机器人用户标识符(users/<id>),用于空间中的 @提及检测 |
| dmPolicy | string | "pairing" | 控制谁可以给机器人发私信。选项:pairing、allowlist、open、disabled |
| allowFrom | string[] | [] | 允许给机器人发消息的用户 ID 或邮箱(dmPolicy 为 allowlist 时生效) |
| groupPolicy | string | "disabled" | 群组空间策略。选项:disabled、allowlist、open |
| groupAllowList | string[] | [] | groupPolicy 为 allowlist 时允许的空间 ID |
| spaces.<id>.systemPrompt | string | "" | 特定 Google Chat 空间的自定义 AI 系统提示 |
| mediaMaxMb | number | 20 | 最大媒体文件大小(兆字节) |
| actions.typing | boolean | true | AI 生成回复时发送输入指示器 |
Google Cloud 服务账号 JSON 密钥文件路径
Bearer 令牌验证的受众类型。设为 app-url 时,Google Chat 发送 OIDC ID token;设为 project-number 时,发送自签名 JWT。选项:app-url、project-number
用于令牌验证的受众值(URL 或项目编号)
接收 Google Chat Webhook 的 HTTP 端点路径
机器人用户标识符(users/<id>),用于空间中的 @提及检测
控制谁可以给机器人发私信。选项:pairing、allowlist、open、disabled
允许给机器人发消息的用户 ID 或邮箱(dmPolicy 为 allowlist 时生效)
群组空间策略。选项:disabled、allowlist、open
groupPolicy 为 allowlist 时允许的空间 ID
特定 Google Chat 空间的自定义 AI 系统提示
最大媒体文件大小(兆字节)
AI 生成回复时发送输入指示器
Google Chat 常见问题
Google Chat 故障排查
Google Chat 插件未启用、channels.googlechat 配置段缺失,或 Gateway 在配置更改后未重启。
服务账号文件路径不正确、受众设置不匹配,或 Bearer 令牌已过期。
未配置机器人用户标识符用于 @提及检测,或空间不在允许列表中。
公网 URL 未正确配置、防火墙阻止了入站连接,或 SSL 证书无效。