Conditions
Conditions determine when a trigger rule should be applied. They allow you to create complex logic for evaluating event data and determining whether actions should be executed.Condition Structure
A condition can be either a simple field comparison or a logical group of other conditions:Simple Conditions
Simple conditions compare a field in the event data to a value using an operator:Field Path Notation
Fields are specified using dot notation to access nested properties:Available Operators
The following operators are available for simple conditions:Operator | Description | Example |
---|---|---|
equals | Exact equality | {"field": "user.role", "operator": "equals", "value": "admin"} |
notEquals | Inequality | {"field": "user.status", "operator": "notEquals", "value": "inactive"} |
contains | String contains | {"field": "user.email", "operator": "contains", "value": "@gmail.com"} |
notContains | String does not contain | {"field": "user.email", "operator": "notContains", "value": "test"} |
startsWith | String starts with | {"field": "document.title", "operator": "startsWith", "value": "Draft:"} |
endsWith | String ends with | {"field": "file.name", "operator": "endsWith", "value": ".pdf"} |
greaterThan | Numeric greater than | {"field": "payment.amount", "operator": "greaterThan", "value": 100} |
lessThan | Numeric less than | {"field": "payment.amount", "operator": "lessThan", "value": 50} |
greaterThanOrEqual | Numeric greater than or equal | {"field": "user.age", "operator": "greaterThanOrEqual", "value": 18} |
lessThanOrEqual | Numeric less than or equal | {"field": "product.stock", "operator": "lessThanOrEqual", "value": 5} |
in | Value in array | {"field": "user.role", "operator": "in", "value": ["admin", "editor"]} |
notIn | Value not in array | {"field": "user.country", "operator": "notIn", "value": ["US", "CA"]} |
exists | Field exists | {"field": "user.phoneNumber", "operator": "exists"} |
notExists | Field does not exist | {"field": "user.deletedAt", "operator": "notExists"} |
isTrue | Boolean is true | {"field": "user.emailVerified", "operator": "isTrue"} |
isFalse | Boolean is false | {"field": "user.suspended", "operator": "isFalse"} |
matches | Regex match | {"field": "user.email", "operator": "matches", "value": "^[a-z0-9]+@[a-z]+\\.[a-z]{2,3}$"} |
Group Conditions
Group conditions combine multiple conditions using logical operators:Logical Operators
Two logical operators are available:AND
: All conditions must be trueOR
: At least one condition must be true
Nesting Conditions
Conditions can be nested to create complex logic:Dynamic Values
You can use template strings in condition values to reference other fields in the event data:Custom Operators
You can extend the rule engine with custom operators by registering them with the rule evaluator:Best Practices
- Start simple - Begin with simple conditions and add complexity as needed
- Use meaningful field paths - Choose clear, descriptive paths for your fields
- Avoid deep nesting - Too many nested conditions can be hard to understand
- Consider performance - Complex conditions may impact evaluation performance
- Test thoroughly - Validate your conditions with different inputs
Examples
User in Specific Region with Premium Plan
High-Value Transaction or VIP Customer
Email from Company Domain with Specific Subject
See Also
- Learn about Actions to perform when conditions are met
- Explore Rule Management techniques
- See how to Test Rules effectively