Iterator

Automate workflows by looping over lists and executing flows for each item with the Iterator component in FlowHunt.

Iterator

Component description

How the Iterator component works

Iterator Component

The Iterator component is designed to execute a sub-flow or an external flow repeatedly for each item in a given list. This enables batch processing, looping, or parallel execution of AI tasks over multiple inputs, which is essential when handling workflows that involve lists or collections of data.

What the Component Does

The Iterator automates repetitive execution within your AI workflow. It takes a list of inputs, and for each item in this list, it runs a specified AI flow (which could be any process or model you have defined). This is particularly useful for scenarios like:

  • Processing multiple documents, images, or messages in sequence
  • Applying the same transformation or analysis to a batch of data
  • Collecting or aggregating results from repeated executions

Key Inputs

The component exposes the following configurable fields:

Field NameTypeRequiredDescription
Flow Execution (flow)FlowExecutionYesThe sub-flow or external flow to execute for each item in the input list.
Input List (flow_inputs)Data, MessageYesThe list of inputs to loop over (each item will trigger a flow execution).
Include Previous Iteration Output (include_prev_output)Bool (Advanced)NoPasses the previous iteration’s output as {prev_iter_res} to the next iteration. Only works with single-threaded (concurrency = 1) execution.
Max Concurrency (max_concurrency)Int (1-20, Advanced)NoSets the maximum number of flow executions to run in parallel. Default is 1 (sequential).
Separator (separator)String (Advanced)NoOptional separator string to use between each flow execution’s output.

Outputs

The main output of the Iterator is:

  • Message (text_output): A message containing the aggregated results of running the flow on each input item. The output type is consistent with the output of the executed flow.

How It Works

  1. You provide a list of items (e.g., messages, data entries).
  2. You choose or define a flow to execute for each item.
  3. The Iterator executes the flow for each list item, either sequentially or in parallel (as set by Max Concurrency).
  4. It collects the outputs and returns them as a single Message output, optionally separated by a custom string.

If Include Previous Iteration Output is enabled (and concurrency is set to 1), each iteration can access the result of the preceding iteration, enabling chained or stateful processing.

Why Use the Iterator Component?

  • Scalability: Efficiently process large batches of inputs without manual looping.
  • Parallelism: Speed up workflows by running executions concurrently.
  • Reusability: Apply the same sub-flow logic to any list of data.
  • Flexibility: Customize iteration behavior with advanced options like output chaining and output formatting.

Example Use Cases

  • Applying sentiment analysis to a list of user comments.
  • Running document summarization on a batch of uploaded files.
  • Translating a collection of messages using a translation flow.

Summary Table

PurposeInputsOutputsAdvanced Options
Batch execution of flowsList of items, Flow to executeAggregated MessageOutput chaining, concurrency, separator

The Iterator is a powerful tool for automating repetitive tasks in AI workflows, making it an essential building block for scalable and maintainable process automation.

Examples of flow templates using Iterator component

To help you get started quickly, we have prepared several example flow templates that demonstrate how to use the Iterator component effectively. These templates showcase different use cases and best practices, making it easier for you to understand and implement the component in your own projects.

Frequently asked questions

What does the Iterator component do?

The Iterator component runs a specific flow or subflow for each item in a provided list, making it easy to automate repetitive processing tasks within your workflow.

Can the Iterator process items concurrently?

Yes, you can set the maximum number of concurrent executions for efficient processing, allowing the component to handle multiple items in parallel.

How do I use previous iteration results?

You can include the output of the previous iteration in the next one by enabling the 'Include Previous Iteration Output' option, which is useful for sequential dependencies when concurrency is set to 1.

What types of data can I iterate over?

The Iterator supports lists of data or messages, allowing flexibility in the type of input you want to process.

Where is the Iterator useful?

Use the Iterator for batch data processing, sending multiple requests, or applying a series of actions to each item in a dataset within your FlowHunt workflows.

Try FlowHunt Iterator

Unlock powerful workflow automation by leveraging the Iterator component in FlowHunt for scalable, repeatable processes.

Learn more