DaaS / Products / Closed-Loop Multi-Channel Notification Pipeline

Closed-Loop Multi-Channel Notification Pipeline

Orchestrate EventBridge rules to fan out business events (order placed, payment completed) to Twilio for SMS/WhatsApp and Resend for branded email delivery, then close the loop by ingesting returning delivery receipts, bounce notifications, and open tracking webhooks back through EventBridge for end-to-end notification status visibility.

Products involved

Scenario

Use this pipeline when your application requires reliable, multi-channel notifications triggered by domain events like OrderPlaced or PaymentCompleted, and you need end-to-end visibility by tracking delivery receipts, bounces, and opens back into your event bus for automated retries and analytics.

Integration steps

  1. Create EventBridge Connections & API Destinations:
  2. ``bash aws events create-connection --name twilio-conn --authorization-type API_KEY --auth-parameters '{"ApiKeyAuthParameters":{"ApiKey":"TWILIO_SID","ApiSecretParameter":"TWILIO_TOKEN"}}' aws events create-api-destination --name twilio-sms --connection-arn <arn> --http-method POST --invocation-endpoint "https://api.twilio.com/2010-04-01/Accounts/{SID}/Messages.json" ``

  3. Configure Resend Destination:
  4. ``bash aws events create-connection --name resend-conn --authorization-type API_KEY --auth-parameters '{"ApiKeyAuthParameters":{"ApiKey":"RESEND_KEY"}}' aws events create-api-destination --name resend-email --connection-arn <arn> --http-method POST --invocation-endpoint "https://api.resend.com/emails" ``

  5. Define Fan-Out Rule:
  6. ``bash aws events put-rule --name "order-fanout" --event-pattern '{"source":["com.app"],"detail-type":["OrderPlaced"]}' aws events put-targets --rule "order-fanout" --targets '[{"Id":"sms","Arn":"<twilio-arn>","InputTransformer":{"InputPathsMap":{"p":"$.detail.phone","m":"$.detail.msg"},"InputTemplate":"{\"To\":\"<p>\",\"Body\":\"<m>\"}"}},{"Id":"email","Arn":"<resend-arn>","InputTransformer":{"InputPathsMap":{"e":"$.detail.email"},"InputTemplate":"{\"to\":\"<e>\",\"from\":\"[email protected]\",\"subject\":\"Order\",\"html\":\"<h1>Confirmed</h1>\"}"}}]' ``

  7. Expose Webhook Endpoints: Deploy API Gateway routes (/webhooks/twilio, /webhooks/resend) to receive async delivery callbacks.
  8. Re-ingest Tracking Events: Transform incoming payloads into EventBridge format via Lambda/API Gateway integration:
  9. aws events put-events --entries '[{"Source":"com.notifications","DetailType":"DeliveryStatus","Detail":"{\"channel\":\"sms\",\"status\":\"delivered\",\"id\":\"SM123\"}"}]'

  10. Route to Analytics: Create a tracking rule matching {"source":["com.notifications"],"detail-type":["DeliveryStatus","Bounce","Open"]} targeting RDS/OpenSearch.

Architecture

Domain events hit the EventBridge bus, where a fan-out rule routes payloads to Twilio and Resend via authenticated API Destinations. Providers process messages and POST delivery receipts to your webhook endpoints. These payloads are normalized and re-ingested into EventBridge via PutEvents, closing the loop. Downstream consumers (RDS, OpenSearch, Supabase) subscribe to tracking events for real-time visibility without polling.

Prerequisites

Common pitfalls

Typical questions

FAQ

Q: How does the closed-loop multi-channel notification pipeline handle message delivery and status tracking? A: The pipeline orchestrates EventBridge rules to fan out business events to Twilio for SMS or WhatsApp and Resend for branded email, then closes the loop by ingesting delivery receipts, bounce notifications, and open tracking webhooks back through EventBridge. This event-driven flow provides complete end-to-end visibility into notification status across all channels.