Custom Code Action

Run JavaScript/TypeScript code within your workflow to transform data, make API calls, or perform custom logic.

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

  1. Input: Access all workflow data via inputData
  2. Execute: Your code runs in a secure sandbox
  3. Output: Store results in output for 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
6
output.result = "processed";
output.total = inputData.items.length;
output.summary = {
  success: true,
  count: 42
};

Runtime & Limits

RuntimeDeno 1.46.1 (not Node.js)
Timeout5 seconds
Memory64 MB
Fetch requests5 per execution
External librariesNone available

Full ES support: async/await, optional chaining, nullish coalescing, etc.

Examples

Basic Transformation

1
2
3
4
5
6
7
8
const 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
13
try {
  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