Lead Engineer
WhatsAppMeta
Twilio SMS Webhook System with Job Queue & Session Management
4
Worker Pool
27
Test Files
5s
Poll Interval
Overview
Built a messaging automation system using Twilio webhooks and Node.js/Express. Routes incoming messages to handlers, manages user sessions across conversations, and processes jobs through a worker pool with real-time status tracking.
The architecture maps directly to WhatsApp Business API integration patterns: same webhook model, session management, and job routing. This makes it ideal for service marketplaces and chatbot systems.
!The Challenge
Needed messaging automation with webhook handling, session management, and job queuing.
✓The Solution
Twilio webhook system with 4-worker job pool, state machines, cross-conversation sessions, and real-time admin dashboard.
Technical Implementation
Webhook Architecture
- Twilio signature validation for security
- Express middleware for request parsing
- Phone number whitelist authentication
- Rate limiting to prevent abuse
Job Queue System
- Worker pool with 4 concurrent workers
- 5-second polling interval
- State machine: pending → running → completed/failed
- Database-backed job persistence
Session Management
- Cross-conversation session tracking
- Pagination for long responses
- Session timeout handling
- Context preservation across messages
Tech Stack
Backend
Node.jsExpress.jsTypeScript
Database
SQLitePostgreSQL
Messaging
Twilio API
Testing
Jest
Logging
Winston
Skills Demonstrated
Node.jsExpress.jsTwilio APIPostgreSQLWebhook ArchitectureJob QueuesState MachinesREST APIAuthentication