Chuyển tới nội dung chính

Email Notification Handler Agent

The Email Notification Handler Agent sends email notifications for alerts and reports.

📋 Overview

PropertyValue
Modulesrc.agents.notification.email_notification_handler_agent
ClassEmailNotificationHandlerAgent
AuthorUIP Team
Version1.0.0

🎯 Purpose

  • Send email alerts for traffic incidents
  • Deliver scheduled reports to subscribers
  • Template-based emails for consistency
  • Track delivery status and retries

🚀 Usage

Send Alert Email

from src.agents.notification.email_notification_handler_agent import EmailNotificationHandlerAgent

handler = EmailNotificationHandlerAgent()

# Send alert email
await handler.send_alert(
recipients=["admin@city.gov", "traffic@city.gov"],
alert_type="accident",
data={
"location": "Nguyen Hue Street",
"severity": "high",
"description": "Two-vehicle collision"
}
)

Send Report

# Send daily report
await handler.send_report(
recipients=["management@city.gov"],
report_type="daily_summary",
date="2025-11-29",
attachments=["report.pdf"]
)

Bulk Send

# Send to subscriber list
await handler.bulk_send(
template="congestion_alert",
subscriber_list="traffic_updates",
data={
"affected_areas": ["District 1", "District 3"],
"estimated_delay": "30 minutes"
}
)

⚙️ Configuration

# config/notification_config.yaml
email_handler:
enabled: true

# SMTP settings
smtp:
host: "smtp.gmail.com"
port: 587
username: "${SMTP_USER}"
password: "${SMTP_PASSWORD}"
use_tls: true

# Sender info
sender:
name: "UIP Traffic Alerts"
email: "alerts@uip-platform.com"

# Templates
templates:
path: "templates/email"
default: "base.html"

# Retry settings
retry:
max_attempts: 3
delay_seconds: 60

📧 Email Templates

TemplatePurposeVariables
accident_alertAccident notificationlocation, severity, time
congestion_alertTraffic jam alertareas, delay, alternatives
daily_summaryDaily reportstats, incidents, trends
weekly_reportWeekly analyticscharts, comparisons

See the complete agents reference for all available agents.