Converting Triggers from v1 to v2
In this article we provide an overview of how to migrate your Triggers from OpenFn v1 to v2.
Converting Triggers
Trigger Types on v1
We use 4 types of triggers on v1: Message Filters, Cron Triggers, Flow Triggers, and Fail Triggers.
Converting Cron Triggers
Setting up a Cron Trigger on v2 works just the same as on v1: when you're building a Workflow, select Cron Schedule as Trigger type, and set the frequency.
Converting Flow and Fail Triggers
With a Flow trigger, we can execute a job upon success of another specified job. With a Fail trigger, the job will run if an another specified job failed.
On v2, we achieve the same conditional behavior with Path Conditions: a job can run (1) always, (2), on success of another job, (3) on failure of another job, or (4) on a custom condition - we'll get to this last one in the next section.
So, if on v1 you had a Flow Trigger, on v2 you'll need to choose the
On Success
condition between your jobs. If you had a Fail Trigger, select the
On Failure
condition.
Converting Message Filters
V1 Message Filters work with webhooks: if an external application sends data to your project, you can check whether the incoming message meets (or doesn't meet) certain criteria, and execute jobs accordingly.
V2 works on the same principle, with a somewhat different setup. Once you've configured your Webhook, you can use a custom Path Condition that matches a JavaScript expression to decide whether a subsequent job should be executed or not.
For example, if on v1 you had a Message Filter trigger that looked like this:
The matching v2 JavaScript Path Condition would look like this: