Connecting Google Chat
1. Cloud project and API
At https://console.cloud.google.com create (or pick) a project, note its project number, and enable the Google Chat API.
2. Service account
The bot authenticates as itself with a service account — Google Chat calls this app authentication.
-
IAM & Admin → Service Accounts → Create service account.
-
Create a JSON key and download it.
-
Push it as a secret. It contains newlines, which some tooling mangles, so the adapter also accepts base64:
wrangler secret put GOOGLE_CHAT_SERVICE_ACCOUNT # paste the JSON # or, if the newlines do not survive: base64 -i key.json | wrangler secret put GOOGLE_CHAT_SERVICE_ACCOUNT
No OAuth scopes are configured on the service account itself — the adapter names them in the assertion it signs when it mints a token:
| Scope | When |
|---|---|
https://www.googleapis.com/auth/chat.bot |
Always. Posting, editing and deleting the app's own messages, reading space memberships, and finding a 1:1 space. |
https://www.googleapis.com/auth/chat.app.messages.readonly |
Only with GOOGLE_CHAT_HISTORY=enabled. See History is opt-in. |
There is nothing more to add here. Unlike Slack, a Chat app does not
accumulate scopes: chat.bot is the app-authentication scope, and everything
an app is permitted to do falls under it. The chat.app.* family is the only
extension, every member of it needs a Workspace administrator to authorise the
app, and requesting one the administrator has not approved makes every call
fail — not just the one that needed it. So ask for chat.bot alone until a
feature actually requires more.
3. Configure the Chat app
Google Chat API → Configuration:
- App name, avatar, description.
- Functionality: enable Receive 1:1 messages and Join spaces and group conversations.
- Connection settings: HTTP endpoint URL →
https://<worker>/google-chat/events. - Authentication Audience: either App URL or Project Number. Set
GOOGLE_CHAT_AUDIENCEto match — the endpoint URL, or the project number. Comma-separate both while migrating between them. - Visibility: the people or groups who may use the app.
4. Variables
| Variable | Meaning |
|---|---|
GOOGLE_CHAT_SERVICE_ACCOUNT |
Secret. The JSON key, raw or base64. Absent ⇒ Google Chat is not configured. |
GOOGLE_CHAT_AUDIENCE |
Required. Project number or endpoint URL, matching the app's Authentication Audience. |
GOOGLE_CHAT_HISTORY |
enabled to switch on conversation.transcript(). See below. |
GOOGLE_CHAT_PATH_PREFIX |
Defaults to /google-chat. |
A service account without an audience fails the deployment rather than starting a bot that rejects every request it receives.
What Google Chat cannot do
These are hard limits of the Chat API with app credentials, not gaps in the SDK.
The adapter does not declare them, so conversation.can(...) reports false and
calling them raises UnsupportedCapabilityError:
| Capability | Why not |
|---|---|
reactions |
spaces.messages.reactions.create accepts user authentication only. An app cannot react. |
fileUpload |
media.upload likewise accepts user authentication only. Reading a file is a different matter — see below. |
typing |
Chat exposes no typing indicator to apps. |
Write handlers that guard with conversation.canSendReactions and the same bot
runs on both Slack and Google Chat unchanged.
Reading a file, but never posting one
fileDownload is declared: media.download takes the app's own scope, so
conversation.download(attachment) can read a file somebody uploaded to a
space, even though the bot cannot attach one to a reply. That asymmetry is why
uploading and downloading are two separate capabilities.
One limit: it works for files uploaded to Chat. An attachment that is a
Google Drive file is reachable only through the Drive API, behind a scope
and a consent this app never asked for, so it is refused with a
not-downloadable refusal rather than fetched.
History is opt-in
conversation.transcript() needs spaces.messages.list, which with app
credentials requires the chat.app.messages.readonly scope. That scope needs a
Workspace administrator to approve the app, and even then returns only public
messages.
Because most deployments will not have it, the capability is off by default. Set
GOOGLE_CHAT_HISTORY=enabled once the approval is in place. Until then a bot
that guards on canReadHistory simply answers without conversational context,
rather than failing with a confusing PERMISSION_DENIED.
Security
Google signs every request with an RS256 bearer token issued by
[email protected]. The adapter verifies the signature against
Google's published JWK set (cached per isolate), pins the algorithm to RS256,
and checks the issuer, audience and expiry. A request that fails gets an opaque
401, which is what Google's documentation asks for.
Differences from Slack worth knowing
- Ids are resource names. A space is
spaces/AAA, a messagespaces/AAA/messages/BBB. Do not parse them. - Ephemeral messages are Chat's private messages (
privateMessageViewer) and work the same way from a bot's side. - Prose renders as text, not as a card. The adapter only builds a card when a message actually needs buttons, images or label/value fields — a boxed two-sentence answer looks like a form.
- Editing is limited to the app's own messages, which is all a bot needs.
Related: Capabilities, Deploying a bot, Connecting Slack, Troubleshooting.