Custom Function
The Custom Function node lets you execute custom JavaScript code within your Agentflow. It securely runs your logic in a Node.js sandbox, giving you full flexibility to transform data, call tools, and apply complex logic at any point in the flow.

Custom Function node on the V2 Agentflow Canvas
Inputs
- Input Variables (JSON): Map values from upstream nodes as input variables. They can be referenced inside your JavaScript code with a
$prefix (e.g. if you map an input namedauthData, use$authDatain your function). - Function Name: Optional string to name your function for easier visual identification on the canvas.
- Additional Tools (List): Connect tools from your flow that can be invoked dynamically inside your JavaScript code via:
$tools.{tool_name}.invoke(args) - Javascript Function (Code): Your custom JavaScript payload. This code executes in a sandboxed environment with access to your input variables, flow context, and connected tools.
Outputs
- Output: Returns a
string,number,boolean,json, orarrayto the next connected node. - Ending Node: Use this output anchor to terminate the flow at this node.