AI Instagram DM Assistant for Multi-Location Parks
Production FastAPI webhook service that answers customer Instagram DMs across three park locations, migrated from a standalone LLM bot into a fault-tolerant relay integrated with a central conversational AI platform.
Overview
A production service that answers customer Instagram DMs for three park locations (Scarborough, Oakville, London) around the clock. It started as a standalone LLM-powered bot and was later migrated into a fault-tolerant relay integrated with the company's central conversational AI platform, with zero customer-facing errors across the cut-over.
What it does
- Verifies and acknowledges Meta Instagram webhooks (HMAC-SHA256) immediately, then processes each event in the background so retries never cause duplicate replies
- Persists every event to a durable SQLite (WAL) queue before processing, so a crash or restart never loses or double-sends a message
- Routes each park's DMs to the right backend, forwards text, story replies, media, stickers, shares, reactions, and echoes, and detects when a staff member takes over a conversation
- Hashes long Instagram message IDs to fit a strict API contract, and applies status-aware retry/backoff (429/503 with exponential backoff, 4xx treated as terminal)
- Gives the marketing team an Instagram-native admin console
(
/collab,/requests,/takeover,/release,/stats,/bot) with collaboration-request alerts that respect Meta's 24-hour messaging window
Stack
- API & async I/O — Python, FastAPI, uvicorn, httpx
- State & queueing — SQLite (WAL mode), durable event queue, idempotent message IDs
- Integrations — Meta Instagram Graph API, webhooks, OAuth token refresh
- Testing — pytest / pytest-asyncio (199 tests covering the relay, API client, admin commands, and webhook handling)
- Ops — pm2, Cloudflare Tunnel, phased shadow-mode rollout with per-park feature flags
Why it mattered
Staff were answering Instagram DMs by hand across three locations with no central visibility. Replacing that with an always-on assistant — rolled out gradually in shadow mode before a zero-error, same-day cut-over — removed the manual bottleneck while giving marketing real-time insight into collaboration requests and customer escalations.