Project Excite — AI-to-Human Live Chat Relay
Project Overview
Volunteer engineering for a nonprofit AI apologetics chat platform: a Next.js seeker-facing app plus a Laravel/Filament backend hub. Project Excite is the piece that hands a conversation from the AI to a live volunteer — on Chatwoot or EchoGlobal — without losing the thread. Unpaid, concurrent with full-time work; roughly 68 commits since April 2026.
The Challenge
- Two volunteer platforms with fundamentally different integration models: one rich (API, webhooks, bot framework, conversation control), one narrow (read-only GraphQL, write-only contacts endpoint, Zapier events)
- The seeker's thread has to survive the handoff, and a session must never be stranded
- The AI should stay available to the volunteer mid-conversation
Technical Solution
Adapter-based relay
An abstract adapter interface with a concrete adapter per platform. The relay core — gateway, session manager, state machine — never knows which platform it is talking to. A mock adapter made the core testable before either real integration existed.
Explicit session state machine
Every conversation is a named-state machine rather than a pile of boolean flags. That choice rules out an entire class of bugs — messages arriving after teardown has begun, @agent commands during handoff — as impossible transitions instead of edge cases to remember.
Idempotent, multi-trigger teardown
Sessions end from any of four triggers (inactivity, volunteer close, seeker close, admin force). The teardown sequence is identical and idempotent, so two triggers firing at once is safe.
The rest of the plumbing
- Redis-backed session manager tracking seeker, adapter, state, and platform conversation ID
- HMAC-verified inbound webhooks at the edge
- QStash-queued delivery and Vercel Cron for background jobs; Pusher for real-time events
- Shared in-session
@agentso the volunteer can pull the AI back in - Sanctum-token relay sessions, Drizzle migrations, encrypted credential casts, and a Filament admin monitoring surface
Design Before Code
Three technical executive summaries in April 2026 — the relay architecture, and one per volunteer platform — reviewed by the founder before implementation, plus a unified relay schema reference in June. Those reviews surfaced the open questions (latency tolerance, who may invoke @agent, whether the Zapier bridge is fit for purpose) before they could become production incidents. A later migration plan moved the implementation from the backend hub into the seeker app behind a RELAY_BACKEND flag, so cutover is a configuration change.
Security Hardening Along the Way
XSS via a DOMPurify SafeHtml wrapper, a CORS allowlist replacing a wildcard, Sentry default PII disabled and a hard-coded client DSN removed, and rate limiting on the chat-completions endpoint — plus repairing the backend's CI/PHPUnit suite so the relay work could land on green.
Key Learnings
The relay is small; the design work around it is what made it shippable. And volunteering on someone else's codebase is a good test of whether your habits travel — split PR stacks, tests first, no secrets in code — when nobody is paying you to keep them.