Skip to main content

Scope & Conditions

An alert has two condition groups, its scope and its conditions. They're built the same way and both must match:

  • Scope narrows which entities the alert looks at, such as one survey, a few locations or one platform. Entities outside the scope are ignored completely. For a threshold alert they aren't counted towards the percentage either.
  • Conditions say which entities in scope are worth knowing about.

You could put everything in the conditions and leave the scope empty, and an instant alert would behave the same. Keeping "where" in the scope and "what" in the conditions makes alerts easier to read, and it matters for threshold percentages.

Conditions​

A condition compares one field with a list of values:

{ "field": "rating", "operator": "lte", "values": ["2"] }
PropertyDescription
fieldThe field's key, such as rating or content.
operatorHow to compare. See Operators.
valuesThe values to compare with, always as strings. Numbers are decimals and booleans are "true" or "false".
stepFor step.* survey fields, the ID of the survey step to read. Otherwise leave it out.
textFor text fields, how to match the words. See Text matching.

Operators​

OperatorValuesMatches when the field…
eqexactly 1equals the value
neqexactly 1doesn't equal the value, or is missing
inat least 1equals one of the values
not-inat least 1equals none of the values, or is missing
gt / gteexactly 1is more than / at least the value
lt / lteexactly 1is less than / at most the value
betweenexactly 2is between the two values, inclusive, in either order
contains-anyat least 1text: mentions at least one value. List: includes at least one value.
contains-allat least 1text: mentions every value. List: includes every value.
not-containsat least 1text: mentions none of the values. List: includes none. Also matches when missing.
existsnoneis set and not empty
not-existsnoneis missing or empty

Each field type accepts only some operators. See the table in Fields. A condition can have up to 100 values of up to 200 characters each.

Text matching​

Text conditions match words, not raw characters, so they're predictable and robust:

  • Case doesn't matter: Burnt matches burnt.
  • Accents are ignored: creme brulee matches Crème Brûlée.
  • Punctuation and spacing are ignored: burnt pizza matches burnt... pizza!!.
  • Any script works, including Urdu and Arabic.
  • A trailing * matches the start of a word: burn* matches burn, burnt, burned and burning. * anywhere else is ignored.

How the words of each value are matched is set by text.match:

text.match"burnt pizza" matchesDoesn't match
phrase (default)"the burnt pizza was awful""the pizza was burnt"
all-words"the pizza was totally burnt" (anywhere, any order)"the pizza was cold"
any-word"so burnt", "cold pizza""slow service"

Two more options refine it:

  • text.proximity (phrase only, 0 to 20): the words may be up to this many words apart, in any order. With 2, "burnt pizza" also matches "the pizza was burnt" (one word between) but not "the pizza we got last week was burnt".
  • text.wholeWord (default true): set it to false to match inside words, so "pizza" also matches "pizzas" and "pizzeria". Prefer a * wildcard for word endings; it's more precise.
{
"field": "content",
"operator": "contains-any",
"values": ["burnt pizza", "burn* crust", "overcooked pizza", "charred"],
"text": { "match": "phrase", "proximity": 2 }
}
Cover how people actually write

Deterministic matching only finds what you list, so list the phrasings and misspellings customers use: "cold", "luke warm", "lukewarm", "not hot". For a theme, pair a few phrases with the analysed topics (negativeCategories on reviews, intents on social posts).

Notifications quote the matching part of the text, so you can see which phrase triggered the alert.

Groups​

Conditions sit in groups:

{
"logic": "all",
"negate": false,
"conditions": [ ... ],
"groups": [ ... ]
}
PropertyDescription
logicall: every condition and nested group must match. any: at least one must.
negateWhen true, the group matches when its contents don't. Use it to exclude things.
conditionsThe group's conditions.
groupsNested groups, up to 3 levels deep in total.

An empty group matches everything. An alert with empty conditions notifies on every entity in scope, which is occasionally what you want, for example "every review of our new branch".

Nesting expresses anything you can say with "and", "or" and "not":

rating ≤ 2
AND (mentions "burnt pizza" OR complaint topic is Food Quality)
AND NOT (platform is Foodpanda)
{
"logic": "all",
"conditions": [{ "field": "rating", "operator": "lte", "values": ["2"] }],
"groups": [
{
"logic": "any",
"conditions": [
{
"field": "content",
"operator": "contains-any",
"values": ["burnt pizza"]
},
{
"field": "negativeCategories",
"operator": "contains-any",
"values": ["rcat_food_quality"]
}
]
},
{
"logic": "all",
"negate": true,
"conditions": [
{ "field": "platform", "operator": "eq", "values": ["food-panda"] }
]
}
]
}

A group can hold up to 50 conditions in total, across its nested groups.

Contradictions​

Harlyy rejects an alert that can never match, and lists every reason, so a typo can't leave you with a silent alert. Scope and conditions are checked together, because both must match. The checks are:

ContradictionExample
A single-valued field required to equal different valuesscope survey eq A, conditions survey eq B: a submission answers one survey
Number bounds that don't overlaprating gt 4 and rating lt 2
Allowed values that are all excluded or out of rangerating in [1, 2] and rating gte 3
A field required to be both missing and setcontent not-exists and content contains-any "pizza"
Text or a list required to include what it also excludescontent contains-all "burnt pizza" and content not-contains "Burnt Pizza!"
A step on a survey outside the alert's scopescope survey in [A], condition on a step of survey B
Required steps from more than one surveystep.rating of a step on survey A and a step on survey B
An any alternative that can never match alongside the restscope platform eq google, conditions any of [platform eq food-panda, …]

Alternatives are fine where they make sense. Conditions on steps of two different surveys inside an any group are allowed, because each submission can meet one of them. Excluded (negated) groups aren't checked, since excluding something impossible is harmless.

The same checks run on alerts created with AI before you are asked to approve them.

Validation errors​

Creating or updating an alert returns 400 Bad Request listing every problem, with the path to the condition:

conditions.conditions[0].operator `gt` can't be used with `content`;
scope.conditions[1].values[0] `yelp` must be one of google, food-panda, chowdeck;
`survey` can't be `sur_A` and `sur_B` at the same time

The dashboard lists the same messages beside the Save button, and a notification confirms when it saves.