Rule expressions are the data types, parameters and operators that make up rules.
Together, they represent what a rule looks for when processing a piece of content.
Data types
String
A String represents a piece of text in between double quote characters.
Example: "This is just a piece of text"
Number
A Number represents a numerical value, with or without a fractional part (i.e. integer or float).
Examples: 42, 3.14
Integer
An Integer represents a whole number, without a fractional part.
Examples: 42
Boolean
Boolean is a data type that can have either of two values: true or false.
Example: true
Regular expression
Regular expressions can be used where a String value is expected. They can also be a part of an array.
Example: /[a-z]*/
Regular expressions support flags, so you can write: /[a-z]*/i .
The flag g for global search is implied by default.
BLANG variables
The following section describes all the variables that can currently be accessed using BLANG.
Variables representing API input
The following variables correspond to fields specific in the API request payload.
Variable | Description | Type | Example |
---|---|---|---|
$title | Title of an item | String | "For sale" |
$body | Body of an item | String | "It is really nice" |
$text | Concatenation of the title and body of an item, with a line break separating both. | String |
"For sale It is really nice" |
First email address of the user posting the item | String | "test@besedo.com" | |
$phoneNumber | First phone number of the user posting the item | String | "08-123 123 33" |
$categoryName | Category name of the item | String | "Cars" |
$categoryId | Category ID of the item | String | "cars", "vehicles-cars" or "22" |
$price | Price of the item | Number | 1400 |
$currency | ISO 4217 currency code | String | "EUR" |
$type | Type of the item | String | "buy", "sell" or "rent" |
$userId | Id of the user posting the item | String | "fjuki97" |
$userName | Username of the user posting the item | String | "Fjodor Kiriakos" |
$city | City name | String | "Stockholm" |
$postalCode | Postal (zip) code | String | "12346" |
$region | Region | String | "Stockholm" |
$countryCode | Two-letter country code (ISO 3166-1 alpha-2) | String | "SE" |
$ip | IP address of the user posting the ad | String | "127.0.0.1" |
$status | Status of the item in your system | String | "published" |
$images.count | Number of images that the item contains | Integer | 3 |
$images.failCount | Number of item images that failed to be retrieved from the specified URL and therefore couldn't be processed | Integer | 0 |
$videos.count | Number of videos that the item contains | Integer | 1 |
Variables representing user's moderation history
The following variables contain statistics about the moderation history of the user (referred to by the user.id specified in the API request payload) to date.
Variable | Description | Type | Example |
---|---|---|---|
$user.itemCount | Number of items seen in Implio for that user to date. | Integer | 10 |
$user.itemCount.1minute |
Number of items seen in Implio for that user over the past minute (past 60 seconds). |
Integer | 0 |
$user.itemCount.1hour |
Number of items seen in Implio for that user over the past hour (past 60 minutes). |
Integer |
1 |
$user.itemCount.1day |
Number of items seen in Implio for that user over the past day (past 24 hours). |
Integer |
4 |
$user.itemCount.1week |
Number of items seen in Implio for that user over the past day (past 7 days). |
Integer |
10 |
$user.itemCount.1month |
Number of items seen in Implio for that user over the past month (past 30 days). |
Integer |
34 |
$user.itemCount.1year |
Number of items seen in Implio for that user over the past month (past 12 months). |
Integer |
60 |
$user.decisionCount | Number of items with an Approved or Refused decision for that user to date. | Integer | 10 |
$user.noDecisionCount | Number of items without a decision (No decision) for that user to date. | Integer | 0 |
$user.approvedCount |
Number of Approved (resp. Refused) decisions for that user to date. | Integer |
9 1 |
$user.approvedPercentage $user.refusedPercentage |
Percentage of Approved (resp. Refused) items over decision count for that user to date. | Integer |
90 10 |
$user.approvedStreak $user.refusedStreak |
Number of items last Approved (resp. Refused) in a row for that user to date. If the last decision is not Approved (resp. Refused), then $user.approvedStreak (resp. $user.refusedStreak) will necessarily have a null (0) value. |
Integer |
5 0 |
Variables augmented from input
Geolocation
The following variables allow you to leverage the built-in automatic geolocation of end users in your automation rules.
See How to locate end users using geolocation to learn more about geolocation and how to make use of it.
Variable | Description | Type | Example |
---|---|---|---|
$geoCity | Name of the city (in English) associated with the user's geolocation at the time of posting | String | "Stockholm" |
$geoContinent | Name of the continent (in English) associated with the user's geolocation at the time of posting | String | "Europe" |
$geoCountry | Name of the country (in English) associated with the user's geolocation at the time of posting | String | "Sweden" |
$geoCountryCode | Three-letter country code (ISO 3166-1 alpha-3) associated with the user's geolocation at the time of posting | String | "SWE" |
$geoPostalCode | Postal code associated with the user's geolocation at the time of posting | String | "117 43" |
Deduplication
The following variables allow you to leverage the built-in duplicate detection capabilities of Implio in your automation rules.
See How to detect and moderate duplicate items to learn more about duplicate detection and how to make use of it.
Variable | Description | Type | Example |
---|---|---|---|
$numberOfDuplicates | Number of text (title + body) duplicates across the entire Implio team | Integer | 3 |
$images[N].duplicateCount | Number of image duplicates for image N across the entire Implio team | Integer | 7 |
$images.duplicateCount | Combined number of image duplicates for all images in the item, across the entire Implio team. For instance, should an item have 2 images with $images[0].duplicateCount having a value of 7 and $images[1].duplicateCount having a value of 5, $images.duplicateCount will have a value of 12. |
Integer | 12 |
Text vision
Implio comes with a number of built-in Text Vision filters that allow you to make sense of user-generated text (combination of an item's title and body), and make it actionable through automation rules.
Language detection
The following variables allow you to leverage the built-in automatic language detection in your automation rules.
See How to check the language in which users write to learn more about automation language detection and how to make use of it.
Variable | Description | Type | Possible values |
---|---|---|---|
$text.languageDetected |
Language in which the text is written (automatically detected) | String |
ISO 639-1 code of the language in which text was detected to be written (e.g. "fr"), or "unknown" if no language could be detected. |
$text.languageExpected |
Value of the content.languageExpected API input field | String | ISO-639-1 code of the language in which the text is expected to be written, or <undefined> if no value was specified in the API input field. |
Nonsense
Variable | Description | Type | Possible values |
---|---|---|---|
$text.isNonsense |
Indicates whether the text is nonsensical:
|
String |
|
Profanity
Variable | Description | Type | Possible values |
---|---|---|---|
$text.blasphemyCount |
Number of blasphemy terms detected in the text | Integer | Number of terms detected, 0 if no term matched or if the language isn't supported |
$text.badWordCount | Number of bad words detected in the text | Integer | Number of terms detected, 0 if no term matched or if the language isn't supported |
$text.sexualTermCount | Number of sexual terms detected in the text | Integer | Number of terms detected, 0 if no term matched or if the language isn't supported |
Violence
Variable | Description | Type | Possible values |
---|---|---|---|
$text.violenceTermCount |
Number of terms related to violence detected in the text | Integer | Number of terms detected, 0 if no term matched or if the language isn't supported |
$text.extremismTermCount |
Number of terms related to violence detected in the text | Integer | Number of terms detected, 0 if no term matched or if the language isn't supported |
$text.racismTermCount |
Number of terms related to racism detected in the text | Integer | Number of terms detected, 0 if no term matched or if the language isn't supported |
Weapons
Variable | Description | Type | Possible values |
---|---|---|---|
$text.weaponTermCount |
Number of terms related to weapons detected in the text | Integer | Number of terms detected, 0 if no term matched or if the language isn't supported |
Contact details
Variable | Description | Type | Possible values |
---|---|---|---|
$text.hasUrl | Indicates whether the text contains a URL. | String |
|
$text.hasEmail | Indicates whether the text contains an email address. | String |
|
$text.hasPhoneNumber | Indicates whether the text contains a phone number. | String |
|
$text.hasSocialMediaId | Indicates whether the text contains a social media identifier. | String |
|
$text.hasFullName | Indicates whether the text has any mention of a full name. | String |
|
$text.hasContactInfo | Indicates whether the text contains some other form of contact information. | String | |
$text.hasContactRequest | Indicates whether the author asks other users for their contact information. | String |
Underage
Variable |
Description |
Type |
Possible values |
---|---|---|---|
$text.underage14 | Indicates whether the author mentions he/she is younger than 14, or seeks someone under that age. | String |
|
$text.underage15 | Indicates whether the author mentions he/she is younger than 15, or seeks someone under that age. | String |
|
$text.underage16 | Indicates whether the author mentions he/she is younger than 16, or seeks someone under that age. | String |
|
$text.underage17 | Indicates whether the author mentions he/she is younger than 17, or seeks someone under that age. | String |
|
$text.underage18 | Indicates whether the author mentions he/she is younger than 18, or seeks someone under that age. | String |
|
$text.underage19 | Indicates whether the author mentions he/she is younger than 19, or seeks someone under that age. | String |
|
$text.underage20 | Indicates whether the author mentions he/she is younger than 20, or seeks someone under that age. | String |
|
$text.underage21 | Indicates whether the author mentions he/she is younger than 21, or seeks someone under that age. | String |
|
Gender detection
Variable | Description | Type | Possible values |
---|---|---|---|
$text.gender | Gender of the author, as stated by the author | String |
|
$text.genderSeek | Gender sought by the author, as stated by the author | String |
|
Relationship status
Variable | Description | Type | Possible values |
---|---|---|---|
$text.inARelationship | Indicates whether the author mentions that he/she is in a relationship. | String |
|
$text.seekingCasualRelationship | Indicates whether the author mentions he/she is seeking a casual relationship. | String |
|
Romance scam
Variable | Description | Type | Possible values |
---|---|---|---|
$text.isRomanceScam | Indicates whether text is a potential romance scam. | String |
|
Subscription info
Variable | Description | Type | Possible values |
---|---|---|---|
$text.hasSubscriptionInfo | Indicates whether the author refers to his/her subscription or member status on the service. | String |
|
Customer-specific variables
In addition to the built-in variables listed above, it is also possible to send in custom parameters. A custom parameter must be prefixed with $$ to avoid naming collisions with present and future built-in variables.
Examples:
- $$fueltype
- $$facebookId
- $$longitude
Comparison operators
Operator | Description | Type(s) | Example |
---|---|---|---|
< | Less than | Number | $price < 1000 |
<= | Less than or equals | Number | $price <= 1000 |
> | Greater than | Number | $price > 1000 |
>= | Greater than or equals | Number | $price >= 1000 |
BETWEEN x - y | Value in the specified range | Number | $price BETWEEN 0 - 1000 |
NOT BETWEEN | Value not in the specified range | Number | $price NOT BETWEEN 0 - 1000 |
EQUALS | The parameter is an exact match of the value. If the value is a list of values, then it checks if any of the values match | String, Number, Boolean | $categoryName EQUALS "Cars" $type EQUALS ("sell","buy") |
NOT EQUALS | The parameter is not an exact match of the value. If the value is a list of values, then it checks so none of the values match | String, Number, Boolean | $categoryName NOT EQUALS "Cars" $type NOT EQUALS ("sell","buy") |
CONTAINS | Checks so the parameter contains the value. I.e. if a word is part of the text. If the value is a list it will check so any of the keywords match. | String, Regular Expression |
$title CONTAINS "Snus" $title CONTAINS("tobacco","cigarettes","vape") $userId CONTAINS @whitelistedUsers |
NOT CONTAINS | Checks so the parameter does not contain the value. I.e. if a word is part of the text. If the value is a list it will check so none of the keywords match. | String, Regular Expression |
$title NOT CONTAINS "Certified" $title NOT CONTAINS ("CE","Certificate","Conform") $ip NOT CONTAINS @blacklistedIPs |
Word boundaries
Word boundaries are respected for Strings, but not for Regular Expressions.
Examples
Considering $text equals "Hello friend how are you?":
Expression | Result |
---|---|
$text CONTAINS "friend" | Match |
$text CONTAINS "fri" | No match |
$text CONTAINS /fri/ | Match |
Case sensitivity
String matches ignore case but Regular Expressions are case sensitive, unless the /i flag is specified.
Examples
Considering $text equals "Hello friend how are you?":
Expression | Result |
---|---|
$text CONTAINS "hello" | Match |
$text CONTAINS "HELLO" | Match |
$text CONTAINS /hello/ | No match |
$text CONTAINS /hello/i | Match |
Logical operators
Expressions can be combined using AND and OR expressions. Also. the evaluation order can be prioritized using parentheses ( ):
By default, AND has a higher priority than OR. This mean that a OR b AND c will be evaluated as a OR (b AND c)
Expressions can also be negated using NOT.
Examples
- $price > 1000 OR $categoryName EQUALS "Cars"
- $price > 1000 OR ($categoryName EQUALS "Cars" AND $professional EQUALS true)
- $title NOT EQUALS "hello" AND NOT ($price BETWEEN 100-10001 AND $body CONTAINS @bad_words)
Other operators
Checking whether a variable is defined
You can check whether a variable is defined and has a value different from null, using the EXISTS operator.
It works both with built-in and customer-specific variables.
Examples
- EXISTS($price)
- NOT EXISTS($$fraudScore)
Testing the length of a string
You can test the length of a variable using the LENGTH operator.
It works both with built-in and customer-specific variables.
Examples
- LENGTH($body) < 160
- LENGTH($$myCustomField) > 0
Arrays and lists
Instead of comparing a parameter against one value and creating long expressions you can use arrays to compare a parameter against a couple of Strings, integers or regular expressions. If you have more than just a few, you can include them in a list and include the list in your filter. The table below illustrates the difference between each method of writing an expression, their result is equivalent.
Comparison with one value | Equivalent using arrays | Equivalent using lists |
---|---|---|
$title CONTAINS "citroen" OR $title CONTAINS "saab" OR $title CONTAINS "dacia" | $title CONTAINS ("citroen", "saab", "dacia") | $title CONTAINS @car_models |
$userId EQUALS 382971232 OR $userId EQUALS 223133740 | $userId EQUALS (382971232, 223133740) | $userId EQUALS @bad_users |
$text CONTAINS /dog(s)?/ OR $text CONTAINS "cat" OR $text CONTAINS /[a-z]*-animal/ | $text CONTAINS (/dog(s)?/, "cat", /[a-z]*-animal/) | $text CONTAINS @animal_list |
Comparing variables
You can easily compare two variables together by putting one on each side of the EQUALS operator.
Examples
- $title EQUALS $body
- $text.languageDetected NOT EQUALS $text.languageExpected
Comments
Expressions allow comments to be inserted using the # delimiter. Both line and inline comments are supported:
# This is a comment
$text CONTAINS /regex/ # This is another comment