step()

The .step() method adds a new step to the workflow, optionally configuring its variables and execution conditions.

Usage

workflow.step({
  id: "stepTwo",
  outputSchema: z.object({
    result: z.number()
  }),
  execute: async ({ context }) => {
    return { result: 42 };
  }
});

Parameters

stepConfig:

Step | StepDefinition | string
Step instance, configuration object, or step ID to add to workflow

options?:

StepOptions
Optional configuration for step execution

StepDefinition

id:

string
Unique identifier for the step

outputSchema?:

z.ZodSchema
Schema for validating step output

execute:

(params: ExecuteParams) => Promise<any>
Function containing step logic

StepOptions

variables?:

Record<string, VariableRef>
Map of variable names to their source references

when?:

StepCondition
Condition that must be met for step to execute

MIT 2025 © Nextra.