Skip to content

Triggers & Automation

Triggers enable scheduled automation and event-driven workflows for your applications.

What are Triggers?

Triggers are scheduled tasks that:

  • Execute on a cron schedule (per-second precision)
  • Call registered backend services
  • Pass execution context and parameters
  • Support enable/disable without deletion

Creating a Trigger

Step 1: Navigate

Open a project, select the tenant and application, then open the application's Triggers page.

Step 2: Click Create

Click the Add Trigger button.

Step 3: Configure

  • Name (required) - Descriptive trigger name
  • Description - What this trigger does
  • Run Key (required) - Identifier for the backend
  • Cron Expression (required) - Schedule (see below)
  • Enabled - Start enabled or disabled

Step 4: Save

Click Create to save. The trigger belongs to the application whose Triggers page you are on.

Cron Expressions

Triggers use standard cron syntax with second precision:

 ┌─────── second (0-59)
 │ ┌────── minute (0-59)
 │ │ ┌───── hour (0-23)
 │ │ │ ┌──── day of month (1-31)
 │ │ │ │ ┌─── month (1-12)
 │ │ │ │ │ ┌── day of week (0-6, 0=Sunday)
 │ │ │ │ │ │
 * * * * * *

Common Examples

ExpressionDescription
0 0 * * * *Every hour at minute 0
0 */5 * * * *Every 5 minutes
0 0 0 * * *Daily at midnight
0 0 9 * * 1-5Weekdays at 9 AM
0 30 14 * * *Daily at 2:30 PM
0 0 0 1 * *First day of month

Testing Cron Expressions

Use online tools like crontab.guru for the trailing five fields, or test in a development environment.

Per-Second Precision

Manager cron expressions always have six fields — the first field is seconds. For example, 30 * * * * * runs at 30 seconds past every minute. Invalid expressions are rejected when the trigger is saved.

Trigger List

The application's Triggers page lists each trigger with:

  • Name - Trigger display name
  • Description - What the trigger does
  • Schedule - Cron expression
  • Enabled - Active/inactive state
  • Actions - Edit, Enable/Disable, Delete

Editing a Trigger

  1. Click the Edit icon on a trigger
  2. Modify fields:
    • Name
    • Cron expression
    • Run key
    • Description
  3. Click Save Changes

WARNING

Changing the cron expression takes effect immediately. The new schedule applies to the next execution.

Enable/Disable Triggers

Toggle triggers without deleting them:

From List

Click the toggle switch in the "Enabled" column.

From Edit Form

Check or uncheck the "Enabled" checkbox.

Use cases:

  • Temporarily pause automation
  • Disable during maintenance
  • Test schedule changes

Deleting a Trigger

  1. Click Delete icon on the trigger
  2. Confirm deletion
  3. Trigger is permanently removed

Deleted triggers:

  • Stop executing immediately
  • Cannot be recovered

How Triggers Work

Backend Registration

For triggers to execute, your application backend must:

  1. Register with Manager using a machine user
  2. Provide a callback URL for trigger execution
  3. Keep connection alive with heartbeat signals

See Backend Registration for technical details.

Trigger Execution Flow

1. Manager checks cron schedules (every trigger_check_interval)
2. Finds triggers due to execute
3. Looks up registered backends for the application
4. POSTs trigger payload to backend callback URL
5. Backend processes the trigger
6. Manager records dispatch metrics and logs failures

Trigger Payload

Backends receive JSON payload:

json
{
  "trigger_id": "uuid",
  "trigger_name": "Daily Report",
  "cron_expression": "0 0 * * * *",
  "run_key": "daily-report",
  "executed_at": "2025-12-01T12:00:00Z"
}

Common Use Cases

Daily Reports

Name: Daily Sales Report
Cron: 0 0 0 * * *
Run Key: daily-sales-report

Backend generates and emails sales report.

Hourly Data Sync

Name: Sync External Data
Cron: 0 0 * * * *
Run Key: data-sync

Backend fetches data from external API.

Cleanup Tasks

Name: Clean Old Logs
Cron: 0 0 2 * * *
Run Key: log-cleanup

Backend purges logs older than 30 days.

Monitoring Health Checks

Name: Health Check
Cron: 0 */5 * * * *
Run Key: health-check

Backend checks service health every 5 minutes.

Weekly Maintenance

Name: Weekly Backup
Cron: 0 0 3 * * 0
Run Key: weekly-backup

Backend performs weekly backup on Sundays at 3 AM.

Best Practices

Naming

  • Use descriptive names: "Daily Report", "Hourly Sync"
  • Include frequency: "Every 5min Health Check"
  • Avoid generic names: "Trigger 1", "Test"

Scheduling

  • Avoid peak hours - Schedule heavy tasks during off-peak
  • Stagger triggers - Don't run all triggers at same time
  • Consider time zones - Cron uses server timezone
  • Test schedules - Verify cron expression before deploying

Run Keys

  • Use consistent naming: kebab-case
  • Match backend expectations
  • Document in backend code

Monitoring

  • Check last run times regularly
  • Monitor backend logs for errors
  • Set up alerts for failed executions

Troubleshooting

Trigger Not Executing

Check:

  1. Is the trigger enabled?
  2. Is a backend registered and healthy for the application?
  3. Is the cron expression valid?
  4. Check backend logs for errors

Debug:

  1. View trigger details
  2. Check the executor metrics and Manager logs
  3. Verify the backend's heartbeat has not timed out
  4. Test the cron expression

Trigger Executing Too Often

Reason: Cron expression is too frequent

Solution:

  1. Review cron expression
  2. Add delays between executions
  3. Consider aggregating tasks

Backend Not Receiving Triggers

Check:

  1. Is backend registered?
  2. Is callback URL correct and accessible?
  3. Is machine user authentication valid?
  4. Check network/firewall rules

Solution: See Backend Registration

Trigger Executing at Wrong Time

Reason: Timezone mismatch

Solution:

  1. Verify server timezone
  2. Adjust cron expression for timezone
  3. Document timezone in trigger description

Monitoring Trigger Execution

Executor Metrics

Trigger execution is monitored through the executor's Prometheus metrics (pfy_executor_*, exposed on the metrics port) and the Manager's server logs:

  • Execution counts and durations per application
  • Backend dispatch success/error rates
  • Dispatch latency

See the Trigger System concepts page for the full metric list.

Backend Health

Backends must re-register (heartbeat) periodically; registrations whose last heartbeat exceeds cron.backend_heartbeat_timeout are marked inactive and stop receiving triggers.

See Also