Workflow.execute()

Executes a workflow with the provided trigger data and returns the results. The workflow must be committed before execution.

Usage Example

const workflow = new Workflow({
  name: "my-workflow",
  triggerSchema: z.object({
    inputValue: z.number()
  })
});
 
workflow.step(stepOne).then(stepTwo).commit();
 
const result = await workflow.execute({
  triggerData: { inputValue: 42 }
});

Parameters

options?:

ExecuteOptions
Options for workflow execution
TriggerSchema
string

Returns

WorkflowResult:

object
Results from workflow execution
string
Record<string, StepResult>
WorkflowStatus

Additional Examples

Execute with run ID:

const result = await workflow.execute({
  runId: "custom-run-id",
  triggerData: { inputValue: 42 }
});

Handle execution results:

const { runId, results, status } = await workflow.execute({
  triggerData: { inputValue: 42 }
});
 
if (status === "COMPLETED") {
  console.log("Step results:", results);
}