Overview
The Rule Engine node processes input data items by applying user-defined conditions (rules) to each item and then sets specified result fields based on those conditions. It is useful for scenarios where you want to filter, transform, or enrich data conditionally within an n8n workflow without writing custom code.
Typical use cases include:
- Filtering records that meet certain criteria.
- Assigning new values or updating existing fields when conditions are met.
- Selectively including or excluding fields in the output based on user preferences.
For example, you might use this node to check if a sales record exceeds a threshold and then tag it with a "High Value" label, or to exclude sensitive fields from output while passing through others.
Properties
| Name | Meaning |
|---|---|
| Conditions | A set of logical conditions (filters) to evaluate against each input item. These determine whether the rule applies to that item. |
| Result to Set | The fields and their values to assign to the output item when the conditions are met. |
| Include Other Input Fields | Boolean flag indicating whether to pass all original input fields along with the assigned fields to the output. |
| Input Fields to Include | Specifies how to select which input fields to include in the output when "Include Other Input Fields" is enabled. Options: - All: Include all unchanged input fields. - Selected: Include only specified fields. - All Except: Include all except specified fields. |
| Fields to Include | Comma-separated list of field names to include in the output when "Selected" option is chosen above. |
| Fields to Exclude | Comma-separated list of field names to exclude from the output when "All Except" option is chosen above. |
Output
The node outputs two arrays of items:
- True output: Items for which the conditions evaluated to true, with fields updated according to the assignments and inclusion/exclusion settings.
- Conditions output: The original input items that matched the conditions (used internally or for further processing).
Each output item contains a json object representing the data fields after applying the rules and field selection logic.
The node does not handle binary data output.
Dependencies
- No external services or API keys are required.
- Uses internal utilities and lodash library for data manipulation.
- Requires no special environment variables or credentials.
Troubleshooting
Common issues:
- Incorrectly defined conditions may cause no items to match or unexpected matches.
- Misconfiguration of field inclusion/exclusion can lead to missing or extra fields in output.
- Loose vs strict type validation in conditions can affect matching behavior; enabling less strict validation may help if type mismatches occur.
Error messages:
- Errors during condition evaluation will be logged and may stop execution unless "Continue On Fail" is enabled.
- Type validation errors indicate mismatched data types in conditions; review condition definitions and consider enabling loose type validation.
- If the node throws operation errors referencing item indices, check the corresponding input data item for issues.
Links and References
- n8n Documentation - Filters and Expressions
- Lodash Library (used internally for data operations)