Notification System #
Complete guide to configuring email, SMS, Slack, and webhook notifications for server status changes.
Overview #
The notification system sends alerts when servers cross status thresholds:
- Success → Failure: Server goes down
- Failure → Success: Server comes back online
Notifications are smart - they only trigger on meaningful status changes, not every check.
Features #
- Multi-channel: Email, SMS, Slack, and custom webhooks
- Per-user configuration: Each admin can have different preferences
- Plan-based restrictions: SMS/webhooks only available on paid plans
- Cost tracking: All communications logged with costs
- Threshold-based: Only alerts on status changes that matter
- Escalation policies: Auto-escalate unacknowledged incidents
- Scheduling: Business hours, after hours, or always
Configuring Notifications #
1. Access Notification Settings #
Navigate to Settings → Notifications in the backend.
Access Requirements:
- Organization administrator privileges
- Or Albright Labs staff account
2. Add Notification Recipients #
Click Add user notifications to configure alerts for team members:
User Selection #
- Choose from users in your organization
- Users must have valid email addresses
- Phone numbers required for SMS notifications
Email Notifications #
- Available on all plans (Free, Basic, Pro, Enterprise)
- No additional cost
- Rich HTML templates with status badges
SMS Notifications #
- Not available on Free plan
- Available on paid plans (Basic, Pro, Enterprise)
- Costs ~$0.0075 per message (configurable)
- Requires valid phone numbers
3. Notification Settings Per User #
For each user, configure:
👤 John Doe (john@company.com) (555-123-4567)
☑️ Email Notifications
☑️ SMS Notifications [Paid plans only]
Email Configuration #
SMTP Setup #
Configure your email driver in config/mail.php:
'default' => 'smtp',
'mailers' => [
'smtp' => [
'transport' => 'smtp',
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
],
],
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'alerts@yourdomain.com'),
'name' => env('MAIL_FROM_NAME', 'Your Monitoring Service'),
],
Environment Variables #
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAIL_USERNAME=your-mailgun-username
MAIL_PASSWORD=your-mailgun-password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=alerts@yourdomain.com
MAIL_FROM_NAME="Your Monitoring Service"
Email Template #
The system uses a responsive HTML template featuring:
- Status badges with color coding (green/red)
- Server information (name, status, time)
- Branded design using your configured branding
- Mobile-friendly layout
Example email content:
Subject: example.com: status changed to 500!
[❤️ / 💔 Icon based on status]
Albright Heartbeat Alert
example.com: status changed to [500]
[Branded footer with company information]
SMS Configuration #
Twilio Setup #
-
Create Twilio Account
- Visit https://www.twilio.com
- Sign up and verify your account
- Purchase a phone number
-
Get API Credentials
- Account SID: Found in Twilio Console
- Auth Token: Found in Twilio Console
- Phone Number: Your purchased Twilio number
-
Configure Environment
TWILIO_SID=your-account-sid TWILIO_TOKEN=your-auth-token TWILIO_NUMBER=+1234567890 SERVER_MONITOR_SMS_COST=0.0075
SMS Template #
SMS messages are concise and informative:
example.com: Status changed from 200 to 500.
Cost Management #
SMS costs are tracked per message:
- Default cost: $0.0075 per message
- Configurable: Update
SERVER_MONITOR_SMS_COSTin.env - Logged: All SMS costs tracked in communication logs
- Reportable: View costs in organization management
Slack Integration #
For detailed Slack setup, see the Slack Notifications Guide.
Quick Setup #
- Create an Incoming Webhook in your Slack workspace
- Add the webhook URL in organization settings
- Configure notification schedule
Custom Webhooks #
Overview #
Custom webhooks allow you to send alerts to any HTTP endpoint, enabling integration with:
- PagerDuty
- Discord
- Telegram
- Microsoft Teams
- Custom internal systems
Webhook Configuration #
- Navigate to Settings → Notifications → Webhooks
- Add your webhook URL
- Configure the events to trigger
- Save and test
Webhook Payload #
Webhooks receive a JSON payload with rich context:
{
"event": "server.status_changed",
"server": {
"id": 123,
"title": "Production API",
"endpoint": "https://api.example.com",
"status": 500,
"previous_status": 200
},
"organization": {
"id": 1,
"name": "Acme Corp"
},
"timestamp": "2025-01-01T12:00:00Z",
"incident": {
"id": 456,
"state": "pending",
"created_at": "2025-01-01T12:00:00Z"
}
}
HMAC Signature Verification #
For security, webhooks include an HMAC signature in the X-Signature header:
$signature = hash_hmac('sha256', $payload, $webhookSecret);
Verify incoming webhooks:
$providedSignature = $request->header('X-Signature');
$expectedSignature = hash_hmac('sha256', $request->getContent(), $secret);
if (!hash_equals($expectedSignature, $providedSignature)) {
return response('Invalid signature', 401);
}
Escalation Policies #
Overview #
Escalation policies automatically escalate unacknowledged incidents to backup recipients after a configurable delay.
Configuration #
- Navigate to Settings → Notifications → Escalation
- Set escalation delay (e.g., 15 minutes)
- Configure backup recipients
- Save settings
How It Works #
- Incident created → Primary recipients notified
- If not acknowledged within delay → Backup recipients notified
- Continues until acknowledged or resolved
Notification Scheduling #
Schedule Options #
- Always: Notifications sent 24/7
- Business Hours: Only during configured hours
- After Hours: Only outside business hours
- Custom Schedule: Define specific windows
Configuration #
// Example schedule configuration
$settings->schedule = [
'type' => 'business_hours',
'start' => '09:00',
'end' => '17:00',
'timezone' => 'America/New_York',
'days' => ['monday', 'tuesday', 'wednesday', 'thursday', 'friday']
];
How Notifications Work #
Threshold Detection #
The system only sends notifications when status crosses meaningful thresholds:
Triggers Notification:
- 200 → 500 (Success to Failure)
- 404 → 200 (Failure to Success)
- null → 500 (First check fails)
Does NOT Trigger:
- 200 → 201 (Success to Success)
- 500 → 404 (Failure to Failure)
- 200 → 200 (No change)
Success/Failure Codes #
Success Codes: 100, 200, 201, 204, 300, 301, 302, 304 Failure Codes: 400, 401, 403, 404, 500, 502, 503
Processing Flow #
- Server check completes with new status
- Log entry created with status change
- Threshold analysis determines if notification needed
- Recipient lookup finds configured administrators
- Email dispatch to users with email enabled
- SMS dispatch to users with SMS enabled (paid plans only)
- Slack/Webhook dispatch if configured
- Communication logs record all sent messages
Plan Restrictions #
Free Plan Limitations #
- Email notifications included
- SMS notifications not available
- Custom webhooks not available
- 1 notification recipient maximum
- No escalation policies
Paid Plan Benefits #
- Email notifications included
- SMS notifications available
- Custom webhooks available
- Unlimited notification recipients
- Full communication logs and cost tracking
- Escalation policies
Communication Logs #
Viewing Logs #
For Organization Admins:
- Logs visible in individual server details
- Shows last 20 notifications per server
For Albright Labs Staff:
- Complete logs in organization management
- Cost summaries and analytics
- Cross-organization reporting
Log Details #
Each communication log includes:
- Timestamp: When notification was sent
- Type: Email, SMS, Slack, or Webhook
- Recipient: Email address, phone number, or webhook URL
- Content: Message content sent
- Status: Delivery status (sent, delivered, failed)
- Cost: Cost in USD (SMS only)
Troubleshooting #
Email Issues #
Emails not sending:
# Test mail configuration
php artisan tinker
>>> Mail::raw('Test', function($m) { $m->to('test@example.com')->subject('Test'); });
Check logs:
tail -f storage/logs/laravel.log | grep -i mail
Common fixes:
- Verify SMTP credentials
- Check firewall rules (port 587)
- Validate DNS/SPF records
SMS Issues #
SMS not sending:
# Enable debug mode
SERVERMONITOR_NOTIFICATION_DEBUG=true
Check Twilio credentials:
php artisan tinker
>>> $client = new \Twilio\Rest\Client(env('TWILIO_SID'), env('TWILIO_TOKEN'));
>>> $client->messages->create('+1234567890', ['from' => env('TWILIO_NUMBER'), 'body' => 'Test']);
Common fixes:
- Verify Twilio credentials
- Check phone number format (+1XXXXXXXXXX)
- Ensure sufficient Twilio balance
- Validate webhook URLs
Debug Mode #
Enable detailed notification logging:
SERVERMONITOR_NOTIFICATION_DEBUG=true
This logs:
- Threshold crossing analysis
- Recipient selection process
- Email sending attempts
- SMS API responses
- Delivery confirmations
Important: Disable in production to avoid log spam.
Testing Notifications #
Manual Testing #
- Add a test server with a URL that will fail
- Configure notifications for your email/phone
- Wait for status change or manually trigger check
- Verify notifications arrive properly
Console Testing #
# Test notification system
php artisan servermonitor:testalerts
Note: This requires a server with endpoint https://albrightlabs.com for testing.
Best Practices #
Recipient Management #
- Keep current: Remove users who leave the organization
- Test regularly: Verify phone numbers and emails work
- Plan limits: Stay within user limits for your plan
Cost Control #
- Monitor usage: Check communication logs regularly
- Optimize recipients: Don't over-notify
- Plan accordingly: Factor SMS costs into plan selection
Performance #
- Avoid loops: Don't set servers that monitor the monitoring system
- Batch updates: System automatically handles burst notifications
- Queue health: Monitor worker performance to ensure timely delivery
Next Steps #
After configuring notifications:
- Add Your First Server - Start monitoring
- Set Up Slack - Configure Slack integration
- Monitor Performance - Ensure reliable delivery
Previous: API Reference | Next: Server Management