Map

A guide on using the Map node to iterate over lists and process items in parallel.

The Map Node is a powerful tool for iteration. It takes a list of items as input and runs a sub-workflow for each item in that list, either sequentially or in parallel. This is incredibly useful for batch processing, data transformation, and running the same set of actions on multiple inputs.

Think of it as an assembly line: you provide a box of parts (your list), and the Map node sends each part down a mini-assembly line (the sub-workflow) to be processed.

How it Works

The Map node requires an input array (a list of items). For each item in the array, it executes the series of nodes contained within its sub-workflow. The outputs from each individual run are then collected into a new array.

graph TD
    A[Start: List of URLs] --> B{Map Node};
    subgraph B_sub [For Each URL]
        C[Web Scrape] --> D[LLM: Summarize];
    end
    B --> E[Output: List of Summaries];

Configuration

Input Parameters

Parameter
Type
Description

Input List

Array

The list of items you want to iterate over. This must be an array, often from a previous node (e.g., {{web_scraping_node.results}}).

Concurrency

Number

The number of items to process in parallel. A higher number means faster processing but uses more resources. Defaults to 1 (sequential).

The Sub-Workflow

Inside the Map node, you build the sequence of actions that should be performed on each item. To access the current item being processed, use the variable {{item}}.

  • {{item}}: Represents the individual item from the Input List for the current iteration.

  • {{index}}: Represents the position (or index) of the current item in the list.

Output Parameters

Parameter
Type
Description

Output

Array

A new array containing the results from the final node of each sub-workflow execution.

Example: Summarize a List of Articles

Let's say you have a list of URLs from a Google Search and you want to summarize each one.

  1. Configure the Map Node:

    • Input List: Set this to the output of your Google Search node, which is an array of URLs (e.g., {{google_search_node.results}}).

    • Concurrency: Set to 5 to process five articles at a time.

  2. Build the Sub-Workflow:

    • Inside the Map node, add a Web Scraping Node.

      • Set its URL parameter to {{item.link}} to scrape the article link for the current iteration.

    • Next, add an LLM Node.

      • Set its prompt to Summarize the following text: {{web_scraping_node.text}}. This will take the scraped text from the current article and generate a summary.

  3. Use the Output:

    • The Output of the Map node will be an array containing the summaries from the LLM node for each article. You could connect this to a Google Sheet Node to save all your summaries in one place.

Last updated

Was this helpful?