Skip to content
广告 · 本站推荐广告

Google Chat - Google Workspace 接入

Google Chat 是 Google Workspace(原 G Suite)中的企业通讯工具。通过 Chat API 和 Service Account(服务账号)可将 OpenClaw 作为 Chat App(聊天应用)接入。

前置要求

  • Google Workspace 账号(免费 @gmail.com 不支持)
  • Google Cloud Console(Google 云控制台)项目访问权限
  • Workspace Admin(管理员)权限
  • OpenClaw Gateway(网关)已安装并运行

重要限制

Google Chat App 仅适用于 Google Workspace(付费版),个人 Gmail 账号无法使用。

配置步骤

第一步:创建项目并启用 API

  1. 访问 Google Cloud Console,创建新项目
  2. 进入 APIs & Services > Library,搜索并启用 Google Chat API

第二步:配置 Chat App

进入 Chat API > Configuration,填写 App name、Description,勾选 Receive 1:1 messagesJoin spaces and group conversations,设置 HTTP endpoint URL:

https://your-domain.com/api/channels/googlechat/webhook

第三步:创建 Service Account(服务账号)

  1. 进入 IAM & Admin > Service Accounts,创建新的 Service Account
  2. Manage keys 中创建 JSON Key,下载 Credentials(凭证)文件

安全提示

JSON Credentials 文件包含完整认证信息,妥善保管并设置权限:

bash
chmod 600 ~/.openclaw/credentials/googlechat-sa.json

第四步:Workspace Admin 审批

登录 Google Admin Console,在 Apps > Google Workspace > Google Chat 中允许你创建的应用。

第五步:配置 OpenClaw

json5
{
  channels: {
    googlechat: {
      enabled: true,
      serviceAccount: "~/.openclaw/credentials/googlechat-sa.json",
      projectId: "openclaw-chat",
      dmPolicy: "pairing"            // DM Policy(私信策略)
    }
  }
}

第六步:重启 Gateway

bash
openclaw gateway restart

Space(聊天空间)消息

json5
{
  channels: {
    googlechat: {
      spaces: {
        allowAll: false,
        allowSpaces: ["spaces/AAAA1234"],
        requireMention: true
      }
    }
  }
}

Space ID 在 Gateway 日志中显示,也可通过 Chat API 查询。

Card Messages(卡片消息)

支持 Header、TextParagraph、Image、ButtonList、Divider 等组件:

json5
{
  channels: {
    googlechat: {
      useCards: true,
      cardTheme: "default"
    }
  }
}

DM Policy(私信策略)

策略说明
pairing用户需通过 Pairing Code(配对码)验证
allowlist仅允许指定用户私聊
open所有 Workspace 用户均可私聊

配对批准:openclaw pairing approve googlechat <pairing-code>

常见问题

Chat App 不可见

确认 Workspace Admin 已审批,Chat API 已启用,审批后可能有最多 24 小时缓存延迟。

Webhook 收不到消息

确认 endpoint URL 正确且公网可访问,HTTPS 证书有效。

权限认证失败

确认 JSON 文件路径正确、Gateway 进程有读取权限、项目已启用 Chat API。

🇨🇳 中国用户须知

Google 全系列服务在中国大陆被封锁,包括 Google Chat、Cloud Console 和所有 API 端点。

不推荐在国内使用:API 端点无法直接访问,即使配置代理稳定性也难以保证。

如需使用:将 OpenClaw 部署在海外服务器(如 Google Cloud、AWS 东京/新加坡等)。

国内替代方案:企业微信、钉钉、飞书,接入方式参考 企业 IM 接入 文档。

基于MIT协议开源 | 内容翻译自 官方文档,同步更新