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 flowtext-processing-flow.ts- A more complex flow using multiple stepssteps/- Directory containing the step definitions used in the flowsrun-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.tsExpected Output
The example will:
- Define and execute a text processing flow
- Show how the flow combines multiple steps (string operations)
- Demonstrate state management between steps
- Display the final output of the flow
Output will show the execution flow and results of processing text through multiple transformation steps.
Next Steps
- Try modifying the flow to add new steps or change the execution order
- Experiment with different input values
- Explore error handling in the Error Handling Example
- Learn about conditional branching in the Conditional Flows Example