SMS
TwilioTeams
Microsoft Teams Bot FrameworkSlack
Incoming WebhookIn-App
Stored in PlanetScale, served via APIArchitecture
dispatchNotification() function in packages/notify/src/index.ts fans out to all requested channels in parallel and returns a per-channel result. Results are written to communications_ledger for audit.
Email Provider
Selecting a provider
SetEMAIL_PROVIDER in .dev.vars or wrangler.toml [vars]:
| Value | Provider | Best for |
|---|---|---|
graph | Microsoft Graph sendMail | O365 licensed mailboxes, MGA tenants |
resend | Resend API | Transactional email to external recipients |
smtp | SMTP relay | Self-hosted or custom relay |
EMAIL_PROVIDER=graph in wrangler.toml).
Graph email secrets
Resend email secrets
SMS (Twilio)
SMS is delivered via Twilio Programmable SMS. The client is created only when bothTWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN are present.
Microsoft Teams
Teams messages are dispatched via the Bot Framework. The Notifications Bot app registration is configured inwrangler.toml:
Caution: The current bot hasMail.Sendpermission only.ChatMessage.Sendmust be added and admin-consented before Teams channel messages work. See Fix Teams Messaging.
Slack
Slack notifications use an incoming webhook URL. No OAuth is required.In-App Notifications
In-app notifications are stored in PlanetScale (notifications table) and surfaced via the API. The client polls or subscribes via SSE.
Endpoints:
| Method | Path | Description |
|---|---|---|
GET | /v1/notifications?orgId=&read=false | List notifications |
POST | /v1/notifications/:id/read | Mark single read |
POST | /v1/notifications/read-all | Mark all read |
Dispatch API
Request
Available templates
| Template | Triggered by |
|---|---|
policy_bound | Policy binds |
claim_opened | FNOL submitted |
claim_settled | Claim closed |
quote_available | UW approves quote |
renewal_reminder | 60/30/15 days before expiry |
invoice_generated | Billing cycle runs |
compliance_deadline | Filing due date approaching |
approval_needed | Authority limit exceeded |
bordereaux_submitted | Bordereaux sent to carrier |
noc_delivery | Notice of cancellation issued |
submission_referred | Submission escalated for review |
endorsement_issued | Mid-term endorsement processed |
cancellation_completed | Policy cancelled |
reinstatement_completed | Policy reinstated |
audit_completed | Premium audit finalized |
nonrenewal_notice | Non-renewal notice issued |
subrogation_update | Subrogation status change |
Response
Communications Ledger
Every email and SMS dispatch is written to thecommunications_ledger table for compliance audit:
sent / failed), provider message ID, and trace ID.
Adding a New Template
- Add the template key to the
templateenum inapps/api/src/routes/notifications.ts2. Add the template rendering logic inpackages/notify/src/templates/3. Document the trigger condition in the table above 4. Add tests inpackages/notify/src/__tests__/