Condition (If)
Compares two values and sends the call to True or to False. This is how a plan makes a decision based on data collected earlier.
In brief
| Outputs | true (True) and false (False) |
| Fields | Left operand, Operator, Right operand |
| Operators | eleven, from equality to testing membership in an array |
| Default operator | = (equals) |
| Variables | {{variable}} accepted on both sides |
| If the chosen output is not connected to anything | the call is hung up |
How it works
The window sums it up: "Compares two values. Use {{variable}} to reference a variable."
The two operands are resolved first. A field that contains only {{name}} returns the value as is, array included. A field that mixes text and variables returns text, where each variable has been replaced by its value, and an array by its elements separated by commas. The comparison is then made according to the chosen operator, and the call leaves by true or by false.
This is how you route based on a piece of data: if the customer found in Odoo has premium status, send them to the priority queue.
If the chosen output is not connected to anything, the call is hung up on the spot. Both branches must be connected, even the one that seems unlikely: it's always the one that gets taken the day the data is missing.
The eleven operators
| Operator | What it tests |
|---|---|
= (equals) | equality, as text; two arrays are equal if they have the same content in the same order |
≠ (not equal) | the opposite of equality |
< (less than), > (greater than), ≤, ≥ | a numeric comparison: both sides are read as numbers, and anything that isn't one counts as zero |
contains (text/array) | whether the right operand is found in the left: a piece of text, or an array element |
is in (array) | whether the left operand appears in the right; a right side written in plain text is split on commas |
not in (array) | the opposite of the previous one |
matches (regex) | whether the regular expression written on the right is found in the left value, anywhere |
is empty | whether the left operand is an empty text or an array with no elements; the right operand is ignored |
What to fill in
| Field | What is expected | If you leave it empty |
|---|---|---|
| Left operand | the value to test, generally a single {{variable}} | blank is compared, which gives false for almost every operator, and true for is empty |
| Operator | the test to apply | = (equals) is offered by default |
| Right operand | the reference value: text, a {{variable}}, or a comma-separated list | the comparison is made against blank; the field is ignored anyway by is empty |
Steps
- Place before it the module that sets the data: Variable, DTMF entry, Odoo, contact resolution or API request.
- Place the Condition (If) module and connect the previous node to its input.
- Open it. In Left operand, write the variable in the form
{{name}}. The field offers the list of variables in the plan. - Choose the Operator, then fill in the Right operand.
- Close the window, then connect both outputs,
trueandfalse. - Click Apply changes.
- Call once under conditions that should give
true, then a second time under conditions that should givefalse, and check both paths.
If it doesn't work
All calls leave by false. The variable being tested does not exist at this point in the plan and is blank. Check its spelling and make sure the module that sets it is indeed placed before this one in the path.
A number comparison gives an unexpected result. < (less than), > (greater than), ≤ and ≥ read both sides as numbers. Text that isn't a number counts as zero, so two texts can end up equal without you intending it.
"Is in (array)" finds nothing. A right operand written in plain text is split on commas, without trimming spaces. 200, 201 therefore produces "200" and "201" preceded by a space, which matches nothing. Write 200,201, with no space.
"Matches (regex)" accepts too many values. The expression is searched anywhere in the left value, not from the first to the last character. Wrap it in ^ and $ to require the entire value.
The call is hung up on one of the two branches. That output is not connected to anything. Connect both true and false, including the branch you consider unlikely.
How the call flow is built, explained in pictures
See the Dial plans page