Variables
Variables reference the data Mangrove evaluates the expression against. They are wrapped in double curly braces.- Event Data rules — variables are datapoint slugs from your project’s data point types. Selecting a specific event type scopes the rule to that event type and narrows autocomplete to its datapoints — we recommend doing this so the rule’s intent is clear. If no event type is selected, the rule evaluates against any event in the project whose datapoints satisfy the expression.
- Batch Calculations rules — variables are nodes in the selected model. When multiple nodes share the same slug, qualify the reference with the datapoint type using the form
node."<NodeName>".<slug>(for example,node."Mass".biochar_mass).
{{ in the rule editor to open autocomplete. Each suggestion shows the variable name and its description, value type, or unit when available.
Comparison operators
| Operator | Meaning |
|---|---|
= | Equal to |
!= | Not equal to |
< | Less than |
<= | Less than or equal to |
> | Greater than |
>= | Greater than or equal to |
Logical operators
Combine conditions withAND, OR, and NOT. Use parentheses to group.
Range and set operators
| Operator | Example | Triggers when… |
|---|---|---|
BETWEEN ... AND ... | {{ph}} between 6.0 and 8.0 | The value is within the range (inclusive). |
NOT BETWEEN ... AND ... | {{ph}} not between 6.0 and 8.0 | The value is outside the range. |
IN (...) | {{country}} in ('US', 'CA', 'MX') | The value matches any item in the list. |
NOT IN (...) | {{country}} not in ('US', 'CA') | The value matches none of the items in the list. |
Text operators
| Operator | Example | Triggers when… |
|---|---|---|
CONTAINS | {{notes}} contains 'override' | The text contains the substring. |
STARTS WITH | {{tracking_id}} starts with 'TMP-' | The text starts with the prefix. |
ENDS WITH | {{filename}} ends with '.csv' | The text ends with the suffix. |
MATCHES | {{lot_code}} matches '[A-Z]{2}-[0-9]+' | The text matches the regular expression. |
Presence operators
Use these to check whether a value was recorded at all.| Operator | Triggers when… |
|---|---|
IS MISSING | The variable has no value. |
IS PRESENT | The variable has any value. |
Aggregates
Aggregate functions roll a set of values into a single number. They are most useful in Batch Calculations rules, where a model node may hold many values across a batch.| Function | Returns |
|---|---|
COUNT | Number of values |
SUM | Sum of values |
AVG | Average of values |
MIN | Smallest value |
MAX | Largest value |
Booleans and numbers
- Booleans are written
trueandfalse(case-insensitive). - Numbers are written without quotes — both integers and decimals work:
0,42,3.14,0.005.
Common patterns
These examples assume your project has datapoints with the slugs shown — substitute slugs that exist in your project.Tips for writing good rules
- Phrase the rule as the failure case. A rule with the expression
{{ph}} not between 6.0 and 8.0triggers when pH is out of range — that’s the alert you want. - Start specific. Scope to an event type when possible. Broad rules across all event types are harder to interpret when they fire.
- Validate before saving. The validate step previews matches against recent data — use it to catch over-eager rules before they generate noise.
- Prefer presence checks over equality with empty string. Use
IS MISSINGrather than= ''to detect missing values. - Use comments in the rule name. Since expressions are terse, lean on the rule name and description to explain why the rule exists.