Overview
Triggers automatically start workflows in response to external events. They live in the config project under triggers/ and must be synced to activate.
Types
| Type | When it fires | Mechanism |
|---|---|---|
| Subscription | When a FHIR resource changes in Aidbox | Aidbox topic-based subscriptions (webhook) |
| Schedule | On a recurring cron or interval | Temporal Schedules |
Directory structure
Each trigger is a subdirectory named after its ID:
triggers/
encounter-finished/ # subscription trigger
definition.yaml
input-mapping.ts
nightly-billing-report/ # schedule trigger
definition.yaml
Activating triggers
Triggers must be synced before they take effect. Use the Sync Triggers button in the admin UI or call:
POST /triggers/sync
This creates the necessary Aidbox subscription resources (for subscription triggers) or Temporal Schedules (for schedule triggers).
How a workflow starts
When a trigger fires:
- Subscription: Aidbox sends a webhook to
POST /triggers/:triggerId/webhookwith the changed resource. - The API runs the trigger's
input-mapping.tsto transform the resource into workflow input. - The API starts a
billingWorkflowon Temporal with the mapped input.
For schedule triggers, Temporal itself starts the workflow directly — no webhook involved.