# Google Chat guide

## Register your Chat app

Enable the Google Chat API and configure the Chat app in your Google Cloud project. Create a service-account JSON key in the same project and copy the numeric project number. Enable direct messages and add your test users to the app's visibility settings.

In [Developer apps](https://platform.agentsky.dev/developer/apps/new?platform=gchat), choose Google Chat and enter the JSON key and project number. API callers use platform gchat with credentials service_account_json (the JSON document as a string) and project_number. Registration obtains an app token from Google and makes a read-only Chat API call. It does not configure or publish your app in Google Workspace.

## Configure the callback

Set the Chat app's HTTP endpoint and authentication audience to the returned setup.webhook_url. Project-number audiences are also accepted for classic Chat apps. Workspace Add-on requests must have the exact service account identity associated with the configured project. Both classic MESSAGE events and Workspace Add-on message payloads are supported. Pub/Sub subscriptions are not enabled by this integration.

## Connect and reply

Create a connection with platform gchat, your registered app ID and a destination containing either a session ID or a webhook endpoint ID. Open the connect URL, copy its LINK code and send it to your app in Google Chat. The page opens Google Chat; locate the app by the display name you configured in Google Cloud. The connection remains PENDING until a verified message claims it.

Use the thread_id from the signed message.received event unchanged when replying through the threads API. Direct messages stay in their space; replies in a space stay in the originating thread. Connecting a space connects that shared conversation, so a webhook consumer must apply its own member authorization.

## Failure and recovery

Inbound native attachment bytes can be downloaded under the current registered credentials. Outbound file uploads are unavailable with the current Google Chat adapter; the API returns files_not_supported rather than silently dropping them.

A rejected key or disabled Chat API returns invalid_credentials. A failed Google service returns platform_unavailable. A callback with a missing token, wrong audience or unexpected service account returns 401 and cannot claim a connection. Fix the configured audience before retrying. Expired LINK codes require a new connection.
