Disclaimer: I created this piece of content for the purpose of participating in the Google All Things Agentic Hackathon 2026 under the Taskmaster track.
💡 The Inspiration: Why Chatbots Fail at Real Bureaucracy
Have you ever received an unexpected $4,000 medical bill in the mail? Or had an insurance company arbitrarily deny coverage for a critical procedure with a generic one-line explanation like “Documentation does not establish conservative therapy criteria”?
Disputing denied insurance claims is an exhausting, months-long administrative nightmare. You have to decipher clinical codes, research federal mandates like the No Surprises Act or ERISA Section 503, draft formal appeal packages, mail them, and wait weeks for a response.
Most AI applications today are synchronous chatbots. They sit passively inside a browser tab waiting for prompts. But bureaucracy isn’t a conversation—it’s an asynchronous, event-driven marathon.
To tackle this, I built The Asynchronous Bureaucracy Buster—an autonomous AI agent that takes messy denial notices, identifies statutory legal violations, constructs comprehensive appeal letters, and manages the claim lifecycle asynchronously in the background over days and weeks.
🏗️ System Architecture
To support long-running, multi-step asynchronous workflows without losing state across container restarts, I decoupled the architecture into three core layers:
mermaidflowchart TD User([User / Patient]) -->|Upload PDF / Denial Notice| UI["Vite + React Glassmorphic Dashboard"] UI -->|REST API| CloudRun["Google Cloud Run (Express API Gateway)"] subgraph Agent Core Execution CloudRun -->|Multimodal Ingestion & JSON Parsing| Gemini["Gemini 3.5 Flash (@google/genai)"] CloudRun -->|Legal Policy Grounding & Appeal Synthesis| Gemini CloudRun <-->|Statutory Knowledge Base| PolicyKB["Policy KB (No Surprises Act, ERISA § 503, Step Therapy)"] end subgraph Memory & Long-Running Persistence CloudRun <-->|Read / Write State & Reason Chains| MemoryBank[("Persistent Memory Bank (Firestore / State Store)")] end subgraph Asynchronous Event Loop CloudScheduler["Google Cloud Scheduler"] -->|Daily Check Trigger| PubSub["Cloud Pub/Sub Event Queue"] PubSub -->|Process Async Carrier Replies| CloudRun CloudRun -->|Transmit Appeal Package| Carrier[("Insurance Carrier Grievance Dept")] end classDef gcp fill:#4285F4,stroke:#333,stroke-width:2px,color:#fff; classDef ai fill:#34A853,stroke:#333,stroke-width:2px,color:#fff; classDef state fill:#FBBC05,stroke:#333,stroke-width:2px,color:#000; class CloudRun,CloudScheduler,PubSub gcp; class Gemini ai; class MemoryBank state;
🛠️ Step-by-Step Technical Implementation
1. Multimodal Document Intake with Structured JSON Output
The agent ingests raw scanned PDFs or text notices and extracts structured billing parameters using Gemini 3.5 Flash with responseMimeType: "application/json":
javascriptimport { GoogleGenerativeAI } from '@google/generative-ai';const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY);const model = genAI.getGenerativeModel({ model: 'gemini-3.5-flash', generationConfig: { responseMimeType: 'application/json' }});const prompt = `Analyze this medical denial document and extract structured JSON parameters:{ "patientName": "Full Name", "memberId": "Member ID", "claimRef": "Claim Reference Number", "provider": "Healthcare Provider", "carrier": "Insurance Carrier", "deniedAmount": "$0.00", "denialReasonCode": "Code", "denialDescription": "Full denial rationale"}Document Text: ${docText}`;const response = await model.generateContent(prompt);const claimData = JSON.parse(response.response.text());
2. Autonomous Statutory Policy Grounding
Rather than hallucinating generic excuses, the agent cross-references the extracted denial reasons against a specialized knowledge base of federal and state healthcare regulations:
- No Surprises Act (45 CFR § 149.110): Prohibits balance billing for out-of-network emergency room services.
- ERISA Claim Regulations (29 CFR § 2560.503-1): Mandates specific clinical rationale and full disclosure of internal criteria.
- State Step-Therapy Exception Mandates: Enforces rapid 72-hour exception timelines for biologic prescriptions.
3. Legal Appeal Synthesis (6,000+ Character Level 1 Appeals)
Using Gemini 3.5 Flash, the agent synthesizes the claim parameters and policy grounding into a formal Level 1 Appeal demand letter, complete with statutory citations, timelines, and notice of escalation to the State Department of Insurance.
4. Asynchronous State Management via Persistent “Memory Bank”
Because real health plan appeals take between 14 to 45 business days, the agent cannot maintain a live browser session.
We implemented a persistent Memory Bank that tracks:
- Immutable OpenTelemetry-compliant audit logs
- Every decision point and reasoning step taken by the agent
- Full outbound and inbound communication histories
- State transitions (
ANALYZED➔APPEAL_DRAFTED➔APPEAL_SENT➔WON_RESOLVED)
⚡ Simulating Asynchronous Carrier Webhooks
In our dashboard, we built an Asynchronous Carrier Response Simulator. When an insurance carrier replies weeks later:
- The carrier message is received by the webhook listener.
- Gemini 3.5 Flash autonomously interprets the reply.
- If the carrier overturns the denial, the claim state machine updates to
WON_RESOLVED. - If the carrier requests physician chart notes, the agent transitions to
MORE_INFO_NEEDEDand alerts the patient with exact missing items.
🚢 Deploying to Google Cloud Run
To make the system scalable and production-minded, we packaged the entire stack into a lightweight multi-stage Docker container deployed to Google Cloud Run:
dockerfileFROM node:20-alpine AS buildWORKDIR /appCOPY package*.json ./RUN npm installCOPY . .RUN npm run buildFROM node:20-alpine AS runtimeWORKDIR /appCOPY --from=build /app/dist ./distCOPY --from=build /app/server ./serverCOPY --from=build /app/package*.json ./RUN npm install --omit=devENV PORT=8080EXPOSE 8080CMD ["node", "server/index.js"]
Deployment was executed via the Google Cloud CLI:
bashgcloud run deploy bureaucracy-buster \ --source . \ --platform managed \ --region us-central1 \ --allow-unauthenticated \ --set-env-vars GEMINI_API_KEY="AIzaSy..."
🧠 Key Learnings & What’s Next
- Shift to Event-Driven Agents: Next-generation AI is not about bigger prompt boxes; it’s about agents with persistent memory that wake up, execute tasks, and sleep until an external event occurs.
- Gemini 3.5 Flash Speed & Precision: Gemini 3.5 Flash provided near-instant structured JSON responses and drafted legally rigorous 8,000-character letters in seconds.
- Future Roadmap: Direct Gmail/Outlook webhook listeners for automatic inbox monitoring, plus expanding from medical claims to property damage and credit dispute appeals.
🔗 Project Links
- GitHub Repository: https://github.com/iamaanahmad/tabb.git
- Built for: Google All Things Agentic Hackathon 2026
- Track: The Taskmaster
#AllThingsAgenticHackathon #Gemini #GoogleCloud #AIAgents #GoogleAI #OpenSource