Skip to main content

Code Node

Overview

The Code Node allows for the embedding and execution of custom JavaScript code, handling dynamic data processing and decision-making within workflows.

Configuration

Custom Code Configuration

Users can input and configure JavaScript code that the node will execute. This code can access and manipulate data from the workflow environment.

  • Code: Users can enter JavaScript code in a provided textarea within the settings dialog. A default code example is provided as a template:
(({globalData, message}) => {
return {
target: message ? "NEXT" : "WAIT",
message: "Hello World!",
error: null,
debug: null,
data: {
sample: true
}
}
})({globalData, message})

Schema

The JavaScript code within the node should return an object conforming to the following schema:

{
"target": "string (optional)",
"message": "string (optional)",
"data": "object (optional)",
"error": "string (optional)",
"debug": "string (optional)"
}

This schema defines possible outputs of the code execution:

  • target: Controls the next action (e.g., "NEXT" to proceed, "WAIT" to wait for user input).
  • message: Output to user.
  • data: Contains data to be used by subsequent nodes. (Added to globalData)
  • error: Any error message generated during execution.
  • debug: Any debug message generated during execution.

Output

Outputs the results from the code execution to subsequent nodes, enabling further actions based on the code's output.