← Back to all products
$19
Notification Dispatcher
Multi-channel notification system for email, Slack webhooks, generic webhooks, and desktop notifications.
JSONMarkdownPython
📄 Product Preview
Try the interactive reader and demo tools below, or get the full product with all content unlocked.
📖 Interactive Reader (Free Preview) ⚙ Try Demo Tools 📦 Download Free Sample📁 File Structure 9 files
notification-dispatcher/
├── LICENSE
├── README.md
├── examples/
│ └── notifications_config.json
├── free-sample.zip
├── guide/
│ ├── 01_features.md
│ ├── 02_quick-start.md
│ └── 03_faq.md
├── index.html
└── src/
└── notification_dispatcher.py
📖 Documentation Preview README excerpt
Notification Dispatcher
A multi-channel notification system built on Python stdlib. Send alerts via email (SMTP), Slack-compatible webhooks, generic HTTP webhooks, and SMS gateways. Supports template rendering, priority levels, retry logic, and delivery logging to SQLite.
Features
- Multi-channel dispatch — Email (SMTP), Slack webhooks, HTTP webhooks, SMS gateways, console
- Template rendering — Python
string.Templateplaceholders in messages - Priority levels —
low,normal,high,criticalwith per-channel routing - Retry with backoff — Exponential backoff on delivery failures (3 retries default)
- Delivery logging — Track every send attempt in SQLite
- Batch dispatch — Send multiple notifications from a single config file
- Config-driven — Define channels, templates, and recipients in JSON
Requirements
- Python 3.10+
- No external dependencies (stdlib only)
- SMTP server access for email delivery
- Webhook URLs for Slack/webhook channels
Quick Start
# Send a quick email
python src/notification_dispatcher.py --channel email \
--to user@example.com --subject "Alert" --message "Server CPU at 95%"
# Send a Slack notification
python src/notification_dispatcher.py --channel slack \
--to "#ops-alerts" --message "Deploy complete" \
--webhook-url https://hooks.example.com/services/T00/B00/xxx
# Send a webhook notification
python src/notification_dispatcher.py --channel webhook \
--to https://api.example.com/v1/alerts --message '{"event": "deploy"}'
# Batch dispatch from config
python src/notification_dispatcher.py --config examples/notifications_config.json
Configuration Reference
{
"channels": {
"email": {
"smtp_host": "smtp.example.com",
"smtp_port": 587,
"smtp_user": "alerts@example.com",
"smtp_pass": "YOUR_SMTP_PASSWORD_HERE",
"from_address": "alerts@example.com"
},
"slack": {
"webhook_url": "https://hooks.example.com/services/T00/B00/YOUR_TOKEN"
},
"webhook": {
"default_url": "https://api.example.com/v1/notifications"
}
},
*... continues with setup instructions, usage examples, and more.*
📄 Code Sample .py preview
src/notification_dispatcher.py
#!/usr/bin/env python3
"""
Notification Dispatcher — Automation Hub (DataNest)
A multi-channel notification system built on Python stdlib. Supports email
(SMTP), webhook (HTTP POST), Slack-compatible webhooks, and SMS gateway
dispatch. Features template rendering, scheduling, retry logic, and
delivery logging.
Usage:
python notification_dispatcher.py --channel email --to user@example.com --message "Hello!"
python notification_dispatcher.py --config notifications_config.json
python notification_dispatcher.py --channel slack --message "Deploy complete" --webhook-url https://hooks.example.com/services/T00/B00/xxx
Dependencies: Python 3.10+ stdlib only (no pip packages)
License: MIT
"""
from __future__ import annotations
import argparse
import email.mime.multipart
import email.mime.text
import json
import logging
import re
import smtplib
import sqlite3
import string
import threading
import time
import urllib.error
import urllib.request
from dataclasses import dataclass, field
from datetime import datetime, timezone
from enum import Enum
from pathlib import Path
from typing import Any
# ---------------------------------------------------------------------------
# Constants
# ---------------------------------------------------------------------------
LOG_FORMAT = "%(asctime)s [%(levelname)s] %(name)s: %(message)s"
MAX_RETRIES = 3
RETRY_DELAY_S = 2.0
BACKOFF_MULTIPLIER = 2.0
logger = logging.getLogger("notification_dispatcher")
# ... 695 more lines ...