Overview
The Dynamic Menu node allows users to create dynamic, customizable menus within an n8n workflow. It is designed to display menu options that are not predetermined but generated dynamically based on input data or custom JavaScript/Python code execution. This node is useful in scenarios where menu options depend on external data sources, user inputs, or complex logic that cannot be hardcoded.
Typical use cases include:
- Generating a list of selectable options from JSON data fetched earlier in the workflow.
- Creating branching workflows where the next steps depend on user choices presented dynamically.
- Running custom scripts to manipulate or filter data before presenting it as menu options.
For example, you might use this node to present a list of customer names retrieved from an API, allowing the user to select one for further processing.
Properties
| Name | Meaning |
|---|---|
| Path | Defines whether this node represents the main natural path of the tree or a branch. Options: Main, Branch. |
| Node Name | A short descriptive name for the dynamic menu node. |
| Node Type | Describes the type of dynamic menu; default is "DYNAMIC_MENU", indicating a menu without predetermined options. |
| Config | Configuration for the dynamic menu values, including: - JsonPath: The JSON path to the variable containing the dynamic menu data.- DisplayField: The field in the JSON object used as the menu option label.- ItemCount: Maximum number of items per page.- CharCount: Character count limit. |
| Validation Failure Text | Text displayed if the user enters an invalid value in the menu selection. |
| Menu Introduction Text | Introductory text shown at the start of the form/menu to guide the user. |
| Status | Indicates the status of the node. Options: Active, Inactive, Test. |
| Variables | List of variables with their names, types (String, Number, JSONArray, JSONObject), and values that can be used within the node's logic. |
| Choose a Processor | Allows specifying processors to execute at different stages: - Pre Processor - Input Processor - Post Processor |
| Mode | Determines how the node executes its code: - Run Once for All Items: Executes code once regardless of input item count.- Run Once for Each Item: Executes code separately for each input item. |
| Language | Programming language for the custom code execution. Options: JavaScript, Python (Beta). |
| JavaScript | Custom JavaScript code to execute within the node. Supports special variables like $today for dates and $jmespath for querying JSON. |
| Skip Rule | Rule expression defining when to skip this node during execution. |
| Branching Rule | Rules defining branching logic, either as node branches or text branches, to control workflow paths dynamically. |
| Flags | Boolean flags controlling behavior: - Sanitize: Whether to sanitize inputs.- Last Node: Marks this as the last node in the workflow.- Close Session: Flag to close the workflow session.- Publish: Whether to publish the workflow output. |
Output
The node outputs an array of items, each containing a json property representing the processed data after executing the dynamic menu logic. If binary data is produced by the executed code, it will be included alongside the JSON under a binary property.
The structure of each output item is:
{
"json": {
// Processed data or error information
},
"binary": {
// Optional binary data if produced
},
"pairedItem": {
"item": <index_of_input_item>
}
}
If an error occurs during code execution and the node is configured to continue on failure, the output will contain an error message inside the json.error field.
Dependencies
- The node supports running custom JavaScript or Python code snippets internally using sandbox environments.
- No external API keys or services are required by default.
- Environment variable
CODE_ENABLE_STDOUTcontrols whether console output from the executed code is logged. - The node relies on internal sandbox utilities for safe code execution and JSON path querying.
Troubleshooting
Common Issues:
- Syntax errors or runtime exceptions in the custom JavaScript/Python code will cause the node to fail unless "Continue On Fail" is enabled.
- Incorrect JSON path expressions in the configuration may result in empty or incorrect menu options.
- Using unsupported features or APIs in the custom code could lead to unexpected errors.
Error Messages:
- Errors thrown during code execution are captured and returned in the output as
{ json: { error: "<message>" } }. - If the node fails to parse or access input data as expected, verify the JSON path and input structure.
- To debug, use
console.log()statements in JavaScript code; output appears in the browser console if enabled.
- Errors thrown during code execution are captured and returned in the output as
Resolution Tips:
- Validate your JSON path expressions carefully.
- Test custom code snippets independently before embedding them in the node.
- Enable logging via environment variables to trace issues.