MAZE Software Development

SYS.04 · AI Agents

WhatsApp CRM Gateway

Self-hosted WhatsApp gateway pushing CRM events and extracting inbound CVs.

Client
Trifid Media
Year
2026
Role
Architect & lead engineer
Category
AI Agents · SYS.04
Private system
2
production sessions
5,000
messages per nightly sweep
5 min
watchdog interval
$0
notification cost

The numbers

2

production sessions

5,000

messages per nightly sweep

5 min

watchdog interval

$0

notification cost

The engineering

  1. The event pipeline starts in the database: row changes call pg_net.http_post into a Supabase edge function, which posts to the gateway REST API and fans out by event type — closed deals to CEO, sales manager and finance; quotations to sales manager and finance; KPI alerts to regional leads.

  2. A production watchdog that solves a failure mode the vendor healthcheck misses entirely: sessions report ready while their Chromium page is hung. The cron probes with a real Puppeteer call on a 45s timeout, then restarts the session and clears Chromium singleton locks.

  3. The nightly CV sweep exploits WhatsApp Web’s lazy history back-sync, holding the watchdog off during the Puppeteer-heavy window and relying on extractor dedup so the model is only billed for genuinely new CVs.

  4. Honest provenance: the custom layer is the CRM integration, four patched engine files and a production ops kit on top of an MIT-licensed upstream gateway.

Stack

  • NestJS 11
  • whatsapp-web.js
  • Supabase Edge Functions
  • PostgreSQL + pg_net
  • BullMQ
  • Docker
  • Hetzner