Triggers
Triggers automatically start your flow based on events.
A trigger can be a scheduled date, the arrival of a new file, a new message in a queue, or the completion of another flow’s execution.
Defining triggers
Use the triggers
keyword in the flow to define a list of triggers. You can have several triggers attached to a flow.
The trigger
definition is similar to a task definition — it contains an id
, a type
, and additional properties specific to the trigger type.
The workflow below is triggered automatically every day at 10 AM and whenever first_flow
finishes its execution. Both triggers are independent of each other.
Schedules default to UTC. To use a different time zone, set the timezone
property on the Schedule
trigger (for example, America/New_York
).
id: getting_startednamespace: company.team
tasks: - id: hello_world type: io.kestra.plugin.core.log.Log message: Hello World!
triggers: - id: schedule_trigger type: io.kestra.plugin.core.trigger.Schedule cron: 0 10 * * *
- id: flow_trigger type: io.kestra.plugin.core.trigger.Flow conditions: - type: io.kestra.plugin.core.condition.ExecutionFlow namespace: company.team flowId: first_flow
Add a trigger to your flow
Building on the example flow from the previous pages, add one of the above triggers to the flow.
triggers: - id: every_monday_at_10_am type: io.kestra.plugin.core.trigger.Schedule cron: 0 10 * * 1
The getting_started
flow now runs every Monday at 10 AM, starting the week with the latest product data.
id: getting_startednamespace: company.team
labels: owner: engineering
tasks: - id: api type: io.kestra.plugin.core.http.Request uri: https://dummyjson.com/products
- id: python type: io.kestra.plugin.scripts.python.Script containerImage: python:slim beforeCommands: - pip install polars outputFiles: - "products.csv" script: | import polars as pl data = {{ outputs.api.body | jq('.products') | first }} df = pl.from_dicts(data) df.glimpse() df.select(["brand", "price"]).write_csv("products.csv")
- id: sqlQuery type: io.kestra.plugin.jdbc.duckdb.Query inputFiles: in.csv: "{{ outputs.python.outputFiles['products.csv'] }}" sql: | SELECT brand, round(avg(price), 2) as avg_price FROM read_csv_auto('{{ workingDir }}/in.csv', header=True) GROUP BY brand ORDER BY avg_price DESC; store: true
triggers: - id: every_monday_at_10_am type: io.kestra.plugin.core.trigger.Schedule cron: 0 10 * * 1
To learn more about triggers, check out the full triggers documentation.