Decision icon

Decision

Decision Node

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 rule-based processing within n8n workflows. Common scenarios include filtering items based on conditions, aggregating values, or selecting specific results according to business rules.

Practical examples:

  • Counting how many items meet certain criteria.
  • Selecting the first item that matches a condition.
  • Finding the maximum or minimum value among items that satisfy a rule.
  • Summing up numeric results from items that pass a condition.

Properties

Name Type Meaning
Rule String The name of the rule set being applied. Useful for documentation or identification.
Hit Policy Options Determines how matching rules are processed:
- Count: Number of items meeting the condition.
- First: First item that meets the condition.
- Max: Maximum result among matching items.
- Min: Minimum result among matching items.
- Sum: Sum of results for all matching items.
Rules Fixed Collection (multiple) A list of rule items, each with:
- Condition (Boolean): Whether the rule applies.
- Result (String): Value associated with this rule.
- Description (String): Optional description for the rule.

Output

The node outputs an array of objects, each containing:

{
  "operation": "<Selected Hit Policy>",
  "value": <Result of applying hit policy>,
  "results": [ /* Array of rule items as defined in input */ ],
  "item": { /* Original input item's json data */ }
}
  • 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 evaluated for this input.
  • item: The original input item's JSON data.

Note: The 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 yield incorrect results.
  • Empty input: If no input data is provided, the node will return an empty array.

Error messages:

  • The node does not throw custom error messages but may fail if required properties are missing or misconfigured. Double-check property settings if you encounter unexpected behavior.

Links and References

Discussion