Skip to Content

Code node

The Code node executes custom code within your workflow. It appears in the Advanced palette category with the description: “Execute custom code.” The node runs in a sandboxed environment with access to workflow variables and platform SDK helpers.

When to use

  • Transform data between nodes (reshape, filter, calculate)
  • Implement custom logic not covered by other nodes
  • Call platform SDK methods (database queries, LLM calls, DMS operations)
  • Parse or validate complex data structures

Configuration

Click the Code node to open its full-screen editor.

Code node full-screen editor showing language selector, code editor with template, quick insert snippets, and output variable
Code node full-screen editor showing language selector, code editor with template, quick insert snippets, and output variable

Editor toolbar

ControlTypeDescription
LanguageCombobox (Python / JavaScript)Code language for this node
VariablesButtonOpens the variable browser to insert {{variable.path}} references
Ask AIButtonAI-assisted code generation
TestButtonExecute the code against test data
Exit fullscreenButtonReturn to canvas view

Code editor

Full-featured code editor with:

  • Line numbers and syntax highlighting
  • {{variable.path}} interpolation (resolved at runtime)
  • Autocomplete (Ctrl+Space)
  • Copy button

Pre-imported modules

Python: json, math, re, datetime, collections, base64, io

SDK helpers (both languages): db, llm, dms

Quick Insert snippets

Pre-built code templates accessible via buttons below the editor:

CategorySnippets
DatabaseSELECT Query, SELECT One Row, INSERT, UPDATE, DELETE
LLMChat, Multi-turn Chat, Streaming Chat, Model from Config, Embeddings
DMSList Documents, List Folder, Download, Read Document, Get Metadata
WorkflowList Inputs, List Outputs, List Artifacts

Output settings

SettingTypeDescription
Output Variable NameText field (default: result)Name used in {{output.node_id.this_name}} to access the result

Output format

Assign your result to the result variable:

result = {"status": "success", "data": processed_data, "count": 42}

Downstream nodes access it as:

  • {{output.<node_id>.result}} → full result object
  • {{output.<node_id>.result.status}}"success"
  • {{output.<node_id>.result.count}}42

Use print() for debugging — output appears in the Test Results panel.

Available system variables

The Variables panel (left sidebar) exposes system context:

VariableTypeDescription
runIdstringCurrent execution run ID
timestampstringExecution start time
envstringEnvironment (preview/production)
agentIdstringCurrent agent ID
agentVersionIdstringCurrent agent version
subscriptionIdstringTenant ID
currentNodeIdstringThis node’s ID
user.idstringCurrent user ID
user.namestringUser display name
user.emailstringUser email
user.rolesarrayUser’s assigned roles

Edge significance

Linear flow: single input → single output edge.

ℹ️

Code runs in a sandboxed environment (indicated by the “Sandboxed” badge on the canvas node). It cannot access the filesystem, network, or external processes directly — use the SDK helpers (db, llm, dms) for platform operations.

Common patterns

  • Data transformation — Reshape query results before passing to an LLM prompt.
  • Validation — Check data integrity and return errors if invalid.
  • Aggregation — Combine results from multiple upstream nodes.
  • SDK operations — Use db.query(), llm.chat(), or dms.list() for platform calls within custom logic.