Skip to main content

Map Step

The Map step transforms data structures, iterates over arrays, filters collections, and reshapes objects. Use it to prepare data for agents, format API responses, extract specific fields, or process lists of items.
When to use Map vs. Agents: Use Map for structural transformations (reformatting, filtering, extracting). Use Agents when transformation requires intelligence or interpretation. Map is for predictable data manipulation; agents are for smart decisions.

How Map Works

Map takes input data and transforms it according to rules you define:

Configuration

Transform Type

transformType
enum
required
Type of transformation to performOptions:
  • extract - Pull specific fields from object
  • iterate - Process each item in array
  • filter - Keep only items matching condition
  • restructure - Reshape entire data structure
  • merge - Combine multiple objects
  • custom - Use JavaScript for complex transforms

Transform Types

Extract Fields

Pull specific fields from an object, discarding the rest.
fields
array
required
Fields to extractExample:
Input:
Output:
Use dot notation for nested fields: "address.city" extracts city from address object.

Iterate Over Array

Process each item in an array, transforming or filtering items.
array
string
required
Path to array to iterate overExample: ${http_request.body.orders}
itemTransform
object
required
How to transform each itemExample:
Reference current item with ${item.field_name}
filterCondition
string
Optional filter condition (keep only matching items)Examples:
Complete Example: Input:
Configuration:
Output:

Filter Array

Keep only items that match a condition (without transforming them).
array
string
required
Path to array
condition
string
required
Filter conditionExamples:

Restructure Data

Completely reshape data structure.
template
object
required
New structure template using variablesExample - Flatten nested structure:Input:
Template:
Output:
Example - Create nested structure: Input:
Template:
Output:

Merge Objects

Combine multiple objects into one.
sources
array
required
Objects to mergeExample:
Later sources override earlier ones on conflicting keys.
Example: Input:
Configuration:
Output:

Custom JavaScript

Use JavaScript for complex transformations that don’t fit other types.
code
string
required
JavaScript code to transform dataAvailable variables:
  • input - Input data
  • context - Flow context and previous step outputs
Must return transformed dataExample:
Custom JavaScript has performance implications. Use built-in transform types when possible.

Common Patterns

Extract only fields agent needs from API response
Why: Reduces token usage, removes noise, faster agent processing
Transform each item in a list
Use when: Need to process lists of items
Keep only items meeting criteria
Use when: Only processing subset of data
Reshape data to match API requirements
Use when: External API expects specific format
Merge data from different sources
Use when: Need combined view of data
Flatten deeply nested structures
Use when: Working with complex API responses
Compute statistics from arrays
Use when: Need derived metrics
Transform data for user-friendly display
Use when: Preparing data for end users

Real-World Examples

Example 1: E-commerce Order Processing

Scenario: Process orders, filter by status, enrich with customer data

Example 2: Lead Scoring

Scenario: Score leads based on multiple criteria

Example 3: Customer Data Enrichment

Scenario: Combine data from multiple APIs

Example 4: Report Generation

Scenario: Transform raw data into report format

Example 5: Form Data Normalization

Scenario: Normalize inconsistent form submissions

Variable Mapping

Map step heavily uses variable syntax to reference data. Learn more about variable mapping:

Variable Mapping Guide

Complete guide to referencing data from triggers, steps, and context
Common variable patterns in Map:

Best Practices

Use Right Transform Type

Choose the appropriate transform type. Extract for simple field selection, Iterate for arrays, Custom JS for complex logic.

Keep Transforms Simple

Break complex transformations into multiple Map steps. Easier to debug and maintain.

Filter Early

Filter arrays before processing to reduce computation. Process only what you need.

Test with Real Data

Test Maps with actual data structures from your APIs/databases. Edge cases matter.

Document Complex Logic

Add descriptions to Map steps explaining what transformation does and why.

Avoid Over-Transformation

Let agents handle interpretation. Use Map only for structural changes, not business logic.

Check for Null Values

Always handle null/undefined values. Use ${field || 'default'} for safety.

Validate Output

Verify Map output has expected structure before using in agents or APIs.

Troubleshooting

Causes:
  • Wrong variable path
  • Source data doesn’t exist
  • Filter condition too strict
Solutions:
  • Check execution logs for actual input data
  • Verify variable references: ${http.body.data} not ${data}
  • Test filter condition separately
  • Add null checks: ${field} != null
Causes:
  • Incorrect dot notation
  • Field doesn’t exist
  • Array needs index
Solutions:
  • Verify exact path from logs: ${input.user.profile.name}
  • Check for arrays: Use [0] for first element
  • Handle optional fields: ${input.field || 'default'}
Causes:
  • Wrong comparison operator
  • Data type mismatch
  • Variable reference incorrect
Solutions:
  • Use == for equality, not =
  • Check types: "100" vs 100
  • Log items to see actual values
  • Test condition in Eval step first
Causes:
  • Wrong array reference
  • Transform template incorrect
  • Missing fields in items
Solutions:
  • Verify array path in logs
  • Check each item has required fields
  • Use ${item.field || 'default'} for optional fields
  • Test with small sample array first
Causes:
  • Syntax error
  • Undefined variable
  • Missing return statement
Solutions:
  • Check JavaScript syntax
  • Verify all variables exist: input, context
  • Always return a value
  • Use console.log for debugging (appears in logs)
  • Test JS in Eval step first

When to Use Map vs. Other Steps

Examples: Use Map: Extract name and email from API response
Don’t need Map: Agent can read full API response
Use Map: Filter array to items > 100UseConditioninstead:Checkifsinglevalue>100 ❌ **Use Condition instead**: Check if single value > 100 Use Map: Flatten nested object structure
Use Agent instead: Interpret and summarize nested data

Performance Tips

Reduce array size before complex transformationsGood:
Bad:
Built-in transforms (Extract, Iterate, Filter) are faster than Custom JavaScriptFast: Extract, Iterate, Filter, Restructure
Slower: Custom JavaScript (but more flexible)
Processing large arrays can be slow. Consider:
  • Paginating API calls
  • Filtering at source (database query, API parameters)
  • Processing in batches
Don’t iterate arrays within iterationsBad:
Better:

Next Steps

Variable Mapping

Learn how to reference data in Map transforms

Eval Step

Custom JavaScript for complex logic

Condition Step

Branch based on Map output

Functions Step

Utility functions for common operations