Skip to main content

Workflow Premium Action: Custom Code

The Custom Code workflow action lets you run JavaScript inside a workflow to apply custom logic, manipulate data, and make external HTTP requests.

Updated over 2 months ago

Who This Is For / When to Use

Use Custom Code when a workflow requires logic or integrations that cannot be achieved using standard workflow actions.

What the Custom Code Action Does

The Custom Code action executes JavaScript in an asynchronous environment and returns structured output that can be used by subsequent workflow steps.

Add the Custom Code Action

  1. Open the workflow editor.

  2. Click Add Action.

  3. Search for Custom Code and select it.

    [Screenshot: unnamed (32).png]

Configure the Action

Action Name

Set a clear name to identify the purpose of the code step.

Language

JavaScript is the supported language for Custom Code actions.

Add Properties (Input Data)

Properties allow you to pass values from previous triggers or actions into your code.

  1. In Property to include in code, enter a key name.

  2. Map the value using workflow variables.

  3. Access values in code using inputData.keyName.

Write Code

The code editor runs inside an async function and supports await.

  • Output must be a JavaScript object or an array of objects.

  • Assign the final result to output.

Example structure:

  • Read values from inputData.

  • Perform logic or calculations.

  • Set the output object.

Build with AI

You can generate JavaScript automatically using AI.

  1. Click Build with AI.

  2. Describe the logic you need.

  3. Click Generate.

  4. Review and insert the generated code.

Make External HTTP Requests

Custom Code supports outbound HTTP requests.

  1. Click HTTP Requests above the editor.

  2. Select a request method.

  3. The request template is added to the code editor.

Supported methods:

  • GET

  • POST

  • PUT

  • PATCH

  • DELETE

  • HEAD

  • OPTIONS

Test Your Code (Required)

Testing is mandatory before the action can be used in a workflow.

  1. Click Test Your Code.

  2. Provide optional test input.

  3. Run the test.

  4. Review the response and console output.

View Console Logs

Console output from console.log() statements appears during test execution and helps debug logic.

Reference Output

The Reference Output section shows the structure of the returned data available to later workflow steps.

Save the Action

After successful testing, click Save Action to activate the Custom Code step in the workflow.

Common Issues and Fixes

Code Cannot Be Saved

  • Ensure the code is tested successfully.

  • Confirm output is a JavaScript object or array.

Missing Input Values

  • Verify properties are mapped correctly.

  • Use the correct inputData.keyName reference.

Workflow Delays

  • Long-running external API calls can slow execution.

  • Use async logic efficiently.

Important Notes

  • Custom values are not passed during testing; only contact data is available.

  • Untested code cannot pass output to subsequent actions.

  • All console logs are captured during test runs.

Did this answer your question?