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
Type of transformation to performOptions:
extract- Pull specific fields from objectiterate- Process each item in arrayfilter- Keep only items matching conditionrestructure- Reshape entire data structuremerge- Combine multiple objectscustom- Use JavaScript for complex transforms
Transform Types
Extract Fields
Pull specific fields from an object, discarding the rest.Fields to extractExample:Input:Output:
Iterate Over Array
Process each item in an array, transforming or filtering items.Path to array to iterate overExample:
${http_request.body.orders}How to transform each itemExample:Reference current item with
${item.field_name}Optional filter condition (keep only matching items)Examples:
Filter Array
Keep only items that match a condition (without transforming them).Path to array
Filter conditionExamples:
Restructure Data
Completely reshape data structure.New structure template using variablesExample - Flatten nested structure:Input:Template:Output:
Merge Objects
Combine multiple objects into one.Objects to mergeExample:Later sources override earlier ones on conflicting keys.
Custom JavaScript
Use JavaScript for complex transformations that don’t fit other types.JavaScript code to transform dataAvailable variables:
input- Input datacontext- Flow context and previous step outputs
Common Patterns
Clean API Response for Agent
Clean API Response for Agent
Extract only fields agent needs from API responseWhy: Reduces token usage, removes noise, faster agent processing
Process Array of Items
Process Array of Items
Transform each item in a listUse when: Need to process lists of items
Filter High-Value Items
Filter High-Value Items
Keep only items meeting criteriaUse when: Only processing subset of data
Prepare Data for API
Prepare Data for API
Reshape data to match API requirementsUse when: External API expects specific format
Combine Multiple Sources
Combine Multiple Sources
Merge data from different sourcesUse when: Need combined view of data
Extract Nested Fields
Extract Nested Fields
Flatten deeply nested structuresUse when: Working with complex API responses
Calculate Aggregates
Calculate Aggregates
Compute statistics from arraysUse when: Need derived metrics
Format for Display
Format for Display
Transform data for user-friendly displayUse when: Preparing data for end users
Real-World Examples
Example 1: E-commerce Order Processing
Scenario: Process orders, filter by status, enrich with customer dataExample 2: Lead Scoring
Scenario: Score leads based on multiple criteriaExample 3: Customer Data Enrichment
Scenario: Combine data from multiple APIsExample 4: Report Generation
Scenario: Transform raw data into report formatExample 5: Form Data Normalization
Scenario: Normalize inconsistent form submissionsVariable 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
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
Output is empty or null
Output is empty or null
Causes:
- Wrong variable path
- Source data doesn’t exist
- Filter condition too strict
- Check execution logs for actual input data
- Verify variable references:
${http.body.data}not${data} - Test filter condition separately
- Add null checks:
${field} != null
Can't access nested fields
Can't access nested fields
Causes:
- Incorrect dot notation
- Field doesn’t exist
- Array needs index
- Verify exact path from logs:
${input.user.profile.name} - Check for arrays: Use
[0]for first element - Handle optional fields:
${input.field || 'default'}
Filter not working
Filter not working
Causes:
- Wrong comparison operator
- Data type mismatch
- Variable reference incorrect
- Use
==for equality, not= - Check types:
"100"vs100 - Log items to see actual values
- Test condition in Eval step first
Iterate produces wrong output
Iterate produces wrong output
Causes:
- Wrong array reference
- Transform template incorrect
- Missing fields in items
- Verify array path in logs
- Check each item has required fields
- Use
${item.field || 'default'}for optional fields - Test with small sample array first
Custom JavaScript errors
Custom JavaScript errors
Causes:
- Syntax error
- Undefined variable
- Missing return statement
- 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
| Use Map When | Use Alternative When |
|---|---|
| Extracting specific fields | Need all data (no transform needed) |
| Reformatting data structure | Agent can work with existing structure |
| Filtering arrays | Condition on single value (use Condition) |
| Merging objects | Complex merge logic (use Eval) |
| Simple calculations | Complex business rules (use Rules) |
| Structural changes only | Need intelligence (use Agent) |
❌ Don’t need Map: Agent can read full API response ✅ Use Map: Filter array to items > 100 ✅ Use Map: Flatten nested object structure
❌ Use Agent instead: Interpret and summarize nested data
Performance Tips
Filter before processing
Filter before processing
Reduce array size before complex transformationsGood:Bad:
Use built-in transforms
Use built-in transforms
Built-in transforms (Extract, Iterate, Filter) are faster than Custom JavaScriptFast: Extract, Iterate, Filter, Restructure
Slower: Custom JavaScript (but more flexible)
Slower: Custom JavaScript (but more flexible)
Limit array sizes
Limit array sizes
Processing large arrays can be slow. Consider:
- Paginating API calls
- Filtering at source (database query, API parameters)
- Processing in batches
Avoid nested iterations
Avoid nested iterations
Don’t iterate arrays within iterationsBad:Better: