Notification Providers

Complete guide to configuring and using all 7 built-in notification channels.

šŸ“§

Email (SMTP)

Send formatted emails with HTML templates, attachments, and rich formatting.

Configuration

  • smtp_host - SMTP server (e.g., smtp.gmail.com)
  • smtp_port - Port number (e.g., 587 for TLS, 465 for SSL)
  • from_email - Sender email address
  • username - SMTP username
  • password - SMTP password (encrypted)
  • use_tls - Enable TLS encryption (true/false)

Notification Configuration

{
  "type": "email",
  "recipients": ["user@example.com", "admin@example.com"],
  "cc": ["manager@example.com"],
  "bcc": ["archive@example.com"],
  "subject": "Order Confirmation #{{order_id}}",
  "body_html": """
    

Order Confirmed!

Thank you for your order:

Order ID:{{order_id}}
Total:${{order_total}}
Estimated Delivery:{{delivery_date}}

Track your order: Click here

""", "attachments": [ { "filename": "invoice.pdf", "path": "{{invoice_path}}" } ] }

Example Workflow

Step: Send Welcome Email (Notification)
Type: Email
Recipients: {{user_email}}
Subject: Welcome to {{company_name}}!
Body: 
  Welcome {{user_name}},
  
  Your account has been created.
  
  Login here: {{login_url}}
  
  Best regards,
  {{company_name}} Team
šŸ’¬

Slack

Send rich Slack messages with formatting, mentions, file uploads, and threading.

Setup: Create Incoming Webhook

  1. Go to api.slack.com/apps → Create New App
  2. Enable "Incoming Webhooks"
  3. Click "Add New Webhook to Workspace"
  4. Select channel (e.g., #alerts)
  5. Copy webhook URL: https://hooks.slack.com/services/T00000000/B00000000/XXXX

Notification Configuration

{
  "type": "slack",
  "webhook_url": "{{SLACK_WEBHOOK_URL}}",
  "channel": "#alerts",  # optional
  "username": "PyExecutor Bot",
  "icon_emoji": ":robot_face:",
  "text": "Server Alert",
  "blocks": [
    {
      "type": "header",
      "text": {
        "type": "plain_text",
        "text": "āš ļø High CPU Alert"
      }
    },
    {
      "type": "section",
      "fields": [
        {
          "type": "mrkdwn",
          "text": "*Server:*\n{{server_name}}"
        },
        {
          "type": "mrkdwn",
          "text": "*CPU Usage:*\n{{cpu_percent}}%"
        }
      ]
    },
    {
      "type": "section",
      "text": {
        "type": "mrkdwn",
        "text": " Immediate attention required on {{server_name}}"
      }
    },
    {
      "type": "actions",
      "elements": [
        {
          "type": "button",
          "text": {
            "type": "plain_text",
            "text": "View Dashboard"
          },
          "url": "{{dashboard_url}}"
        }
      ]
    }
  ]
}

Advanced Features

  • āœ“ @mentions: Use <@USER_ID> in text
  • āœ“ Channel @mentions: Use <!channel>, <!here>, <!everyone>
  • āœ“ Markdown: *bold*, _italic_, ~strikethrough~, `code`
  • āœ“ Block Kit: Create rich UI blocks (sections, buttons, images)
  • āœ“ Threading: Reply to specific message with thread_ts
šŸ¤

Microsoft Teams

Send formatted Teams messages with rich cards, @mentions, and actions.

Setup: Create Incoming Webhook

  1. Go to your Teams channel → ⋯ (More options)
  2. Select "Connectors"
  3. Search for "Incoming Webhook" → Configure
  4. Name: "PyExecutor"
  5. Optionally upload image
  6. Copy webhook URL

Notification Configuration

{
  "type": "teams",
  "webhook_url": "{{TEAMS_WEBHOOK_URL}}",
  "title": "Deployment Completed",
  "themeColor": "00FF00",  # Hex color without #
  "sections": [
    {
      "activityTitle": "{{app_name}} v{{version}}",
      "activitySubtitle": "Deployment Summary",
      "facts": [
        {
          "name": "Environment:",
          "value": "Production"
        },
        {
          "name": "Status:",
          "value": "āœ… Success"
        },
        {
          "name": "Duration:",
          "value": "{{deploy_duration}}s"
        },
        {
          "name": "Deployed by:",
          "value": "{{deploy_user}}"
        }
      ]
    },
    {
      "activityTitle": "Changes",
      "text": "• {{change_1}}\n• {{change_2}}\n• {{change_3}}"
    }
  ],
  "potentialAction": [
    {
      "name": "View Logs",
      "targets": [
        {
          "os": "default",
          "uri": "{{logs_url}}"
        }
      ]
    },
    {
      "name": "Rollback",
      "targets": [
        {
          "os": "default",
          "uri": "{{rollback_url}}"
        }
      ]
    }
  ]
}
šŸŽ®

Discord

Send rich Discord embeds with colors, thumbnails, and interactive buttons.

Setup: Create Webhook

  1. Go to Server Settings → Integrations → Webhooks
  2. Click "New Webhook"
  3. Select channel (e.g., #alerts)
  4. Copy webhook URL: https://discordapp.com/api/webhooks/...

Notification Configuration

{
  "type": "discord",
  "webhook_url": "{{DISCORD_WEBHOOK_URL}}",
  "content": "🚨 Production Alert",
  "tts": false,
  "embeds": [
    {
      "title": "Database Backup Failed",
      "description": "Backup for {{database_name}} failed to complete.",
      "url": "{{monitoring_dashboard_url}}",
      "color": 16711680,  # Red (decimal)
      "fields": [
        {
          "name": "Database",
          "value": "{{database_name}}",
          "inline": true
        },
        {
          "name": "Time",
          "value": "{{failure_time}}",
          "inline": true
        },
        {
          "name": "Error",
          "value": "{{error_message}}",
          "inline": false
        }
      ],
      "thumbnail": {
        "url": "https://example.com/alert-icon.png"
      },
      "footer": {
        "text": "PyExecutor Monitoring",
        "icon_url": "https://example.com/logo.png"
      }
    }
  ]
}

Color Reference

  • šŸ”“ Red (Error): 16711680
  • 🟔 Yellow (Warning): 16776960
  • 🟢 Green (Success): 65280
  • šŸ”µ Blue (Info): 255
āœˆļø

Telegram

Send Telegram messages with markdown formatting, buttons, and bot integration.

Setup: Create Bot Token

  1. Open Telegram app
  2. Search for @BotFather
  3. Send /newbot command
  4. Follow prompts to create bot
  5. Copy token: 1234567890:ABCdefGHIjklmnoPQRstuvWXYZabcdefG
  6. Get chat ID by sending message to bot and calling: https://api.telegram.org/botTOKEN/getUpdates

Notification Configuration

{
  "type": "telegram",
  "bot_token": "{{TELEGRAM_BOT_TOKEN}}",
  "chat_id": "{{TELEGRAM_CHAT_ID}}",
  "text": """
*Error Alert* 🚨

*Service:* `{{service_name}}`
*Status:* {{status}}
*Error:* `{{error_code}}`

_{{timestamp}}_

[View Dashboard]({{dashboard_url}})
[Acknowledge]({{ack_url}})
  """,
  "parse_mode": "Markdown",
  "disable_web_page_preview": true,
  "reply_markup": {
    "inline_keyboard": [
      [
        {
          "text": "šŸ“Š Dashboard",
          "url": "{{dashboard_url}}"
        }
      ],
      [
        {
          "text": "āœ… Acknowledge",
          "callback_data": "ak_{{alert_id}}"
        },
        {
          "text": "āŒ Ignore",
          "callback_data": "ig_{{alert_id}}"
        }
      ]
    ]
  }
}

Markdown Formatting

  • *bold* → bold
  • _italic_ → italic
  • `code` → fixed-width code
  • ~~strikethrough~~ → strikethrough
  • [link text](url) → clickable link
šŸ’š

WhatsApp

Send WhatsApp messages using Twilio integration or WhatsApp Business API.

Setup: Twilio WhatsApp Sandbox

  1. Sign up at twilio.com
  2. Get Account SID and Auth Token from dashboard
  3. Go to Console → Messaging → Try it Out → Send a WhatsApp message
  4. Get sandbox number and phone number
  5. Save: account_sid, auth_token, from_number, to_number

Notification Configuration

{
  "type": "whatsapp",
  "account_sid": "{{TWILIO_ACCOUNT_SID}}",
  "auth_token": "{{TWILIO_AUTH_TOKEN}}",
  "from_number": "+1234567890",  # Your Twilio number
  "to_number": "{{user_phone}}",  # Include country code
  "template": "appointment_reminder",  # Pre-approved template
  "template_variables": [
    "{{appointment_date}}",
    "{{appointment_time}}",
    "{{doctor_name}}"
  ],
  "media": {
    "document": "{{invoice_path}}",
    "type": "application/pdf"
  }
}

Template Example

# Pre-approved Template: appointment_reminder
# Variables: {{1}}, {{2}}, {{3}}

"Hello! Your appointment with {{1}} on {{2}} at {{3}} is confirmed. 
Please arrive 10 minutes early. Reply C to confirm or R to reschedule."
🚨

PagerDuty

Create incidents and alerts in PagerDuty with escalation policies and runbooks.

Setup: Create Integration Key

  1. Go to PagerDuty dashboard → Integrations
  2. Create new integration → Select "Events API v2"
  3. Name: "PyExecutor"
  4. Copy Integration Key (routing key)
  5. Store as secret: PAGERDUTY_ROUTING_KEY

Notification Configuration

{
  "type": "pagerduty",
  "routing_key": "{{PAGERDUTY_ROUTING_KEY}}",
  "event_action": "trigger",  # trigger, acknowledge, resolve
  "dedup_key": "database-backup-{{date}}",  # Group related alerts
  "payload": {
    "summary": "Database backup failed",
    "severity": "critical",  # critical, error, warning, info
    "source": "PyExecutor",
    "timestamp": "{{iso_timestamp}}",
    "custom_details": {
      "database": "{{database_name}}",
      "error": "{{error_message}}",
      "affected_records": "{{affected_count}}",
      "dashboard_link": "{{monitoring_url}}"
    }
  },
  "client": "PyExecutor",
  "client_url": "{{dashboard_url}}",
  "links": [
    {
      "href": "{{runbook_url}}",
      "text": "Database Backup Runbook"
    }
  ]
}

Severity Levels

  • critical - Requires immediate action, pages on-call user
  • error - Significant issue requiring attention
  • warning - Potential issue to monitor
  • info - Informational alert, no page

Provider Comparison

Provider Rich Formatting Buttons/Actions Team Integration File Upload
šŸ“§ Email āœ… HTML āœ… Links āœ… Any email āœ… Attachments
šŸ’¬ Slack āœ… Block Kit āœ… Buttons āœ… Channels āœ… Via API
šŸ¤ Teams āœ… Adaptive Cards āœ… Actions āœ… Teams rooms āš ļø Limited
šŸŽ® Discord āœ… Embeds āœ… Buttons āœ… Servers āœ… URLs
āœˆļø Telegram āœ… Markdown āœ… Buttons āœ… Groups āœ… Any file
šŸ’š WhatsApp āœ… Templates āœ… Buttons āœ… Broadcast āœ… Media
🚨 PagerDuty āœ… Structured āœ… Payload āœ… On-call āŒ No