Skip to main content

Notifications (@loyaltyos/notifications)

Multi-channel notification delivery engine.

Channels​

ChannelProvider(s)
EMAILResend (production), SMTP (dev)
SMSTwilio REST API
PUSHOneSignal REST API
WEBHOOKHTTP POST with HMAC-SHA256
IN_APPStored-only (noop)

Architecture​

Event → sendTrigger() → Template Matching → Handlebars Render → Create Notification
↓
BullMQ Enqueue
↓
Worker: deliver()
↓
Provider (SMTP / Twilio / OneSignal / Webhook)
↓
Status: SENT or FAILED

Templates​

Handlebars syntax with sandboxed variable access:

<h1>Congratulations {{member.firstName}}!</h1>
<p>You earned <strong>{{points}}</strong> points. Your balance is now {{balance}}.</p>

Features:

  • Create, update, preview, and test-send templates
  • Template variables from event payload + member context
  • Opt-out management per channel per member
  • Transactional vs marketing classification

Webhooks​

Outgoing webhooks signed with HMAC-SHA256:

curl -X POST http://localhost:3002/api/v1/admin/webhooks \
-H "X-API-Key: dev-key" -H "X-Program-Id: prog_dev" \
-H "Content-Type: application/json" \
-d '{"url": "https://partner.example.com/webhooks", "events": ["points.earned"], "secret": "whsec_..."}'

See the full README on GitHub for details.