Google Apps Script is an incredible rapid prototyping environment, but every enterprise engineering team eventually hits its hard wall: the 30-second synchronous HTTP execution limit.
When building deep ChatOps command centers—such as multi-tier vendor invoice approvals, ERP ledger reconciliations, or candidate offer approvals—waiting for third-party systems like Tally, NetSuite, or SAP frequently exceeds this window, crashing the card UI with an opaque Service Invocation Failure. Furthermore, if an approval requires waiting hours or days for an executive sign-off, Apps Script cannot maintain execution state.
Here is the architectural pattern Ekarna Interactive uses to make Google Chat applications completely timeout-proof while running stateful, multi-day approval gates at near-zero idle compute cost.
1. The Core Bottleneck: Synchronous Webhook Traps
When a user clicks [Approve Invoice] in Google Chat, Google’s CardService sends an HTTP POST event to your webhook backend. If your backend attempts to:
- Reconcile GSTIN tax tables via regional ERP APIs,
- Generate an encrypted PDF signed via Google Drive APIs, and
- Notify the
#finance-auditspace in Google Chat,
The combined round-trip latency often spikes to 35–45 seconds. Because Google Chat expects a 200 OK containing the next card render within 30 seconds, the user sees a broken error state even though the background write succeeded.
2. The Solution: Decoupled Asynchronous Workflows & Stateful Pauses
Instead of executing long-running business logic synchronously within Apps Script, we decouple the front-end user experience from background execution using a 202 Accepted + Asynchronous Callback Topology:
Key Architectural Advantages:
- Zero UI Freezes: The Google Chat UI acknowledges button clicks in under 180ms with an optimistic card state, preventing multi-click races and timeout crashes.
- $0 Idle Compute for Multi-Day Approvals: Google Cloud Workflows can pause execution on an HTTP Callback for up to 1 year while waiting for manager action in Chat—incurring zero compute charges while paused.
- Enterprise Identity: All worker communication between Cloud Run, Cloud Workflows, and internal databases is secured by Google Cloud IAM and Service Accounts, eliminating public internet exposure.
3. Implementation Blueprint
For engineering teams looking to implement this pattern:
- Use Google Cloud Eventarc or Pub/Sub to decouple incoming Card action payloads from execution.
- Store ephemeral card tokens in Cloud MemoryStore (Redis) or Supabase with Row Level Security.
- Use the Google Chat REST API v1 (
spaces.messages.patch) with the card’s originalmessageIdto replace the interactive button grid with an immutable confirmation receipt once downstream workers complete.
Move from Manual Drag to AI-Native Velocity.
We design, build, and deploy working AI systems—instant ChatOps, self-driving workflows, and private Gemini enterprise coworkers—directly inside your private Google Cloud within a fixed 7–14 day sprint.