Skip to main content
The Code node lets you run custom JavaScript within your flow. It is useful for operations that cannot be achieved with standard nodes: transforming data, performing calculations, manipulating text, or integrating custom business logic.

Accessing variables

Inside the Code node you can read and write flow variables using predefined global objects.

Context ($context)

Variables that persist only during the current flow execution:

Memory ($memory)

Variables that persist across workflows, tools, and nodes. They support time-to-live (TTL):

Reading

Deletion

Limits by data type

The methods $memory.setFile(), $memory.getFile().toBase64(), and $memory.getFile().toRaw() are asynchronous. You must use await when calling them.

Migration from legacy nodes

  1. Create a new Code (Memory V2) node.
  2. Copy and paste the script from the legacy node.
  3. Use the new available methods ($memory.setJson, $memory.setFile, etc.) if needed.

User ($user)

Information about the contact interacting with your flow:

Message ($message)

The last message sent by the user:

Input/Output (input,input, output)

For communication between tools and workflows:

HTTP responses

If you saved the response from an API node:
The key in $context.getHttpResponse() must match exactly the one you configured in the “Save response” field of the API node.

Available utilities

Logger

Logs values for debugging in key-value format. Logs appear in the execution history:
Each node allows a maximum of 10 log entries. The value of each entry has a limit of 512 characters.

Crypto

Standard cryptographic functions:

Lodash

Utilities for manipulating arrays, objects, and strings:
Allowed MIME types for $memory.setFile():