Create a centralized notification system that routes alerts to the right channel based on severity, time of day, and user preferences.
intermediate
Chapter 7: Real-World Automation Projects3. Multi-Channel Notifications
Build a notification hub routing to Slack, email, and SMS.
20m Lesson 3 of 5
Code Examples
Notification Router
javascript
const alert = $input.first().json;
const hour = new Date().getHours();
// Determine channels based on severity
const channels = [];
if (alert.severity === "critical") {
channels.push("slack", "email", "sms");
} else if (alert.severity === "warning") {
channels.push("slack", "email");
} else {
// Info level: Slack only during business hours
if (hour >= 9 && hour <= 17) channels.push("slack");
channels.push("email"); // Always email
}
return [{ json: { ...alert, channels } }];Pro Tips
- 💡Add rate limiting to prevent alert fatigue — no more than 1 SMS per 15 minutes for the same alert type
Comprehension Quiz
Answer 2 of 2 correctly to unlock lesson completion.
1. For a "critical" severity alert, which channels should fire?
2. What prevents alert fatigue?
Pass the quiz above to unlock lesson completion