Understanding the Syntax for SMOC Expressions in Decision Elements
When the SMOC bot engine makes a decision about what edge to follow next, it uses SMOC Expressions to assign a score to each possible edge. This article explains the syntax in detail.
It then follows an edge as follows:
- If no edges have a positive score, no edge is followed.
- IMPORTANT: Always add a default edge with a score of 0.5 to ensure the bot does not get stuck.
- If one edge has a higher score than all other edges, it will be followed.
- If multiple edges have the highest score, a random one amongst them is followed.
Smoc Expressions are infix arithmetic expressions.
Valid operators are +, -, * and /. You can also use ( and ) to group sub-expressions.
Each operand is either a number or a variable. Most variables expect a case insensitive argument following the = sign.
For example:
2 * ${answer=34}
In this example, the first operand is 2 (a number), and the second operand is ${answer=34} (a variable).
A variable evaluates to either 0 or 1. The ${answer=34} variable will evaluate to 1 only if the visitor has given a survey question answer with the id 34.
There are many SMOC Expression variables to choose from, and most of them represent facts we know about the visitor before they have started interacting with the bot (such as geolocation, device type, utm_ variables etc).