Connect Google Chat
This guide connects a Google Chat app in a Google Cloud project you control to a CatalEx agent. People then mention the app in a space, or message it directly, and get the agent's replies in Google Chat.
Setup takes about 13 minutes: each step shows its own estimate. A new setup needs two files from Google Cloud, a service-account key and an OAuth client. CatalEx refuses to connect without both.
In the app
Open Add channel for the agent, as Messaging channels describes, choose Google Chat, then the New card. CatalEx shows six numbered steps, each with its buttons, the text to copy and a Guide link back to this page. To set up an app with no agent, use Settings › Channels › Add channel › Google Chat › Continue instead and give it to an agent later with Add channel › Existing.
1. Check you can
You need:
- A Google Workspace Business or Enterprise account, signed in to Google Cloud. Personal Gmail accounts can't use Google Chat apps.
- A Google Cloud organization that lets you create a project and download a service-account key. Organizations created since May 2024 refuse key downloads by default. You'll find out in the next step, before you set up the app.
- An agent added to CatalEx, and CatalEx signed in to your CatalEx account.
2. Create the project and key
- Choose Create a project, enter any name, then choose Create.
- Choose Turn on the Chat API. Check that your new project is selected at the top of the page, then choose Enable.
- Choose Make the key and create a service account with any name. Open it, then choose Keys › Add key › Create new key › JSON › Create. A key file downloads.
Keep the key file private. Don't share it or paste it anywhere except CatalEx.
If Google says Service account key creation is disabled, or won't let you create a project, setup can't finish with this account. Close the setup (CatalEx doesn't keep it) and use a Workspace account whose organization allows both.
3. Name the Chat app
Choose Open Chat app settings. Copy App name (CatalEx), Avatar URL and Description ("Talks with your CatalEx agent") into Google's form with each value's Copy button. A description can be at most 40 characters.
If the form is read-only, you're in a project you didn't create. Select your new project at the top of the page, or ask a project Owner for the Editor role.
4. Connect the Chat app
In the same form:
- Keep Build this Chat app as a Workspace add-on selected.
- Turn on Enable interactive features, then select Join spaces and group conversations.
- Under Connection settings, choose HTTP endpoint URL. Under Triggers, choose Use a common HTTP endpoint URL for all triggers, then paste the HTTP endpoint URL from CatalEx.
- Under Visibility, enter your email address, then choose Save.
5. Let people allow file uploads
A Chat app can't upload a file as itself; Google accepts uploads only from a person. So each person allows CatalEx once to post files for them, through an OAuth client in the Chat app's project.
- Choose Open the consent screen and create the consent screen with user type Internal. Only people in your organization can then allow uploads, and Google needs no review.
- Choose Open credentials and create an OAuth client ID of type Web application.
- Under Authorized redirect URIs, add the Authorized redirect URI CatalEx shows. It looks like
https://HOST/apps/googlechat/INSTALLATION/files/allowed. - Download the client's JSON file and keep it private.
New setups require this client: Connect Google Chat in the next step says "Choose the OAuth client file." and sends nothing until you add it. An app set up before this rule works without one, but files from agents aren't delivered; see Turn on file uploads for an existing app.
6. Connect in CatalEx
-
Enter your Cloud project number, digits only. It is on your project's Dashboard in Google Cloud.
-
For Service-account key, choose the key file from step 2. For OAuth client, choose the JSON file from step 5. Choose Connect Google Chat.
CatalEx refuses a wrong file before saving anything, for example "This file is not a Web application OAuth client. Choose the JSON file you downloaded for the OAuth client." or "This file is not a service-account key. Choose the JSON key file you downloaded from the Google Cloud console." If Google doesn't accept the key, nothing is saved; make a new key and try again.
-
CatalEx shows a code. Choose Copy code. In Google Chat, open a direct message with the app and send exactly that code. The app answers that you're linked. The code works once.
-
Choose Verify. If no message has arrived yet, CatalEx says "No message has arrived yet." Once it says Connected, choose Open Google Chat and message the app there.
The agent now has the Google Chat channel, and its Settings open on the Channels tab. Only you can use the app: anyone else gets "This app was connected by someone else, so only they can use it here." Until you send the code, everyone gets "This app needs whoever connected it to finish setup before it can answer."
With the CLI
Run these on the computer that runs the agent, signed in to your CatalEx account. catalex agents list shows the agent IDs. Connect channels with an AI agent has the same steps with every expected result.
-
Add the app for the agent:
catalex channels add --agent AGENT_ID --type googlechat --newExpected:
Next: set it up:followed bycatalex destinations setup ACCOUNT_ID --googlechat. -
Prepare the setup:
catalex destinations setup ACCOUNT_ID --googlechat --action prepareExpected: a
Callback:line with the HTTP endpoint URL, then the numbered steps with their console links. Do steps 1 to 5 above in Google Cloud, using that endpoint URL and the redirect URI it shows. -
Send the project number, the key and the OAuth client as downloaded. Keep both files private (mode 0600);
--input-stdin service_account_keyor--input-stdin oauth_clientreads one from a pipe, and a secret passed with--valueis refused:catalex destinations setup ACCOUNT_ID --googlechat --action authorize --value project_number=PROJECT_NUMBER --input-file service_account_key=/absolute/path/to/chat-key.json --input-file oauth_client=/absolute/path/to/chat-client.jsonExpected: the first line ends
(committed), thenCode to send the app:. Nothing is saved unless Google accepts the key. Send exactly that code to the app in a Google Chat direct message. -
Check the connection:
catalex destinations setup ACCOUNT_ID --googlechat --action verifyExpected: the first line ends
(verified). Until the code arrives,--jsonshowsCALLBACK_CHECK_PENDING.
Use the app in a space
- In a space, mention the app to start a thread, such as
@CatalEx check the build. - The app replies "Received" in the thread and keeps that one message up to date: "Working" while the agent works, "Waiting" while the request is queued or the agent's computer is offline, and "Needs your decision" while a question or permission waits. The agent's progress appears in the same message.
- The final reply is a new message that starts by mentioning you. It ends with a View conversation link (see Replies in messaging apps).
- To continue, reply in the thread and mention the app again.
Google Chat sends the app only messages that mention it. The agent doesn't see anything else posted in the thread, including other people's replies. To give the agent something said there, quote or paste it into the message that mentions the app.
In a thread, mention the app and then a command, such as @CatalEx /stop. Use /stop and the card buttons; the commands that take a MESSAGE_ID (/stop MESSAGE_ID, /answer MESSAGE_ID TEXT, /quote MESSAGE_ID TEXT) need a message name that only the Chat API shows.
Commands work while the agent's Chat commands switch is on for its Google Chat channel, which is the default. Off, a message that starts with / reaches the agent as ordinary text and CatalEx sends no reply. CatalEx's own notices, such as waiting and failure notices, follow the Send system messages to people switch, also on by default. Both are in the agent's Settings › Channels panel for Google Chat, beside Engagement; Google Chat has no allowed or blocked lists and no limits there. See Messaging channels.
Direct messages
Message the app directly, without mentioning it. A group chat (several people, without a space name) reaches no agent: the group gets at most one post saying "This app doesn't work in group chats, so nothing was sent to the agent. Message it directly instead." Use a direct message, or mention the app in a space. Adding the app in a direct message gets the same reply as /help. Replies appear in the direct message, and each progress update is its own message. Commands: /help, /agents, /switch, /sessions, /saved, /new, /status, and /cancel or /stop. To send text that starts with / to the agent, begin it with // (with Chat commands off, the text goes to the agent exactly as typed, // included).
Questions and permissions
A question or permission request arrives as a card with a button for each choice and Cancel turn. A question that accepts a typed answer adds Your answer and Send answer. A form opens from Answer form. Notifications and clients that can't show cards get the choices as a list.
Once decided, the buttons are replaced by "Approved by NAME", "Denied by NAME" or "Answered by NAME" with the answer. Later progress for that turn appears on the same card.
Choose who may approve
On CatalEx Cloud only the app's owner (the person who sent the code) answers, approves and cancels. catalex channel-settings show ACCOUNT_ID reports this:
Who may act in threads: only the app's owner, whatever the saved setting says (anyone).
You can still save an approver list from the terminal, for example to keep it ready. It takes Google Chat user names (users/ and digits):
catalex channel-settings set ACCOUNT_ID --approval approvers_only --approver users/123
--approval takes anyone, anyone_answers or approvers_only; a mode other than anyone needs at least one approver. An approver that isn't a users/ name exits with code 2. The setting doesn't apply to direct messages.
Find someone's ID
Google Chat doesn't show anyone's users/ ID. In a space with the app, mention the app with /people and each person:
@CatalEx /people @Alex @Sam
Only you see the reply, which lists each person once, such as Alex: users/222. Nothing reaches the agent.
Files and formatting
When an agent replies with a file or a chart, CatalEx uploads it with one person's permission: the person who wrote last, if they allowed uploads, otherwise the person who set the app up. The reply's text comes from the app, then each file arrives after it as a message from that person.
A person allows uploads once from the app's card in Google Chat (Allow file uploads). If nobody can upload a file, the app posts one card saying "NAME wasn't delivered". Charts arrive with every value in the reply, then the chart image. If the image can't be prepared, the reply says "(The chart preview could not be sent.)". Files people attach, of any type, reach the agent with their message.
Agent Markdown is shown formatted: bold, italic, strikethrough, code, links, lists and quotes. Google Chat has no headings or tables, so a heading becomes a bold line and a table becomes a code block of its pipe-separated text. Long replies are split into parts labelled (n/m).
Turn on file uploads for an existing app
An app set up without an OAuth client handles text, cards and approvals, but files from agents aren't delivered. Its row on the Channels tab of the agent's settings says "Files from agents aren't delivered on this app. Choose Turn on file uploads… and add its OAuth client."
- Create the OAuth client as in step 5.
- Open the agent's Settings, choose the Channels tab, then Turn on file uploads… on the Google Chat row.
- Choose Copy redirect URI and add it under Authorized redirect URIs of the OAuth client. Open Google Cloud credentials opens the page.
- For OAuth client, choose the downloaded JSON file, then Save.
Expected: "File uploads are on. Each person allows them once from the app's card in Google Chat." From the terminal:
catalex credentials set ACCOUNT_ID --key-file CLIENT_FILE
Expected: Credential operation OPERATION_ID: committed. catalex accounts health stops reporting that files from agents are not delivered.
Replace the app's key
After rotating the service-account key, or when Google refuses the saved one, create a new JSON key in the Chat app's project (step 2).
In the app:
- Open Settings › Channels and open the Google Chat card.
- On the app's card, choose Replace key… and pick the downloaded file.
Expected: Key replaced. The provider and callback checks passed. If Google refuses the file, the card says so and the saved key stays in use.
From the terminal:
catalex credentials set ACCOUNT_ID --key-file KEY_FILE
Expected: an Operation: line, then Credential operation OPERATION_ID: committed. The app keeps its project, endpoint and chats. If Google refuses the key, the command exits with CREDENTIAL_REJECTED and the saved key stays in use. If TARGET_CHANGED appears, run catalex credentials status ACCOUNT_ID and try again.
When Google refuses the saved key
If the service account was deleted, or its key was removed or rotated, Google refuses the key the app saved. While that lasts:
- A person who messages the app gets "CatalEx can't reply here right now: Google refused this app's saved key. The app's owner can replace the key in CatalEx." Only the person's own message gets this answer; the app can't post anything else without a working key.
catalex accounts listadds "· Needs attention" to the app and prints the fix,catalex statusmarks the destination as needing attention, andcatalex accounts health ACCOUNT_IDnames the finding.- If Google keeps refusing it across three health checks, CatalEx deletes the saved key and disables the account until you save a new one (finding
PROVIDER_CREDENTIAL_RETIRED).
Create a new key and replace it. When you choose Verify during setup and Google refuses the key, the dialog says to check in the Google Cloud console that the key is still active, then verify again.
Move or remove the app
Each Google Chat app reaches one agent at a time. To move it, add it as another agent's channel from Add channel › Google Chat, choosing Move ACCOUNT on the app's card, and confirm, or run:
catalex channels add --agent AGENT_ID --type googlechat --account ACCOUNT_ID --move
A reply in a thread that belonged to the previous agent gets "This app now reaches AGENT, so nothing was sent to an agent. Mention the app in a new message to start a new conversation."
To remove an app no agent uses, run catalex accounts remove ACCOUNT_ID and confirm. The app stops answering and its conversations are kept. CatalEx doesn't delete the Chat app or its key in Google Cloud; delete them there when you no longer need them.
Troubleshooting
| What you see | What to do |
|---|---|
| The Chat app form is read-only | Select your own project, or ask a project Owner for the Editor role. |
| Google refuses the key | Create a new JSON key for a service account in the Chat app's project and enter it again. |
| "This app needs whoever connected it to finish setup before it can answer." | Send your code to the app in a direct message, then choose Verify. |
| "This app was connected by someone else, so only they can use it here." | Only the person who sent the code can use the app. |
| "This app is not connected to an agent yet, so nothing was sent to an agent." | Add the app to an agent with Add channel › Google Chat and the app's card. |
| Mentions get no reply at all | Check that the endpoint URL in the Chat app matches the one setup showed. People who aren't allowed to use the app, or are over a limit, get no reply by design. |
| "Received" stays and no reply follows | The agent's computer isn't connected. Start CatalEx on it. |
| A reply says "NAME wasn't delivered" | Nobody allowed file uploads, or Google refused the permission. Choose Allow file uploads on the card, or turn on file uploads. |
| Google refused the saved key, or the app answers "CatalEx can't reply here right now: Google refused this app's saved key." | Check that the key is still active in Google Cloud. If it was rotated or deleted, replace the key. |
| "Choose the OAuth client file." when you connect | New setups need the OAuth client's JSON file beside the key. Create it as in step 5. |
A message starting with / reaches the agent as text and nothing answers it | The agent's Chat commands switch is off for Google Chat. Turn it on in the agent's Settings › Channels panel. |