Overview
The "Decision" node evaluates a set of user-defined rules against input data and applies a selected "hit policy" to determine the output. This node is useful for implementing decision tables, conditional logic, or business rules within an n8n workflow. For example, you can use it to filter items based on conditions, calculate aggregates (like sum or count), or select specific results (like minimum or maximum) from a list of rule evaluations.
Practical scenarios:
- Routing leads based on score thresholds.
- Calculating totals or counts from filtered data.
- Selecting the first matching item in a set of rules.
Properties
Name | Type | Meaning |
---|---|---|
Rule | String | The name of the rule set being evaluated. Useful for documentation or identification. |
Hit Policy | Options | Determines how the results of the rules are aggregated: - Count: Number of rules where the condition is true. - First: Result of the first rule where the condition is true. - Max: Maximum result value among rules where the condition is true. - Min: Minimum result value among rules where the condition is true. - Sum: Sum of result values among rules where the condition is true. |
Rules | FixedCollection (multiple, sortable) | A collection of rule items, each with: - Condition (Boolean): Whether this rule applies. - Result (String): Value associated with this rule if its condition is met. - Description (String): Optional description for the rule. |
Output
The node outputs one item per input, with the following JSON structure:
{
"operation": "<selected hit policy>",
"value": <result of applying the hit policy>,
"results": [
{
"condition": <boolean>,
"result": <string>,
"description": <string>
},
...
],
"item": <original input item's json>
}
- operation: The hit policy used (e.g., "count", "first", "max", "min", "sum").
- value: The computed result according to the selected hit policy.
- results: The array of rule items as defined in the input.
- item: The original input item's JSON data.
Note: All output is in JSON; binary data is not produced by this node.
Dependencies
- No external services or API keys required.
- No special n8n configuration or environment variables needed.
Troubleshooting
Common issues:
- Incorrect rule configuration: If rules are not properly set up (e.g., missing conditions or results), the output may be empty or not as expected.
- Type mismatches: The "Result" field is treated as a string, but for "max", "min", and "sum" policies, numeric values are expected. Non-numeric strings may cause unexpected behavior or NaN results.
- Empty rules: If no rules are provided or none match the condition, the output value may be undefined or zero, depending on the hit policy.
Error messages:
- The node does not throw explicit custom errors, but standard n8n parameter validation errors may occur if required fields are missing.