Skip to Content

Workflow.branch()

The .branch() method creates conditional branches between workflow steps, allowing for different paths to be taken based on the result of a previous step.

Usage example

workflow.branch([ [async ({ context }) => true, step1], [async ({ context }) => false, step2], ]);

Parameters

steps:

[() => boolean, Step]
An array of tuples, each containing a condition function and a step to execute if the condition is true

Returns

workflow:

NewWorkflow
The workflow instance for method chaining