[ Web Proxy ]
URL:
Viewing: https://openworkflow.dev/docs/dynamic-steps [Back]  [Original]

Dynamic Steps - OpenWorkflow
Skip to main content
Navigation
Guides
Dynamic Steps
Guides

Dynamic Steps

Run a variable number of steps based on runtime data

Sometimes you dont know how many steps a workflow needs until it runs. You might need to fetch data for each item in a list, process rows from a query, or fan out across a set of IDs from an API response. OpenWorkflow handles this automatically. When multiple steps share the same name, theyre disambiguated in order (fetch-data, fetch-data:1, fetch-data:2, ). You dont need to generate unique names yourself.

Basic Pattern

Map over your data and create a step per item using Promise.all:
Every step uses the same name OpenWorkflow appends :1, :2, etc. automatically. Each step is individually memoized, so if the workflow restarts, completed steps return their cached results and only the remaining steps re-execute.

Stable IDs for Mutable Collections

If items can be added, removed, or reordered between retries, include a stable ID from the data in the step name instead of relying on auto-indexing:
This way, each step is tied to a specific item regardless of its position in the array. Use any stable identifier a database ID, a slug, or a unique key from the data itself.
Parallel Steps
Child Workflows

Web Proxy Viewer  |  New URL  |  Original Page