Overview
The Custom Code action lets you run JavaScript/TypeScript code within your workflow to transform data, make API calls, or perform custom logic.
How It Works
- Input: Access all workflow data via
inputData - Execute: Your code runs in a secure sandbox
- Output: Store results in
outputfor subsequent actions
Input Data
The inputData object contains all data available at this point in your workflow - including data from previous actions, user context, and system variables.
1 2 3 4 5 6// Access workflow data const userName = inputData.user_name; const previousResult = inputData.api_response; // Use optional chaining for nested data const city = inputData.address?.city;
Output
Assign values to the output object to pass data to subsequent actions:
1 2 3 4 5 6output.result = "processed"; output.total = inputData.items.length; output.summary = { success: true, count: 42 };
Runtime & Limits
| Runtime | Deno 1.46.1 (not Node.js) |
| Timeout | 5 seconds |
| Memory | 64 MB |
| Fetch requests | 5 per execution |
| External libraries | None available |
Full ES support: async/await, optional chaining, nullish coalescing, etc.
Examples
Basic Transformation
1 2 3 4 5 6 7 8const items = inputData.raw_items ?? []; output.processed = items.map(item => ({ id: item.id, name: item.name.toUpperCase() })); output.count = items.length;
API Call
1 2 3 4 5 6 7 8 9 10 11 12 13try { const response = await fetch("https://api.example.com/data", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ id: inputData.user_id }) }); output.result = await response.json(); output.success = true; } catch (error) { output.error = error.message; output.success = false; }
Common Gotchas
Important
- Deno, not Node: Node-specific APIs (like
require()) won't work - No libraries: lodash, axios, etc. are not available - use native JS
- 5 fetch limit: Scripts making more than 5 HTTP requests will fail
- 5 second timeout: Long-running operations will be killed
