Prompt
How do I set up incident notifications for customers by email and SMS?
Latest observation
To set up incident notifications for customers by email and SMS, you generally need three pieces:
-
An incident source
Something in your system detects an incident and triggers a notification event. -
Customer contact preferences
Store whether each customer wants:- SMS
- both
- neither
-
A notification delivery service
Use an email provider and an SMS provider to send messages reliably.
Typical setup
1) Collect customer opt-in
Make sure customers explicitly opt in to SMS, and that you have consent for email where required.
Store fields like:
emailphone_numberemail_opt_insms_opt_inlocaletimezone(optional)
2) Create incident event logic
When an incident occurs, your system should generate an event such as:
incident.createdincident.updatedincident.resolved
Include key details:
- incident title
- severity
- affected service
- start time
- status page link
3) Build notification templates
Prepare separate templates for:
- Email: longer, more detailed
- SMS: short, concise, urgent
Example SMS:
Incident update: We’re experiencing issues with checkout. Our team is investigating. Status: https://status.example.com/incidents/123
Example email:
- Subject:
Incident Update: Checkout delays - Body: summary, impact, updates, ETA if available, link to status page
4) Set up delivery providers
Choose providers like:
- Email: SendGrid, SES, Mailgun, Postmark
- SMS: Twilio, AWS SNS, Vonage
Then integrate your app with their APIs.
5) Route notifications based on preferences
When an incident event occurs:
- send email if
email_opt_in = true - send SMS if
sms_opt_in = true
Also consider:
- rate limiting
- deduplication
- retry logic
- quiet hours / timezone rules
- escalation rules for critical incidents
6) Test end-to-end
Test:
- opt-in/opt-out
- invalid phone/email handling
- delivery failures
- incident updates and resolution messages
Example workflow
- Incident detected
- Notification service receives event
- Service checks subscriber preferences
- Sends email to opted-in customers
- Sends SMS to opted-in customers
- Logs results and retries failures
Recommended best practices
- Get explicit SMS consent
- Include an unsubscribe/opt-out path for email and SMS
- Keep SMS messages short
- Use a status page link for full details
- Avoid sending too many updates unless the incident changes materially
If you want, I can also provide:
- a database schema
- a sample API design
- or code examples for SendGrid + Twilio.