Decision icon

Decision

Decision Node

Overview

The Decision node evaluates a set of user-defined rules against incoming data and applies a selected "hit policy" to determine the output. This node is useful for implementing decision tables, conditional logic, or simple rule engines within n8n workflows. Common scenarios include filtering items based on conditions, aggregating values, or selecting specific results from a list of rules.

Practical examples:

  • Counting how many input items meet certain criteria.
  • Selecting the first item that matches a condition.
  • Finding the maximum or minimum value among matched items.
  • Summing up values from all items that satisfy a condition.

Properties

Name Type Meaning
Rule String The name of the rule set being evaluated. Used for identification purposes.
Hit Policy Options Determines how the results are aggregated:
- Count: Number of matching items
- First: First matching item's result
- Max: Maximum result value
- Min: Minimum result value
- Sum: Sum of result values
Rules Fixed Collection (multiple) A list of rule items, each containing:
- Condition (Boolean): Whether the rule applies.
- Result (String): Value associated with the rule if it applies.
- Description (String): Optional description for the rule.

Output

The node outputs an array of objects, each with the following structure:

{
  "operation": "<selected hit policy>",
  "value": <result according to hit policy>,
  "results": [ /* array of rule items as defined in input */ ],
  "item": { /* original input item's json */ }
}
  • operation: The hit policy used (e.g., "count", "first", "max", "min", "sum").
  • value: The computed result based on the hit policy and rules.
  • results: The array of rule items after evaluation.
  • item: The original input item's JSON data.

This node does not output binary data.

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 (e.g., missing conditions or results), the output may be empty or unexpected.
  • Type mismatches: For "max", "min", or "sum" policies, ensure that the "Result" field contains numeric values; otherwise, calculations may fail or produce incorrect results.
  • Empty input: If no input data is provided, the node will return an empty array.

Error messages:

  • Errors related to missing or invalid parameters will typically reference the property name (e.g., "rules.item") and can be resolved by checking the node's configuration.
  • If the "Result" field is not a number when using "max", "min", or "sum", the output may be NaN or undefined.

Links and References

Discussion