Framework

Framework

Triggers

A trigger runs an agent on its own, either when a document changes or on a schedule.

If you want fixed steps without AI, use an Automation Flow instead.

Create a trigger

The quickest way is to ask Flow:

"Every weekday at 9am, email me a summary of yesterday's new leads."

Flow shows you the trigger and saves it once you approve. To set one up by hand, go to Settings > Triggers and click New trigger.

Field What it does
Agent The agent to run.
Event DocType Event runs the agent when a document is created, saved, submitted, cancelled or deleted. Scheduled runs it on a cron expression.
Cron Expression The schedule, for example 0 9 * * 5 for every Friday at 09:00.
Condition An optional Python expression. The agent runs only when it is true.
Prompt Template The message the agent receives. It can use the document's fields.
Run As The user whose permissions the agent works with.

Example

This trigger plans every new high-priority ToDo.

Field Value
Event DocType Event
Target DocType ToDo
Doc Event after_insert
Condition doc.priority == "High"
Prompt Template Read ToDo {{ doc.name }}. Email its owner a short plan to finish it.

Approvals and permissions

A trigger runs with nobody around to approve its changes, so the agent makes every change without asking. Keep that in mind when you set one up:

  • The agent works with the permissions of the Run As user. Pick a user with only the roles the job needs. If you leave Run As empty, the trigger runs as its owner.
  • The trigger skips documents the Run As user can't read.
  • Triggers run as background jobs, so the scheduler and the workers must be running.

Every run is saved as a Flow Run, which shows what the agent did and any errors.

If a trigger doesn't run

Check these in order:

  1. The trigger is enabled.
  2. The scheduler and the workers are running.
  3. The Run As user can read the document and use the agent.
  4. The Condition is true for the document.

If the trigger ran but the result is wrong, open its Flow Run.

Last updated 4 hours ago
Was this helpful?
Thanks!