Status:已可透過 Google Chat API Webhook(僅 HTTP)用於 DM + space。Documentation Index
Fetch the complete documentation index at: https://docs.openclaw.ai/llms.txt
Use this file to discover all available pages before exploring further.
快速設定(初學者)
- 建立 Google Cloud 專案並啟用 Google Chat API。
- 前往:Google Chat API Credentials
- 如果尚未啟用 API,請啟用它。
- 建立 Service Account:
- 按 Create Credentials > Service Account。
- 依喜好命名(例如
openclaw-chat)。 - 權限留空(按 Continue)。
- 可存取的主體留空(按 Done)。
- 建立並下載 JSON Key:
- 在 Service Account 清單中,點選你剛建立的那一個。
- 前往 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。
- 使用 Service Account 路徑 + Webhook audience 設定 OpenClaw:
- Env:
GOOGLE_CHAT_SERVICE_ACCOUNT_FILE=/path/to/service-account.json - 或 config:
channels.googlechat.serviceAccountFile: "/path/to/service-account.json"。
- Env:
- 設定 Webhook audience 類型 + 值(需符合你的 Chat 應用程式設定)。
- 啟動 Gateway。Google Chat 會將 POST 傳送到你的 Webhook 路徑。
新增到 Google Chat
Gateway 執行中且你的電子郵件已新增至可見性清單後:- 前往 Google Chat。
- 點選 Direct Messages 旁的 +(加號)圖示。
- 在搜尋列(你通常新增使用者的位置)中,輸入你在 Google Cloud Console 中設定的 App name。
- 注意:機器人不會出現在「Marketplace」瀏覽清單中,因為它是私人應用程式。你必須依名稱搜尋它。
- 從結果中選取你的機器人。
- 點選 Add 或 Chat 以開始 1:1 對話。
- 傳送「Hello」以觸發助理!
公開 URL(僅 Webhook)
Google Chat Webhook 需要公開 HTTPS 端點。為了安全性,只將/googlechat 路徑暴露到網際網路。請將 OpenClaw 儀表板與其他敏感端點保留在你的私人網路上。
選項 A:Tailscale Funnel(建議)
使用 Tailscale Serve 提供私人儀表板,並使用 Funnel 提供公開 Webhook 路徑。這會讓/ 保持私有,同時只暴露 /googlechat。
-
檢查你的 Gateway 綁定到哪個位址:
注意 IP 位址(例如
127.0.0.1、0.0.0.0,或你的 Tailscale IP,例如100.x.x.x)。 -
只將儀表板暴露給 tailnet(連接埠 8443):
-
只公開暴露 Webhook 路徑:
- 授權 Node 以取得 Funnel 存取權: 如果出現提示,請造訪輸出中顯示的授權 URL,以在你的 tailnet policy 中為此 Node 啟用 Funnel。
-
驗證設定:
https://<node-name>.<tailnet>.ts.net/googlechat
你的私人儀表板會維持僅限 tailnet:
https://<node-name>.<tailnet>.ts.net:8443/
在 Google Chat 應用程式設定中使用公開 URL(不含 :8443)。
注意:此設定會在重新開機後保留。若要稍後移除它,請執行tailscale funnel reset和tailscale serve reset。
選項 B:反向 Proxy(Caddy)
如果你使用像 Caddy 這樣的反向 Proxy,只 Proxy 特定路徑: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 會將 Webhook POST 傳送到 Gateway。每個請求都包含
Authorization: Bearer <token>標頭。- OpenClaw 會在讀取/剖析完整 Webhook body 之前,先在標頭存在時驗證 bearer auth。
- 支援在 body 中攜帶
authorizationEventObject.systemIdToken的 Google Workspace Add-on 請求,並使用更嚴格的 pre-auth body budget。
- OpenClaw 會依設定的
audienceType+audience驗證 token:audienceType: "app-url"→ audience 是你的 HTTPS Webhook URL。audienceType: "project-number"→ audience 是 Cloud 專案編號。
- 訊息會依 space 路由:
- DM 使用 session key
agent:<agentId>:googlechat:direct:<spaceId>。 - Space 使用 session key
agent:<agentId>:googlechat:group:<spaceId>。
- DM 使用 session key
- DM 存取預設使用 pairing。未知傳送者會收到 pairing code;使用下列指令核准:
openclaw pairing approve googlechat <code>
- 群組 space 預設需要 @-mention。如果提及偵測需要應用程式的使用者名稱,請使用
botUser。
目標
使用這些識別碼進行傳送與 allowlist:- 直接訊息:
users/<userId>(建議)。 - 原始電子郵件
name@example.com是可變的,且只有在channels.googlechat.dangerouslyAllowNameMatching: true時才用於直接 allowlist 比對。 - 已棄用:
users/<email>會被視為使用者 ID,而不是電子郵件 allowlist。 - Space:
spaces/<spaceId>。
Config 重點
- Service Account 認證也可以用
serviceAccount(JSON 字串)內嵌傳入。 - 也支援
serviceAccountRef(env/file SecretRef),包含channels.googlechat.accounts.<id>.serviceAccountRef下的個別 account ref。 - 如果未設定
webhookPath,預設 Webhook 路徑是/googlechat。 dangerouslyAllowNameMatching會重新啟用 allowlist 的可變電子郵件主體比對(緊急相容模式)。- 啟用
actions.reactions時,可透過reactions工具與channels action使用 reaction。 - 訊息 action 會公開
send以傳送文字,以及upload-file以明確傳送附件。upload-file接受media/filePath/path,以及可選的message、filename和 thread target。 typingIndicator支援none、message(預設)和reaction(reaction 需要使用者 OAuth)。- 附件會透過 Chat API 下載,並儲存在 media pipeline 中(大小受
mediaMaxMb限制)。
疑難排解
405 Method Not Allowed
如果 Google Cloud Logs Explorer 顯示如下錯誤:-
尚未設定 channel:你的 config 中缺少
channels.googlechat區段。使用下列指令驗證:如果傳回「Config path not found」,請新增設定(見 Config 重點)。 -
Plugin 未啟用:檢查 Plugin 狀態:
如果顯示「disabled」,請將
plugins.entries.googlechat.enabled: true新增到你的 config。 -
Gateway 未重新啟動:新增 config 後,重新啟動 Gateway:
其他問題
- 檢查
openclaw channels status --probe是否有 auth 錯誤或缺少 audience config。 - 如果沒有收到訊息,請確認 Chat 應用程式的 Webhook URL + 事件訂閱。
- 如果 mention gating 阻擋回覆,請將
botUser設為應用程式的使用者資源名稱,並驗證requireMention。 - 傳送測試訊息時使用
openclaw logs --follow,查看請求是否抵達 Gateway。
相關
- Channels Overview — 所有支援的 channel
- Pairing — DM 驗證與 pairing 流程
- Groups — 群組聊天行為與 mention gating
- Channel Routing — 訊息的 session 路由
- Security — 存取模型與強化