Code
Run Python or Node.js for transformations no ready-made node covers.
The Code executor node runs a script inside the flow. It is for transforming data, calculating derived values and applying business rules the standard nodes don't cover.
It is the escape hatch for the specific case, not the default path.
Input variables
Before the code, you declare which data it receives. Each input has two parts:
- Field name: what the variable is called inside the script, for example
textornumber1. - Value: where the data comes from, such as
{{ entrada.mensagem }}.
The names declared here become the main function's arguments.
The code
The editor accepts Python or Node.js. The script must expose a main function whose parameters match the declared input variables.
def main(arg1, arg2):
result = arg1 + arg2
return {"sum": result}Whatever the function returns becomes the node's output, accessible to the following nodes.
When not to use it
A flow whose work all happens inside a code node loses what the canvas offers: the step-by-step reading in the run log.
If the script does three distinct things, splitting them into their own nodes makes investigation much more direct. The log then shows which step failed, instead of pointing at a single block.
Before writing code, check whether there is a ready-made node. Extracting a CPF, querying Collections, calling an API and assembling a file already have dedicated nodes, with their own error handling.