Installation
Environment Variables
Create a Google Chat app in the Google Cloud Console.
Configuration Options
Setup
- Service Account
- Application Default Credentials
- Workload Identity Federation
Use a JSON service account key:
Webhook Handler
Workspace Events (Recommended)
Why Workspace Events? Direct webhooks only fire for @mentions. Workspace Events delivers ALL messages via Pub/Sub, enabling background processing and better UX.
1
Create Pub/Sub topic
2
Configure adapter
Set
pubsubTopic in your adapter config:3
Enable domain-wide delegation
Required for creating subscriptions:
- Go to Google Workspace Admin Console
- Security → API Controls → Domain-wide Delegation
- Add your service account client ID
- Authorize scopes:
https://www.googleapis.com/auth/chat.bothttps://www.googleapis.com/auth/chat.messages.readonly
impersonateUser to a user email in your workspace:4
Create Pub/Sub push subscription
Point subscription to your webhook endpoint:
5
Subscribe to threads
When bot joins a space or a thread is subscribed, the adapter auto-creates a Workspace Events subscription:
Features
Supported Events
MESSAGE- Messages in spaces (via direct webhook or Pub/Sub)ADDED_TO_SPACE- Bot added to a spaceREMOVED_FROM_SPACE- Bot removed from a spaceCARD_CLICKED- Button clicks in cardsmessage.v1.created(Pub/Sub) - All messages via Workspace Eventsreaction.v1.created/reaction.v1.deleted(Pub/Sub) - Reactions
Cards v2
Google Chat uses Cards v2 format:Reactions
Add/remove emoji reactions:Ephemeral Messages
Send private messages visible only to one user:File Attachments
Thread IDs
Google Chat thread IDs encode space and thread names:- DM (no thread):
gchat:spaces/AAAAxxxx: - Space thread:
gchat:spaces/AAAAxxxx:dGhyZWFkcy95eXl5
Opening DMs
Create a 1:1 conversation with a user:Requires domain-wide delegation with
impersonateUser configured.Message History
Fetch message history (requires domain-wide delegation):Platform Limits
- Message length: 4,096 characters
- Cards per message: 100 cards
- Widgets per card: 100 widgets
- Rate limits: Google Chat quotas
Code Examples
Troubleshooting
Bot only receives @mentions
Bot only receives @mentions
- Enable Workspace Events (Pub/Sub) to receive all messages
- Without Pub/Sub, Google Chat only sends @mention events
Workspace Events subscription fails
Workspace Events subscription fails
- Enable domain-wide delegation in Workspace Admin Console
- Set
impersonateUserto a user in your workspace - Grant service account
https://www.googleapis.com/auth/chat.botscope - Ensure Pub/Sub topic exists and is accessible
openDM() fails
openDM() fails
- Requires domain-wide delegation with
impersonateUser - Service account needs
chat.spaces.createscope - User must be in same Workspace
Required Scopes
Add these OAuth scopes to your service account: Bot Scopes:https://www.googleapis.com/auth/chat.bot- Core bot functionalityhttps://www.googleapis.com/auth/chat.messages.readonly- Read messageshttps://www.googleapis.com/auth/chat.messages.reactions.create- Add reactionshttps://www.googleapis.com/auth/chat.messages.reactions- Read/remove reactionshttps://www.googleapis.com/auth/chat.spaces.create- Create DMs (with domain-wide delegation)
Next Steps
Message Handling
Process messages and build conversation flows
Cards v2
Create interactive UIs with Google Chat cards
Workspace Events
Learn about Workspace Events API
State Management
Persist subscriptions and data