How to write automation rules using BLANG

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"

Integer

An Integer represents a numerical value with no fractional component.

Example: 10012

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]*/

The regexp also supports 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 based on API input

The following variables correspond to the information provided as API input.

Variable Description Type Example
$title Title of an item String "For sale"
$body Text body of an item String "It is really nice"
$text ($title + $body) Concatenation of the title and body of an item String "For sale It is really nice"
$email 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 Integer 1400
$currency ISO 4217 currency code String "SEK"
$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) 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"

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 Country code (ISO 3166-1) 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 variable allows 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 exact text duplicates found for a given item in Implio Integer 3

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:
  • gibberish / random keystrokes
  • repeated character sequences (excessive copy/paste)
  • excessive use of punctuation
String
  • "yes" if the content is nonsensical, e.g. "??????????!!!"
  • "maybe" if there is a possible but uncertain match
  • "no" if there is no match

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
  • "yes" if the text contains a URL, e.g. "https://www.besedo.com"
  • "maybe" if there is a possible but uncertain match
  • "no" if there is no match
$text.hasEmail Indicates whether the text contains an email address. String
  • "yes" if the text contains an email address, e.g. "hiatbesedo.com"
  • "maybe" if there is a possible but uncertain match
  • "no" if there is no match
$text.hasPhoneNumber Indicates whether the text contains a phone number. String
  • "yes" if the text contains a phone number, e.g. "08-522 371 00"
  • "maybe" if there is a possible but uncertain match
  • "no" if there is no match
$text.hasSocialMediaId Indicates whether the text contains a social media identifier. String
  • "yes" if the text contains a social media identifier, e.g. "You can find me on Twitter just search for Patrik666"
  • "maybe" if there is a possible but uncertain match
  • "no" if there is no match
$text.hasFullName Indicates whether the text has any mention of a full name. String
  • "yes" if the text contains a full name, e.g. "Sven Hoek"
  • "maybe" if there is a possible but uncertain match
  • "no" if there is no match or if the language isn't supported
$text.hasContactInfo Indicates whether the text contains some other form of contact information. String
  • "yes" if the text contains some other form of contact information, e.g. "Message me on Kik"
  • "maybe" if there is a possible but uncertain match
  • "no" if there is no match or if the language isn't supported
$text.hasContactRequest Indicates whether the author asks other users for their contact information. String
  • "yes" if the text contains a request for other users' contact information, e.g. "Msg me your number "
  • "maybe" if there is a possible but uncertain match
  • "no" if there is no match or if the language isn't supported

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
  • "yes" if the author mentions he/she is younger than 14 or seeks someone under that age, e.g. "I will soon turn 14"
  • "maybe" if there is a possible but uncertain match
  • "no" if there is no match or if the language isn't supported
$text.underage15 Indicates whether the author mentions he/she is younger than 15, or seeks someone under that age. String
  • "yes" if the author mentions he/she is younger than 15 or seeks someone under that age, e.g. "I will soon turn 14"
  • "maybe" if there is a possible but uncertain match
  • "no" if there is no match or if the language isn't supported
$text.underage16 Indicates whether the author mentions he/she is younger than 16, or seeks someone under that age. String
  • "yes" if the author mentions he/she is younger than 16 or seeks someone under that age, e.g. "I will soon turn 14"
  • "maybe" if there is a possible but uncertain match
  • "no" if there is no match or if the language isn't supported
$text.underage17 Indicates whether the author mentions he/she is younger than 17, or seeks someone under that age. String
  • "yes" if the author mentions he/she is younger than 17 or seeks someone under that age, e.g. "I will soon turn 14"
  • "maybe" if there is a possible but uncertain match
  • "no" if there is no match or if the language isn't supported
$text.underage18 Indicates whether the author mentions he/she is younger than 18, or seeks someone under that age. String
  • "yes" if the author mentions he/she is younger than 18 or seeks someone under that age, e.g. "I will soon turn 14"
  • "maybe" if there is a possible but uncertain match
  • "no" if there is no match or if the language isn't supported
$text.underage19 Indicates whether the author mentions he/she is younger than 19, or seeks someone under that age. String
  • "yes" if the author mentions he/she is younger than 19 or seeks someone under that age, e.g. "I will soon turn 14"
  • "maybe" if there is a possible but uncertain match
  • "no" if there is no match or if the language isn't supported
$text.underage20 Indicates whether the author mentions he/she is younger than 20, or seeks someone under that age. String
  • "yes" if the author mentions he/she is younger than 20 or seeks someone under that age, e.g. "I will soon turn 14"
  • "maybe" if there is a possible but uncertain match
  • "no" if there is no match or if the language isn't supported
$text.underage21 Indicates whether the author mentions he/she is younger than 21, or seeks someone under that age. String
  • "yes" if the author mentions he/she is younger than 21 or seeks someone under that age, e.g. "I will soon turn 14"
  • "maybe" if there is a possible but uncertain match
  • "no" if there is no match or if the language isn't supported

Gender detection

Variable Description Type Possible values
$text.gender Gender of the author, as stated by the author String
  • "male" (e.g. "I am a 31 y/o male) or "female"
  • "unknown" if there is no mention or if the language isn't supported
$text.genderSeek Gender sought by the author, as stated by the author String
  • "male" (e.g. "I am looking for a man") or "female"
  • "unknown" if there is no mention or if the language isn't supported

Relationship status

Variable Description Type Possible values
$text.inARelationship Indicates whether the author mentions that he/she is in a relationship. String
  • "yes" if the author mentions he/she is in a relationship, e.g. "I have a boyfriend"
  • "maybe" if there is a possible but uncertain match
  • "no" if there is no mention or if the language isn't supported
$text.seekingCasualRelationship Indicates whether the author mentions he/she is seeking a casual relationship. String
  • "yes" if the author mentions he/she is seeking a casual relationship, e.g. "I am looking for NSA fun"
  • "maybe" if there is a possible but uncertain match
  • "no" if there is no mention or if the language isn't supported

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
  • "yes" if the author refers to his/her subscription or member status on the service, e.g. "I am not a paid member anymore"
  • "maybe" if there is a possible but uncertain match
  • "no" if there is no mention or if the language isn't supported

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 Example
< Less than Integer $price < 1000
<= Less than or equals Integer $price <= 1000
> Greater than Integer $price > 1000
>= Greater than or equals Integer $price >= 1000
BETWEEN x - y Range of integers Integer $price BETWEEN 0 - 1000
NOT BETWEEN Range of integers Integer $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, Integer, 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, Integer, 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)

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

  • $text.languageDetected NOT EQUALS $text.languageExpected
  • $title EQUALS $body

 

Was this article helpful?

Can’t find what you’re looking for?

We are here to help! Click that big button or chat bubble to get in touch with our support team ➡