Workflow Variables Node

Access Workflow Instance Variables

Actions2

Overview

This node, named "Workflow Variables Node," allows users to access and manipulate variables that persist within the scope of a workflow execution in n8n. It supports two main operations:

  • Get: Retrieve stored workflow instance variables.
  • Set: Store or update workflow instance variables.

This node is useful when you want to share data between different parts of a workflow without passing it explicitly through input/output connections. For example, you can store intermediate results or flags during execution and retrieve them later in the same workflow run.

Properties

Name Meaning
Operation Choose between "Set" (store/update variables) or "Get" (retrieve variables).
Content (JSON) JSON object representing variables to set or keys to get.
Content Multi-line text input for JSON content; required. Used as an alternative to "Content (JSON)".

Note: Both "Content (JSON)" and "Content" represent the same underlying data but differ in input style.

Output

The node outputs an array of items where each item contains a json field with a debug object describing the operation performed:

  • For Set operation:

    • debug.operation: "set"
    • debug.set: The current state of all stored workflow variables after setting new values.
    • Other metadata like instance and execution IDs, and local variable scope size.
  • For Get operation:

    • debug.operation: "get"
    • debug.get: An object containing the requested variables and their current values.
    • Other metadata similar to the Set operation.

If an error occurs and the node is configured to continue on failure, the output item will include an error field describing the issue.

Dependencies

  • No external services or API keys are required.
  • The node relies on internal workflow execution context to store variables scoped by execution ID.
  • No special environment variables or n8n configurations are needed beyond standard workflow setup.

Troubleshooting

  • Common issues:
    • Invalid JSON in the "Content" property will cause parsing errors.
    • Attempting to get variables that have not been set will return undefined values.
  • Error messages:
    • JSON parsing errors if the content is malformed.
    • NodeOperationError wrapping any unexpected exceptions during execution.
  • Resolutions:
    • Ensure valid JSON syntax in the "Content" input.
    • Use the "Set" operation first to initialize variables before attempting to "Get" them.

Links and References

Discussion