Prompt
How do I connect event-driven notifications to email, SMS, push, and webhooks in one flow?
Latest observation
To connect event-driven notifications to email, SMS, push, and webhooks in one flow, use a single event pipeline with a notification orchestrator that fans out the event to multiple channels based on rules and user preferences.
Recommended flow
-
Event occurs
- Example:
order.shipped,password.reset_requested,payment.failed
- Example:
-
Publish the event to an event bus / queue
- Kafka, SNS, RabbitMQ, Pub/Sub, SQS, etc.
- This decouples your app from the notification delivery logic.
-
Notification service consumes the event
- A dedicated service receives the event payload.
- It decides:
- who should be notified
- which channels to use
- templates/content for each channel
- retry/fallback behavior
-
Channel-specific adapters send notifications
- Email adapter → SendGrid, SES, Mailgun, etc.
- SMS adapter → Twilio, Vonage, etc.
- Push adapter → FCM, APNs, OneSignal, etc.
- Webhook adapter → POST to subscriber endpoints
-
Track delivery status
- Store success/failure per channel
- Retry transient failures
- Dead-letter queue for permanent failures
- Emit delivery events for observability
Typical architecture
Application
↓
Domain Event / Event Bus
↓
Notification Orchestrator
├── Email Provider
├── SMS Provider
├── Push Provider
└── Webhook Dispatcher
Key design pieces
1) Event schema
Keep events structured and channel-agnostic.
Example:
{
"event_type": "order.shipped",
"event_id": "evt_123",
"occurred_at": "2026-11-10T12:00:00Z",
"tenant_id": "t_456",
"recipient_id": "user_789",
"data": {
"order_id": "ord_001",
"tracking_number": "1Z999..."
}
}
2) Notification policy
Define rules like:
- If critical → send email + push + SMS
- If low priority → send email only
- If user opted out of SMS → skip SMS
- If webhook subscriber exists → send webhook too
3) Template system
Render the same event into different channel formats:
- Email: rich HTML/text
- SMS: short plain text
- Push: concise title/body
- Webhook: JSON payload
4) Reliability
Use:
- idempotency keys to avoid duplicate sends
- retries with exponential backoff
- dead-letter queues
- per-channel timeout handling
- audit logs
Example flow for order.shipped
- App emits
order.shipped - Notification service receives it
- It checks preferences:
- Email: yes
- SMS: yes
- Push: yes
- Webhook: yes for partner integration
- It sends:
- Email: “Your order has shipped”
- SMS: “Your package is on the way…”
- Push: “Order shipped”
- Webhook:
POST /subscriber-webhook
Suggested implementation pattern
Use a strategy pattern or plugin architecture:
NotificationOrchestratorEmailSenderSMSSenderPushSenderWebhookSender
Each sender exposes a common interface like:
send(notification_context) -> delivery_result
This keeps the flow unified while allowing channel-specific logic.
Best practices
- Separate event ingestion from delivery
- Make delivery idempotent
- Respect user preferences and quiet hours
- Validate webhook signatures
- Encrypt sensitive payloads
- Monitor delivery metrics per channel
- Store notification history
If you want the simplest version
Build:
- one event consumer
- one notification rules engine
- four channel adapters
- one delivery log table
That gives you one flow with multi-channel fan-out.
If you want, I can also give you:
- a reference architecture diagram,
- a database schema for notification tracking, or
- a sample implementation in Node.js, Python, or Java.