- Connect
- Triggers
Connect
Triggers
The four ways a run starts - by hand, on a schedule, from a webhook, or through the API.
Rendering diagram…
Every run records what started it: Manual, Scheduled, Webhook or API.
By hand
In the UI, open the workflow, fill in the input form and choose Run. From the command line:
ava run process_invoice --input '{"text": "Invoice 42 ..."}'
Schedule
Add a cron expression to the workflow.
@ava.workflow(input=ReportInput, cron="0 6 * * 1") # Mondays at 06:00
def weekly_report(): ...
| Local operator | Avalanche Cloud | |
|---|---|---|
| A new schedule starts | Off. Turn it on with Run on schedule or ava schedule enable. | On, at deploy |
| Clock | The machine’s local time | UTC |
| Input | Saved when you turn the schedule on | Saved when you turn the schedule on |
ava schedule enable weekly_report --input '{"region": "eu"}'
ava schedule list
Webhook
webhook=True gives the workflow a URL. A POST with a JSON body starts a run, and the body is
the run’s input.
@ava.workflow(input=TicketInput, webhook=True)
def triage(): ...
curl -X POST "$WEBHOOK_URL" -H "Content-Type: application/json" -d '{"ticket_id": 812}'
# 202 {"run_id": "run_..."}
| Find the URL | ava webhooks list |
| Choose the path | webhook=ava.Webhook(path="/tickets") |
| Body | A JSON object, up to 1 MiB |
| Answer | 202 and the run ID. The run continues in the background. |
The local operator’s webhook listener accepts requests from the same machine only, and has no authentication.
API
The operator has a REST API. Starting a run is one request:
curl -X POST http://127.0.0.1:7435/api/v1/runs -H "Content-Type: application/json" \
-d '{"workflow_selector": "flow.py::process_invoice", "input_json": "{\"text\": \"...\"}"}'
