Overview
The "Decision Matrix" 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 scenarios where you need to automate decision-making based on multiple conditions, such as scoring leads, filtering items, or aggregating results according to specific business logic.
Practical examples:
- Selecting the first item that matches certain criteria.
- Counting how many items meet a condition.
- Finding the maximum or minimum value among matched items.
- Summing up values from items that satisfy a rule.
Properties
| Name | Type | Meaning |
|---|---|---|
| Rule | String | The name of the rule set being applied. Useful for documentation or reference. |
| Hit Policy | Options | Determines how matching rules are processed: - Count: Number of matches - First: First match - Max: Maximum result - Min: Minimum result - Sum: Sum of results |
| Rules | FixedCollection (multiple) | A list of rule items, each with: - Condition (Boolean): Whether this 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 evaluated */ ],
"item": { /* original input item's json */ }
}
- operation: The hit policy used (e.g., "first", "count", "max", etc.).
- value: The computed result according to the hit policy.
- results: The list of rule items after evaluation.
- 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 no rules have
conditionset to true, the output may be empty or zero depending on the hit policy. - Type mismatches: For "Max", "Min", or "Sum" policies, ensure that the "Result" field contains numeric values; otherwise, calculations may fail or produce unexpected results.
- Empty input: If there are no input items, the node will return an empty array.
Error messages:
- Errors related to missing or malformed parameters (e.g., if "rules.item" is not provided) may occur. Ensure all required fields are filled in the node configuration.