Call Function

Call a Function node defined in the current workflow

Overview

This node allows you to call a Function node defined in another workflow within the same n8n instance. It is useful when you want to reuse logic encapsulated in a Function node from a different workflow without duplicating code. For example, you might have a common data transformation or calculation function that multiple workflows need to invoke.

Typical use cases include:

  • Centralizing complex JavaScript functions in one workflow and calling them from others.
  • Passing parameters dynamically to these functions and optionally storing their return values.
  • Modularizing workflows by separating reusable logic into dedicated Function nodes.

Properties

Name Meaning
ℹ️ If function details are out-of-date, toggle Active off/on for the workflow containing the function A notice to remind users to refresh the workflow activation if function details seem outdated.
Workflow Select the workflow that contains the Function node you want to call.
Function Name or ID Choose the specific Function node to call from the selected workflow. You can select from a dropdown list or specify an ID using an expression.
Last Configured Function Internal field used to track changes in the selected function (hidden).
Last Selected Workflow Internal field used to track changes in the selected workflow (hidden).
Parameter Mode How to specify the function parameters: either as individual parameters or as a single JSON object. Options: "Individual Parameters", "JSON Object".
Parameters JSON When using JSON mode, provide all parameters as a single JSON object.
Function Parameters When using individual parameters mode, specify each parameter name and its value separately.
Store Response Whether to store the return value of the called function in the output item.
Response Variable Name The name of the variable under which to store the function's response in the output JSON. Defaults to "functionResult".

Output

The node outputs an array of items corresponding to the input items. Each output item contains:

  • json: The original input JSON merged with an optional property holding the function's return value if "Store Response" is enabled. The property name is configurable.
  • binary: The original binary data from the input item is preserved unchanged.
  • index: The index of the item in the input array.

If the function call fails for an item, and "Continue on Fail" is enabled, the output item will contain an _functionCall property inside json with details about the failure (functionName, parameters, success: false, and error message).

The node does not produce any new binary data.

Dependencies

  • Requires access to the n8n instance's workflows to select and call Function nodes from other workflows.
  • Depends on an internal Function Registry service to list available functions and their parameters.
  • No external API keys or credentials are required.
  • The target workflow containing the Function node must be active for the function to be callable.

Troubleshooting

  • No workflow selected: The node throws an error if no workflow is selected.
  • No valid function selected: If the selected workflow has no Function nodes or the function selection is invalid, an error is thrown. Ensure the target workflow is active and contains Function nodes.
  • Invalid JSON in parameters: When using JSON mode, malformed JSON will cause an error. Validate the JSON syntax before running.
  • Parameter mismatch: If parameters do not match the function's expected parameters (e.g., due to function changes), warnings are logged, and invalid parameters are ignored.
  • Function call failure: Errors during function execution are caught. If "Continue on Fail" is disabled, the node stops execution and throws the error; otherwise, it logs the error and continues processing remaining items.
  • Stale function resources: The node attempts to clean up stale functions/workers internally but may log warnings if issues occur.

Links and References

Discussion