Events Providers Overview
Introduction
Section titled “Introduction”Events Providers enable your digital worker to respond to external triggers beyond messaging. They handle:
- Webhooks from external services
- Scheduled tasks (timers/cron)
- Email notifications
- SMS notifications
Available Providers
Section titled “Available Providers” Webhook Receive HTTP webhooks from external services
Timer Schedule tasks with cron expressions
Email (SendGrid) Send transactional emails via SendGrid
SMS (Twilio) Send SMS messages via Twilio
Architecture
Section titled “Architecture”External Service / Timer │ ▼ HTTP / Schedule┌─────────────────────────────────────────┐│ Events Ingress ││ (Process incoming event) │└─────────────────────────────────────────┘ │ ▼ Normalized Event┌─────────────────────────────────────────┐│ NATS Bus ││ greentic.events.{env}.{tenant}.{type}│└─────────────────────────────────────────┘ │ ▼┌─────────────────────────────────────────┐│ Flow Executor ││ (Process with event flows) │└─────────────────────────────────────────┘Event Normalization
Section titled “Event Normalization”All events are normalized to a common format:
pub struct Event { pub id: String, pub event_type: String, pub source: String, pub timestamp: u64, pub payload: Value, pub metadata: Option<Value>,}Configuration
Section titled “Configuration”In Bundle
Section titled “In Bundle”providers: events-webhook: pack: "providers/events/events-webhook.gtpack"
events-timer: pack: "providers/events/events-timer.gtpack"Event Flows
Section titled “Event Flows”name: handle_eventversion: "1.0"
nodes: - id: process type: script config: script: | // Process the event let payload = event.payload; process_payload(payload) next: respond
triggers: - type: event event_type: "order.created" target: processNATS Subjects
Section titled “NATS Subjects”Events flow through NATS:
| Subject | Purpose |
|---|---|
greentic.events.{env}.{tenant}.{type} | Event notifications |
greentic.events.{env}.{tenant}.{type}.result | Event processing results |
Common Patterns
Section titled “Common Patterns”Event-Driven Notifications
Section titled “Event-Driven Notifications”nodes: - id: on_order type: branch config: conditions: - expression: "event.event_type == 'order.created'" next: send_confirmation - expression: "event.event_type == 'order.shipped'" next: send_trackingScheduled Tasks
Section titled “Scheduled Tasks”nodes: - id: daily_report type: http config: method: GET url: "https://api.example.com/reports/daily" next: send_email
triggers: - type: timer cron: "0 9 * * *" # 9 AM daily target: daily_report