Triggers
Weik.io 2026.1Execute actions automatically based on events or schedules.
Triggers connect events and schedules to the code you want to run. While an Action defines what happens, a Trigger defines when it happens.
Trigger types#
You can start an Action in two ways:
- Event Triggers: Something happened in the system. A file arrived in an SFTP folder, a database row was updated, or a webhook was received.
- Schedule Triggers: A specific time was reached.
Event Triggers#
When an event fires, it usually carries a payload of data. The Event Trigger catches the event, extracts the relevant data, and passes it to your Action.
apiVersion: weik.io/v1alpha1
kind: EventTrigger
metadata:
name: process-new-orders
spec:
# Listen to this specific source and event type
eventSource: orders-source
eventType: order.created
# When it happens, run this Action
action: process-order
# Pull data out of the event payload to feed the Action
parameters:
orderId: "{{event.data.id}}"
customerId: "{{event.data.customerId}}"
priority: "{{event.data.priority}}"
# Only trigger if this condition is met
filter:
expression: "event.data.amount > 100"Filtering events#
You rarely want to trigger an Action for every event. For example, when listening to a file system, you may only care about .csv files, not temporary .tmp files the system creates.
Use the filter block to ignore irrelevant events:
filter:
conditions:
- field: "event.data.fileType"
operator: "equals"
value: "pdf"Schedule Triggers#
Schedule Triggers are cron jobs that fire an Action.
apiVersion: weik.io/v1alpha1
kind: ScheduleTrigger
metadata:
name: daily-report
spec:
# Standard 5-field cron (unlike Scheduled Tasks which use 6)
schedule: "0 9 * * *"
timezone: "America/New_York"
action: generate-daily-report
# Hardcode the parameters you want to pass to the Action
parameters:
reportType: "daily"
recipients: "team@company.com"Note: Schedule Triggers use standard 5-field cron, which is different from the 6-field Quartz cron used in Scheduled Tasks.
Handling failures#
Networks and APIs can fail. Triggers provide several ways to handle failures without losing data.
Retries#
If the Action fails, you can configure the Trigger to try again. Use exponential backoff to avoid overloading a failing service.
spec:
retry:
maxAttempts: 3
backoff: exponential
initialDelay: 5sNotifications#
When retries are exhausted and the Action has failed, you can configure notifications instead of relying on manual dashboard checks.
spec:
notifications:
onFailure:
- type: slack
channel: "#alerts"
- type: email
to: "ops@company.com"Best practices#
Avoid wildcards unless necessary
Listening to eventType: file.* can cause problems at scale. If 10,000 files arrive in a directory, the platform starts 10,000 Action instances, which can crash your agent. Be specific.
Expect duplicate events Network retries happen, and message queues sometimes deliver the same message twice. If your Trigger fires twice for the same event, your Action must detect that the work is already done (idempotency).
Specify timezones
If you do not specify a timezone on a Schedule Trigger, it defaults to UTC. A “9 AM” report scheduled in UTC fires at 5 AM Eastern Time. Always specify timezone: "America/New_York" (or your local equivalent).
Next steps#
- Automation Overview: Learn about automation features
- Actions: Create actions to trigger
- Scheduled Tasks: Alternative scheduling approach
- Event Sources: Create event sources for triggers