Ringkasan Provider Event
Pendahuluan
Section titled “Pendahuluan”Events Providers memungkinkan digital worker Anda merespons trigger eksternal di luar messaging. Provider ini menangani:
- Webhook dari layanan eksternal
- Tugas terjadwal (timer/cron)
- Notifikasi email
- Notifikasi SMS
Provider yang Tersedia
Section titled “Provider yang Tersedia” Webhook Menerima webhook HTTP dari layanan eksternal
Timer Menjadwalkan tugas dengan ekspresi cron
Email (SendGrid) Kirim email transaksional melalui SendGrid
SMS (Twilio) Kirim pesan SMS melalui Twilio
Arsitektur
Section titled “Arsitektur”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) │└─────────────────────────────────────────┘Normalisasi Event
Section titled “Normalisasi Event”Semua event dinormalisasi ke format umum:
pub struct Event { pub id: String, pub event_type: String, pub source: String, pub timestamp: u64, pub payload: Value, pub metadata: Option<Value>,}Konfigurasi
Section titled “Konfigurasi”Di Bundle
Section titled “Di Bundle”providers: events-webhook: pack: "providers/events/events-webhook.gtpack"
events-timer: pack: "providers/events/events-timer.gtpack"Event Flow
Section titled “Event Flow”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: processSubject NATS
Section titled “Subject NATS”Event mengalir melalui NATS:
| Subject | Tujuan |
|---|---|
greentic.events.{env}.{tenant}.{type} | Notifikasi event |
greentic.events.{env}.{tenant}.{type}.result | Hasil pemrosesan event |
Pola Umum
Section titled “Pola Umum”Notifikasi Berbasis Event
Section titled “Notifikasi Berbasis Event”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_trackingTugas Terjadwal
Section titled “Tugas Terjadwal”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