What this enables
Connecting Google Chat allows Cake Agents to:- start a Cake session when a user sends the Cake Agents app a direct message
- start a Cake session when a user @-mentions the app at the start of a message in a space
- stream agent output back into the Google Chat thread
- read attachments sent with the message
How Google Chat sessions work
When a user sends a direct message or starts a message with an @-mention of the app, Cake Agents creates a new session and replies with a link to it. Follow-up messages in the same thread go to the same session. Sessions started from a direct message are private by default. Cake Agents identifies the Google Chat user by email. If no Cake user with that email exists, Cake Agents creates one. If the user hasn’t linked GitHub, the reply includes a Link GitHub link so Cake can open pull requests and push commits for them. See Link GitHub.Admin responsibilities
Unlike the GitHub, Linear, and Slack integrations, you create the Google Chat app from the command line with the Google Cloud CLI. As an admin, you are responsible for:- creating a Google Group for the people who can use the app
- running the Cake Agents setup script, which creates a Google Cloud project, configures the Chat app, and creates a service account key
- pasting the script’s output into Cake Agents
- keeping the credentials up to date if you rotate the service account key
Requirements
- You need the admin role in Cake Agents.
- Google must be able to reach your Cake Agents instance. Google Chat sends events to
https://<your-cake-host>/api/webhooks/gchat. Deployments that disable public ingress return404for these events. - The Google Cloud CLI (
gcloud) must be installed, including thebetacomponent. - You must be signed in to
gcloudas a user (gcloud auth login), not a service account, with permission to create Google Cloud projects. - The setup script,
create-gchat-app.sh. For now, a member of the Cake team shares the script with you directly. - A Google Group whose members can use the app. See Choose who can use the app.
Instructions
Choose who can use the app
Cake Agents isn’t published to the Google Workspace Marketplace. Instead, the setup script allowlists the users and groups that can use the app in your Google Workspace. Anyone not on the allowlist can’t message the app. Create a Google Group for the people who should use Cake Agents in Google Chat, and pass the group’s email to the script. To give someone access later, add them to the group. You don’t need to run the script again.Run the setup script
Run the script with three arguments:
The script:
- Creates the Google Cloud project and sets it as your active
gcloudproject. - Enables the Google Chat, Google Workspace add-ons, and IAM APIs.
- Configures the Chat app with the display name Cake Agents, the endpoint
<base-url>/api/webhooks/gchat, and support for spaces with multiple users, and allowlists the principals you passed. - Creates a service account named
cake-agents-gchatand a key for it. - Prints two values you need in the next step:
- a line starting with
workspaceAddOnServiceAccountEmail:, followed by an address likeservice-<project-number>@gcp-sa-gsuiteaddons.iam.gserviceaccount.com - the service account key as a JSON object
- a line starting with
Save the credentials in Cake Agents
- In Cake Agents, go to
Settings → Organization → Integrations. - Next to Google Chat, select Connect.
- In Service Account Email, paste the address printed after
workspaceAddOnServiceAccountEmail:. Cake Agents saves the field when you leave it. - Expand Credentials JSON, paste the service account key JSON, and select Save.
Set the bot user ID
Cake Agents needs the Chat app’s own user ID (users/<number>) to recognize @-mentions in spaces. Until the Bot User ID field is set, Cake Agents ignores @-mentions.
Cake Agents fills in Bot User ID automatically when the app is added to a space or someone opens a direct message with it. After setup, add the app to a space or open a direct message with it as one of the allowed principals, then check that the field has a value. You can also paste the ID yourself.
Rotate or update credentials
To rotate the service account key:- Create a new key for the
cake-agents-gchatservice account in your Google Cloud project. - In Cake Agents, go to
Settings → Organization → Integrationsand select Connected next to Google Chat. - Expand Credentials JSON, paste the new key, and select Save.
Troubleshooting
The app doesn’t respond to @-mentions in a space
The Bot User ID field is empty. To fill it in, add the app to a space or open a direct message with it. If the app is already in the space, remove it and add it again. You can also paste the app’susers/<number> ID into the field.
The app doesn’t respond to direct messages
Check that Google can reachhttps://<your-cake-host>/api/webhooks/gchat and that public ingress is enabled. Cake Agents verifies each request against the saved Service Account Email, so also check that the field matches the address the setup script printed.