Skip to main content

Workflow API

The Workflow API provides the building blocks to create, configure, and connect steps in a workflow.

Classes

Workflow

The main class used to construct and manage a workflow.

Methods:

  • addStep(step: Step): this Adds a single step to the workflow.

    workflow.addStep(myStep);
  • addSteps(...steps: Step[]): this Adds multiple steps to the workflow at once.

    workflow.addSteps(step1, step2, step3);
  • listSteps(): Step[] Returns an array of all steps currently in the workflow.

    const steps = workflow.listSteps();
  • toJSON(): SerializedWorkflow Exports the workflow to a serialized JSON format.

    const definition = workflow.toJSON();
  • toRuntimeWorkflow(): WorkflowRuntimeShape Converts the workflow into a shape ready for the runtime engine.

    const runtimeShape = workflow.toRuntimeWorkflow();
  • save<TResponse = unknown>(options: SaveWorkflowOptions): Promise<SaveWorkflowResponse<TResponse>> Deploys the workflow to the Culvii platform.

    const response = await workflow.save({
    baseUrl: 'https://api.culvii.com',
    cloneId: 'my-clone',
    workbookId: 'my-workbook',
    token: 'my-auth-token'
    });

Step

Represents a single node or action within a workflow.

Methods:

  • connectTo(targetStep: Step, options?: ConnectStepOptions): this Connects this step to another step, defining the execution path.
    triggerStep.connectTo(actionStep);

Types & Interfaces

WorkflowConfig

Configuration object for a complete workflow.

const workflowConfig: WorkflowConfig = {
name: 'Status Workflow',
active: true,
steps: [trigger, setStatus],
};

WorkflowStepConfig

Configuration object for an individual step.

const stepConfig: WorkflowStepConfig = {
name: 'Set Status',
type: 'core.set',
params: {
values: {
status: 'ready',
},
},
};

ConnectStepOptions

Options for connecting steps, such as conditional branching.

SerializedWorkflow

The JSON representation of a workflow.

WorkflowRuntimeShape

The internal representation used by the execution engine.