Webhook Notification Handler Agent
The Webhook Notification Handler Agent delivers notifications to external systems via HTTP webhooks.
π Overviewβ
| Property | Value |
|---|---|
| Module | src.agents.notification.webhook_notification_handler_agent |
| Class | WebhookNotificationHandlerAgent |
| Author | UIP Team |
| Version | 1.0.0 |
π― Purposeβ
- Deliver notifications to external HTTP endpoints
- Support various authentication methods
- Handle retries for failed deliveries
- Track delivery status and metrics
π Usageβ
Register Webhookβ
from src.agents.notification.webhook_notification_handler_agent import WebhookNotificationHandlerAgent
handler = WebhookNotificationHandlerAgent()
# Register webhook endpoint
webhook = await handler.register_webhook({
"name": "Emergency Services",
"url": "https://emergency.city.gov/api/alerts",
"events": ["accident.high", "accident.critical"],
"auth": {
"type": "bearer",
"token": "${EMERGENCY_API_TOKEN}"
}
})
Send Notificationβ
# Send webhook notification
result = await handler.send(
webhook_id="WH_001",
event="accident.high",
payload={
"incident_id": "ACC_001",
"location": {"lat": 10.8231, "lon": 106.6297},
"severity": "high",
"timestamp": "2025-11-29T10:30:00Z"
}
)
Batch Sendβ
# Send to multiple webhooks
results = await handler.broadcast(
event="congestion.severe",
payload=congestion_data,
webhook_filter={"category": "traffic_ops"}
)
βοΈ Configurationβ
# config/webhook_config.yaml
webhook_handler:
enabled: true
# Delivery settings
delivery:
timeout_seconds: 30
max_retries: 5
retry_delays: [1, 5, 30, 300, 900] # Exponential backoff
# Security
security:
sign_payloads: true
signing_algorithm: "HMAC-SHA256"
include_timestamp: true
# Registered webhooks
webhooks:
- name: "Emergency Services"
url: "https://emergency.city.gov/api/alerts"
events: ["accident.*"]
auth:
type: "bearer"
token: "${EMERGENCY_TOKEN}"
- name: "Traffic Control"
url: "https://traffic.city.gov/webhooks"
events: ["congestion.*", "accident.*"]
auth:
type: "basic"
username: "${TC_USER}"
password: "${TC_PASS}"
π Webhook Eventsβ
| Event Pattern | Description | Priority |
|---|---|---|
accident.* | All accident events | High |
accident.critical | Critical accidents | Immediate |
congestion.severe | Severe congestion | High |
system.health | Health status | Low |
π Authentication Typesβ
| Type | Description | Headers |
|---|---|---|
bearer | Bearer token | Authorization: Bearer <token> |
basic | Basic auth | Authorization: Basic <base64> |
api_key | API key header | X-API-Key: <key> |
custom | Custom headers | User-defined |
π Related Documentationβ
- Alert Dispatcher - Alert generation
- Email Handler - Email alternative
- Subscription Manager - Event subscriptions
See the complete agents reference for all available agents.