Examples
Flow Definition

Flow Definition and Execution Example

This example demonstrates how to define and execute flows in ZoopFlow. Flows combine individual steps into a workflow that processes data and manages state.

What You'll Learn

  • How to define a flow with input and output schemas
  • How to implement a flow's execution logic
  • How to use steps within a flow
  • How to execute a flow and track its progress
  • How to manage state within a flow

Files in this Example

  • basic-flow-definition.ts - Demonstrates how to define a simple flow
  • text-processing-flow.ts - A more complex flow using multiple steps
  • steps/ - Directory containing the step definitions used in the flows
  • run-example.ts - Entry point to run the example

Flow Definition Concepts

In ZoopFlow, flows:

  • Have a unique identifier and version
  • Define their input and output schema (using JSON Schema)
  • Contain execution logic as an async function
  • Can use registered steps to perform operations
  • Maintain state during execution
  • Can be composed of multiple steps with dependencies

How to Run

# From the project root
npm install
npx ts-node docs/new-structure/examples/flow-definition/run-example.ts

Expected Output

The example will:

  1. Define and execute a text processing flow
  2. Show how the flow combines multiple steps (string operations)
  3. Demonstrate state management between steps
  4. Display the final output of the flow

Output will show the execution flow and results of processing text through multiple transformation steps.

Next Steps