Eval Step
The Eval step executes custom JavaScript code within your flow. Use it for complex logic, custom calculations, advanced data manipulation, or anything that can’t be accomplished with other step types. Full JavaScript ES6+ support with access to common libraries.How It Works
Eval executes JavaScript code and returns the result:When to Use Eval
Examples:
✅ Use Eval: Calculate compound interest with variable rates, fees, and payment schedules
❌ Use Rules instead: Simple percentage calculation ✅ Use Eval: Implement custom recommendation algorithm
❌ Use Agent instead: Interpret user needs and recommend ✅ Use Eval: Parse and validate complex data formats
❌ Use Map instead: Extract fields from JSON
Configuration
Code
JavaScript code to executeMust return a value using
return statementAvailable variables:input- Input data from previous step or triggercontext- Full flow context including all previous stepstrigger- Original trigger datasecrets- Access to secrets (read-only)
Input Data
Data passed to the Eval stepCan reference previous steps:Accessible in code as
input objectTimeout
Maximum execution time in millisecondsRecommendations:
- Simple logic: 1000ms (1 second)
- Moderate complexity: 5000ms (5 seconds, default)
- Heavy processing: 30000ms (30 seconds)
Available Libraries
Eval has access to common JavaScript libraries:Lodash
Lodash
Utility library for arrays, objects, and moreImport:Common uses:
Moment.js
Moment.js
Date and time manipulationImport:Common uses:
Math.js
Math.js
Advanced mathematical operationsImport:Common uses:
Crypto (Node.js)
Crypto (Node.js)
Cryptographic functionsImport:Common uses:
Standard JavaScript
Standard JavaScript
All standard ES6+ features availableIncludes:
- Array methods (map, filter, reduce, find, etc.)
- Object methods (keys, values, entries, assign, etc.)
- String methods (split, replace, match, etc.)
- Math object (round, floor, ceil, random, etc.)
- JSON parse/stringify
- RegExp for pattern matching
- Promises and async/await
- Template literals
- Destructuring
- Spread operator
Common Patterns
Complex Calculations
Complex Calculations
Calculations beyond simple operators
Advanced Array Processing
Advanced Array Processing
Complex array manipulation beyond Map
Data Validation
Data Validation
Custom validation logic
String Parsing and Formatting
String Parsing and Formatting
Complex string manipulation
Date/Time Calculations
Date/Time Calculations
Complex date logic
Conditional Logic with Edge Cases
Conditional Logic with Edge Cases
Complex business logic with many conditions
API Response Transformation
API Response Transformation
Complex data reshaping beyond Map
Custom Scoring Algorithm
Custom Scoring Algorithm
Proprietary scoring logic
Real-World Examples
Example 1: Mortgage Qualification Calculator
Example 2: Recommendation Engine
Example 3: Fraud Detection Scoring
Best Practices
Use Judiciously
Only use Eval when built-in steps (Map, Rules, Functions, Condition) can’t accomplish the task. Eval adds complexity.
Always Return a Value
Code must include a
return statement. The returned value becomes the step output.Handle Errors
Use try-catch blocks for operations that might fail. Return error information for debugging.
Keep It Fast
Optimize for performance. Long-running code slows flows. Set appropriate timeouts.
Test Thoroughly
Test with real data and edge cases. Use Test Mode to verify before production.
Document Complex Logic
Add comments explaining what the code does and why. Future you will thank present you.
Avoid External API Calls
Use HTTP Request step for API calls, not fetch/axios in Eval. Eval is for computation, not I/O.
Validate Inputs
Check that input has expected structure before processing. Return meaningful errors if not.
Troubleshooting
Code execution fails
Code execution fails
Causes:
- Syntax error in JavaScript
- Runtime error (undefined variable, null reference)
- Exceeded timeout
- Missing return statement
- Check execution logs for error message
- Test code separately in JavaScript console
- Add try-catch blocks
- Verify all variables exist before using
- Add return statement
Can't access input data
Can't access input data
Causes:
- Wrong variable name
- Input not passed correctly
- Variable undefined
- Use
inputto access passed data - Use
contextfor full flow context - Check input configuration
- Add null checks:
const value = input?.field || 'default'
Library not available
Library not available
Causes:
- Library not included in Eval environment
- Wrong import syntax
- Check available libraries list
- Use correct require syntax:
const _ = require('lodash') - For unavailable libraries, implement logic directly or use different step
Timeout errors
Timeout errors
Causes:
- Code takes too long to execute
- Infinite loop
- Processing large datasets
- Optimize algorithm
- Increase timeout setting
- Process data in smaller chunks
- Use Map step for large array processing instead
Unexpected output
Unexpected output
Causes:
- Logic error in code
- Wrong data types
- Missing edge case handling
- Add console.log statements (appear in logs)
- Test with various inputs
- Verify data types match expectations
- Handle null/undefined cases
Security Considerations
No External Network Access
No External Network Access
Eval cannot make external HTTP requests. Use HTTP Request step for API calls.Blocked:
- fetch()
- XMLHttpRequest
- axios
- node-fetch
Secrets Access
Secrets Access
Can read secrets but not write them
Input Validation
Input Validation
Always validate input data, especially user-provided data
Sandboxed Execution
Sandboxed Execution
Code runs in isolated environment
- Cannot access file system
- Cannot execute system commands
- Cannot import arbitrary modules
- Timeout enforced automatically
Next Steps
Map Step
Simpler data transformations
Rules Step
Declarative business logic
Functions Step
Pre-built utility functions
Condition Step
Route based on Eval output