Trigger Reference
Built-in triggers that fire workflow executions
Overview
A trigger is attached to a workflow and fires the workflow execution when a specific event occurs. A workflow can have multiple triggers; each independent trigger invocation starts a new execution cycle (subject to the configured WorkflowTriggerStrategy).
All triggers implement IWorkflowTaskTriggerBase and share the same common properties described in the Core API section.
OneTimeTrigger
OneTimeTrigger
Fires exactly once immediately when the workflow starts. Ideal for one-shot automation scripts.
Output: none (the trigger itself does not emit a value).
Configuration: none required.
TimedTrigger
TimedTrigger
Fires the workflow repeatedly at a fixed interval. An optional random tolerance can be applied to avoid thundering-herd patterns when many workflows share the same interval.
Output: DateTimeOffset – the timestamp at which the trigger fired.
| Property | Type | Description |
|---|---|---|
Interval | int (ms) | The base interval between executions in milliseconds. |
Tolerance | int (ms) | Maximum random jitter added or subtracted from the interval. Set to 0 for a fixed interval. |
CronTrigger
CronTrigger
Fires the workflow on a schedule defined by a Quartz.NET cron expression. The expression format uses six or seven fields (seconds, minutes, hours, day-of-month, month, day-of-week, and optional year).
Output: DateTimeOffset – the scheduled fire time.
| Property | Type | Description |
|---|---|---|
CronExpression | string | A valid Quartz.NET cron expression. Default: 0/10 0/1 * 1/1 * ? * (every 10 seconds). |
Cron Expression Examples
| Expression | Fires |
|---|---|
0 0 2 * * ? | Daily at 02:00:00 |
0 0/5 * * * ? | Every 5 minutes |
0 0 9 ? * MON-FRI | Weekdays at 09:00 |
0 0 0 1 * ? | First day of every month at midnight |
FileTrigger
FileTrigger
Fires when a file or directory event is detected by a FileSystemWatcher. You can subscribe to any combination of create, change, delete, and rename events.
Outputs:
FileSystemEventArgs(default) – the raw event args fromFileSystemWatcher.FileInfo– aFileInfoobject for the affected file.string(key:FilePath) – the full path of the affected file.
| Property | Type | Description |
|---|---|---|
Path | string | The directory to watch. |
Filter | string | File name filter pattern, e.g. *.csv. Defaults to all files. |
NotifyFilters | NotifyFilters | Types of changes to watch for. Default: LastWrite | FileName | DirectoryName. |
IncludeSubdirectories | bool | Monitor subdirectories recursively. |
OnCreateEventEnabled | bool | Subscribe to file creation events. |
OnChangeEventEnabled | bool | Subscribe to file change events. |
OnDeleteEventEnabled | bool | Subscribe to file deletion events. |
OnRenamedEventEnabled | bool | Subscribe to file rename events. |
HttpListenerTrigger
HttpListenerTrigger
Starts an HTTP listener and fires the workflow each time an HTTP request is received on the configured prefixes. Useful for building simple webhook receivers or HTTP-triggered automation.
Output: HttpListenerContext – the full request/response context. Use ReadStringFromRequestTask or ReadQueryStringFromRequestTask to read request data, and WriteStringToResponseTask to write a response.
| Property | Type | Description |
|---|---|---|
Prefixes | string | Semicolon or comma-separated URL prefixes, e.g. http://localhost:8080/;. Must end with /. |
netsh http add urlacl.Adding a Custom Trigger
Implement IWorkflowTaskTriggerBase (or extend WorkflowTaskTriggerBase) and register the trigger on the workflow:
await workflow.AddTriggerAsync(new MyCustomTrigger { Name = "My Trigger" });
Custom triggers are described in more detail in Writing Custom Tasks.