Hi everyone,
I’m curious how others here structure Google Chat apps once they grow beyond a fairly simple webhook handler.
I found that once you start adding commands, Cards, Actions, forms, Threads, private flows, and different ways of receiving events, quite a bit of application code starts appearing around the Chat API itself.
In particular, I was looking for a clean way to handle routing, typed events, state, and Cards/Actions without passing raw payload dictionaries through the whole application.
I ended up turning my approach into an open-source Python project called Chattice:
The idea is to keep Google Chat concepts as they are — Spaces, Threads, Messages, Cards, Actions, Dialogs, App Home, Workspace Events — and add some application structure around them: routers, filters, middleware, DI, typed forms/actions, and state management.
A basic handler looks like this:
from chattice import Dispatcher, F, Router
from chattice.events import MessageEvent
router = Router()
@router.message(F.text == "ping")
async def ping(message: MessageEvent) -> str:
return "pong"
dispatcher = Dispatcher()
dispatcher.include_router(router)
One thing I decided not to do was make Pub/Sub look like Telegram-style polling.
With HTTP, Google Chat calls your endpoint and you can return the synchronous interaction response.
With Pub/Sub streaming pull, your app is a persistent subscriber and replies through the Chat API.
They feel like different runtime models to me, so the framework keeps them separate.
Docs and examples are here:
I’d be interested in hearing how people here handle this in their own Chat apps, especially:
- whether you mostly use HTTP, Pub/Sub, or both
- how you model Cards and Actions
- where you keep state for multi-step flows
- what parts of Google Chat development create the most boilerplate for you
If anyone takes a look at Chattice, feedback on places where the abstraction doesn’t match real Google Chat workflows would be especially useful.
It’s MIT licensed and currently in public beta. It’s an independent project and isn’t affiliated with Google.