Skip to main content

chat-adapter-gchat

Google Chat adapter for chat-py. Python port of upstream packages/adapter-gchat.

Supports both HTTP-endpoint Chat apps (Workspace Add-ons event envelopes) and Pub/Sub-delivered Workspace Events subscriptions.

Install

uv add chat-py chat-py-adapter-gchat chat-py-adapter-state-pg

Auth / config

GoogleChatAdapterConfig — four auth modes mirror upstream:

Mode Config fields
Service account JSON credentials (a ServiceAccountCredentials dict)
Application Default Credentials useApplicationDefaultCredentials=True
Custom auth auth (callable returning a bearer token)
Auto from env none — relies on GOOGLE_APPLICATION_CREDENTIALS etc.

Additional config: googleChatProjectNumber, impersonateUser, pubsubAudience, pubsubTopic, endpointUrl.

Minimal example

from chat import Chat
from chat_adapter_gchat import create_google_chat_adapter
from chat_adapter_state_pg import create_postgres_state

bot = Chat(
    user_name="mybot",
    adapters={"gchat": create_google_chat_adapter(
        credentials=...,  # service account JSON dict
    )},
    state=create_postgres_state(url="postgres://localhost/chat"),
)


@bot.on_new_mention
async def greet(thread, message):
    await thread.post("Hi!")

Mount bot.handle_webhook("gchat", body, headers) under /api/webhooks/gchat. The adapter verifies incoming requests via bearer tokens (HTTP-endpoint apps) or Pub/Sub-signed JWTs (Workspace Events subscriptions — see decode_pubsub_message).

Thread ID

Google Chat thread IDs: gchat:spaces/{spaceId}:{base64(threadName)}.

Features

  • HTTP-endpoint and Pub/Sub Workspace Events dispatch paths
  • Space-subscription management (create_space_subscription, list_space_subscriptions, delete_space_subscription) with TTL-based refresh
  • UserInfoCache for bot-to-user display-name lookups
  • Card v2 translation (card_to_google_card) — sections, headers, buttons, images, grids
  • Markdown ↔ mdast via GoogleChatFormatConverter

Parity notes

  • Matches upstream's cache TTLs (SUBSCRIPTION_CACHE_TTL_MS, SUBSCRIPTION_REFRESH_BUFFER_MS).
  • Bearer-token verification (verify_bearer_token) uses the same issuer allowlist as upstream.
  • Supplying both credentials and useApplicationDefaultCredentials raises ValidationError.

Test

uv run pytest packages/chat-adapter-gchat

# Live — requires a configured project and credentials
GCHAT_PROJECT=... uv run pytest packages/chat-integration-tests -k gchat

Upstream

https://github.com/vercel/chat/tree/main/packages/adapter-gchat

Metadata

Release files for chat-py-adapter-gchat 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for chat-py-adapter-gchat 0.1.0
File Size Uploaded Provenance Actions
chat_py_adapter_gchat-0.1.0.tar.gz 40.1 kB Without provenance Details for chat_py_adapter_gchat-0.1.0.tar.gz

Release files / chat_py_adapter_gchat-0.1.0.tar.gz

Download URL chat_py_adapter_gchat-0.1.0.tar.gz
Size 40.1 kB
Tags Source
SHA-256 checksum
How to use checksums
0517db4aae678c26011e7c06fbb1bd0e80552c1473d12f7e1387383fbb0cd002
BLAKE2b-256 checksum
How to use checksums
d30da54bb2470dc271846284c994b5801730e7146cc43c72b7584d71213bfed8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.20 {"installer":{"name":"uv","version":"0.9.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for chat-py-adapter-gchat 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page