Skip to main content

Can you write Python in n8n?

Yes. n8n's Code node runs JavaScript or Python in a sandbox, and the output feeds into the next node. The rest of the workflow stays on the canvas.

The Code node and its limits.

The Code node adds Python to a workflow. Here is what it handles and where the workflow around it stays visual.

CapabilityWhat it doesWhere it stops
Python supportRuns JavaScript or Python inside a workflow stepLimited built-in packages. No pip install
Data flowReads input from the previous node, passes output to the nextCode runs inside one step. The workflow logic stays on the canvas
Control flowBranches and loops available as visual nodesWired visually. The orchestration is the canvas, not the code
TestingRun the workflow to verify outputNo test framework. No way to write assertions before going live
PromptsPrompts live in AI nodesNo version history. No rollback on a prompt edit
Model outputAI Agent node processes model responsesNo schema constraint on what the model returns
Change historyWorkflow JSON exportNot a line-level diff. A code change is buried in the full workflow export
Python support
What it doesRuns JavaScript or Python inside a workflow step
Where it stopsLimited built-in packages. No pip install
Data flow
What it doesReads input from the previous node, passes output to the next
Where it stopsCode runs inside one step. The workflow logic stays on the canvas
Control flow
What it doesBranches and loops available as visual nodes
Where it stopsWired visually. The orchestration is the canvas, not the code
Testing
What it doesRun the workflow to verify output
Where it stopsNo test framework. No way to write assertions before going live
Prompts
What it doesPrompts live in AI nodes
Where it stopsNo version history. No rollback on a prompt edit
Model output
What it doesAI Agent node processes model responses
Where it stopsNo schema constraint on what the model returns
Change history
What it doesWorkflow JSON export
Where it stopsNot a line-level diff. A code change is buried in the full workflow export

qbash Tasks.

A Task is an AI automation written in Python, hosted on a managed runtime. A developer writes the script; anyone runs it from a form. Integrations, model calls, version control, and logging are built in.

Model and provider agnostic.

  • Anthropic
  • OpenAI
  • Gemini
  • xAI
  • OpenRouter
  • Amazon
  • Perplexity
  • MoonshotAI
  • Meta
  • Qwen

In qbash, the whole automation is Python.

The trigger, the integrations, the model calls, the branching, and the tests are in one script.

  • 45+ integrations called in one line, with credentials brokered server-side.
  • aisle.ai.run_prompt with an output_schema that constrains the model to your JSON.
  • tests.py runs in a sandbox alongside the task. Assert that the automation works before it goes live.
  • Every save is a version with a line-level diff and one-click rollback.
  • Loops, branches, and functions are language features.
triage.py
since = aisle.run.last_run_at.date().isoformat()

tickets = aisle.integrations.jira.get_tickets_by_time_span(
    query_type="date_range", start_date=since,
)

for ticket in tickets:
    triage = aisle.ai.run_prompt(
        slug="triage-ticket",
        variables={"body": ticket["description"]},
    )
    aisle.integrations.jira.update_ticket(
        ticket["key"], field_id="labels", tag_name=triage["team"],
    )

The orchestration moves into code.

The Code node is Python for one step inside a canvas. A Task is Python for the entire automation: the logic, the integrations, the tests, and the version history.

Revisions and rollback

Every save writes a version with a line-level diff. The tests.py is versioned in the same revision, so the diff shows whether the tests moved with the code. Any version restores in one click.

Structured outputs

Pass an output_schema and the model is constrained to JSON matching it. A malformed answer fails at the schema boundary rather than three steps downstream.

triage.py
TRIAGE = {
    "type": "object",
    "properties": {
        "team": {"enum": ["billing", "technical", "sales"]},
        "priority": {"enum": ["low", "normal", "urgent"]},
    },
}

triage = aisle.ai.raw(
    f"Triage this ticket:\n\n{body}",
    output_schema=TRIAGE,
)

Integrations in code

Read from and write to 45+ services in one line. Credentials are brokered server-side, never in your code or a model context.

notify.py
aisle.integrations.slack.create_message(
    "#ops", text=f"Triaged {len(tickets)} tickets",
)

aisle.integrations.gmail.send_email(
    to="[email protected]",
    subject="Weekly triage report",
    body=report["summary"],
)

Questions

Can n8n's Code node run arbitrary Python packages?

No. The sandbox includes a set of built-in modules. You cannot pip install packages or import libraries outside that set. If the script needs a library the sandbox does not include, the code has to work around it or the logic has to move elsewhere.

Is the Code node the same as writing a full Python script?

No. The Code node runs inside one step of a visual workflow. The surrounding logic, including triggers, routing, error handling, and other integrations, stays on the canvas. In qbash, the entire automation is one Python script.

Do I need to write Python to use qbash?

To build or change a task, yes, though the builder drafts the first version from a description. To run one, no. Typed inputs render a form, so the person who asked for the automation runs it without seeing the code.

How does qbash handle Python dependencies?

The runtime includes a managed set of libraries and the full qbash SDK. You do not manage a requirements.txt or install packages. The platform maintains the interpreter and its upgrades.

Can I move my n8n Code node scripts to qbash?

There is no importer, but the Python inside the node is portable. The work is rebuilding the visual logic around it as code. Describe the workflow to the builder and it drafts the task. See the full qbash vs n8n comparison for migration steps.

Competitor details reviewed . Vendors change plans and features without notice, so check theirs before deciding.

Ship your first task.

Open the editor, write a script against your connected accounts, and put it on a trigger. Or describe it, and the builder drafts the task as code you edit.