Docs
Sign in

Python

The Python node runs a Python script as a step in a workflow, with variables you map in as JSON.

Screenshot to add: A Python node with its settings panel showing the Python code, Input mapping and Output key fields.

The palette describes it as "Run Python".

When to use it

Use it when you need a custom calculation or data change written in Python. If you want to choose the language on the node, or use TypeScript, use the Code node.

Settings

FieldWhat it doesNotes
Python codeYour scriptHint "Write your script below"
Input mapping (JSON)The variables made available to the scriptHint "Variables available in script". Default {}
Output keyThe name the result is stored underDefault script_output in the form. A new node starts with py_output

A new node starts with this code:

def run(input: dict) -> dict:
    # Your logic here
    return {"result": input}

Inputs and outputs

HandleWherePurpose
InputTopThe step that comes before
OutputBottomContinues the workflow with the script's result

The node card shows a "Python" tag.

Example

This is an illustrative example. You want to work out a total from a list of amounts.

  1. In Input mapping (JSON), map the amounts from the previous step into a variable.
  2. In Python code, add them up and return the total.
  3. Read the total in the next step using the Output key.

Tips

  • Keep the function name run, as in the starter code.
  • Make sure Input mapping (JSON) is valid JSON.
  • Use the Code node if you need to install packages from the settings panel.