Variable
Stores a value under a name, to reuse it further on in the plan by writing that name between double braces. This is the foundation of the advanced modules.
In brief
| Outputs | one, with no label |
| Fields | Name, Type, then Value or Items (one per line) |
| Types offered | Text and Array, Text by default |
| Variables available by default | 8, with nothing to configure |
| Lifetime | the current call, and that alone |
| Name case | does not matter: {{DATETIME}} and {{datetime}} refer to the same thing |
The help text shown in the window is: "Defines a variable, reusable via {{name}} in other modules."
How it works
What a variable is
A variable is a label attached to a value. You give it a name, for example language, and a value, for example en. Anywhere else in the plan, writing {{language}} is the same as writing en.
The point is not to save typing: it's that the value can change from one call to the next. The caller's number, what they dialed on the keypad, the name found in your Odoo are all variables. You build a single plan that behaves differently depending on what it discovers along the way.
A variable lives for the duration of a call. Two simultaneous calls each have their own, without interfering with each other, and nothing is kept from one call to the next.
Where to write it
Anywhere a field accepts text: the URL and body of an API request, the Args of an Odoo request, the recipient and text of a Notification, the text of a Caller ID, the operands of a Condition (If), the expression of a Switch / Case, the message of a Debugging module, the destination of a Call. This module's own Value field also accepts it: a variable can be built from another one.
An unknown name is not flagged: it is replaced with blank, without the slightest warning. This is the most common explanation for a message that arrives half-written.
The variables available with nothing to configure
| Name | What it contains |
|---|---|
caller | the caller's number, as passed to us |
caller_name | the caller's name, when the carrier passes it |
callee | the number dialed inside the installation |
did | the number that received the call |
tenant | the short name of your installation |
domain | the SIP domain of your installation |
datetime | the date and time, in your installation's time zone |
datetime_utc | the same date and time, in universal time |
Added to these, as the plan progresses: those you set with this module, the one from a DTMF entry, the six from Odoo, contact resolution, and the extractions from an API request or an Odoo request.
A ninth variable, caller_e164, contains the possible forms the caller's number can be written in. It is used by the filter of an Odoo request and has little use elsewhere.
What to fill in
| Field | What is expected | If you leave it empty |
|---|---|---|
| Name | a short name, in unaccented letters, digits and underscores | the variable is not created, the module does nothing and the call carries on |
| Type | Text for a single value, Array for a list | Text |
| Value | the content, which can itself contain {{another_one}} | the variable exists, with an empty value |
| Items (one per line) | one value per line, in Array | the list is empty; blank lines are ignored |
Steps
- Place the Variable module and connect the previous node to its input.
- Open it and enter the Name, for example
language. Remember it exactly, you'll need it elsewhere. - Choose the Type. Text in the vast majority of cases; Array if you want a list to be tested further on with the "is in (array)" operator of a Condition (If).
- Fill in the Value, or the Items, one per line.
- Click Save.
- Connect the module's output to the rest of the plan: an output that leads nowhere hangs up the call.
- Further on in the plan, insert
{{language}}wherever you need it, preferably by copying it from the Available variables panel. - Place a Debugging module right after, with the message
language={{language}}. You'll read the actual value instead of assuming it. - Click Save, then Apply changes in the top banner.
- Call your number, then open the plan's Debug log and check the value written.
If it doesn't work
My variable shows up blank further on in the plan. Two causes, in this order. The call did not pass through the module that sets it, because it took another branch. Or the name written between braces does not match the module's, even by one letter. An unknown name is replaced with blank, with no error.
I put an accent or a hyphen in the name, and nothing comes out. Only unaccented letters, digits and the underscore are recognized. Rename the variable, then fix every place that uses it.
My list shows up on one line, separated by commas. This is the expected behavior: an Array inserted into text is rendered with commas. An array is meant to be tested, with the "is in (array)" operator of a Condition (If), rather than displayed.
The call cuts off right after the module. Its single output is not connected to anything. A module whose sole output leads nowhere ends the call.
The value is correct on screen but not on the phone. The saved plan is not yet in service. Click Apply changes in the top banner, then call again.
How the call flow is built, explained in pictures
See the Dial plans page