Nodes read and write values as a conversation runs: what the customer said, the matched intent, a service's answer, a value you calculated. These values are the conversation's context, and each one is held in a variable. Part of Flows.
Inserting a variable
In any node input that accepts variables, type % to open the picker, then choose a variable. When the input is used, the variable is replaced with its current value. A name you type after % can be up to 36 characters long and use letters, digits, ., [ and ].
The picker groups variables by kind, and which groups you see depends on the flow type:
| Group | What it holds | Offered in |
|---|---|---|
| Static | Values the platform fills in, such as the session ID or the customer's last input | Every flow |
| Dynamic | Variables you define for the project | Every flow |
| Custom | Any name you type after %, such as an HTTP node's output name |
Every flow |
| Project Entity | The project's entity values | Every flow |
| Binary Base64 | Binary variables you define for the project | Every flow |
| Intent Entity | Entities picked out by the intent that matched | Intent action flows only |
| AI Agent Tool Parameter | The parameters the AI agent passes to the tool | AI Agent tool flows only |
Static variables
The platform fills these in. The most useful ones:
| Variable | What fills it |
|---|---|
| SessionId | Set when the conversation starts. |
| ExternalConversationId | Set when the conversation starts. |
| Channel | Set when the conversation starts. |
| LastUserInput | The customer's latest message. When Real-Time Translation applies, it holds the translated text. |
| LastInputType | The type of the customer's latest input, set on every message. |
| LastIntent, LastIntentConfidence | The intent matched in the current turn, and its score. |
| ResponseLanguage | The language the virtual agent answers in. It is set from the customer's language when that is a project language, and a Virtual Agent node sets it to its virtual agent's language. |
| LastUserLanguage | The language detected in the customer's latest message. |
| CurrentTime | The current time, in UTC. |
| Rating | The rating the customer gave, written by an Ask node whose output is Rating. |
| WebhookUrl | Written by a Webhook Listener node. |
| SentimentScore | The running sentiment score. Filled only when sentiment is turned on. See Sentiment. |
| LocationLatitude, LocationLongitude | The location the customer shared with their latest message. |
| CustomAttributes | The current custom attribute values, written by Set Attribute nodes. |
| ChatHistory | The messages of the conversation. Filled only in the Post Session Flow. |
You can assign a static variable yourself, but the platform overwrites it the next time it sets that value.
Dynamic variables
A dynamic variable has a Key (its name) and a Value. The Value is a JavaScript expression, worked out each time a node uses the variable. Dynamic variables belong to the project version, so every flow in it sees the same list, including intent action flows and AI Agent tool flows.
To create one, type % in a node input and select + (Add Dynamic Context) in the list. In the Create dynamic context window, fill in:
- Key: no spaces.
- Value: required. It cannot contain a double quote, a backtick or a semicolon.
⚠️ Warning: The Value is worked out again every time the variable is used. If a Code or Variable node assigns a dynamic variable whose Value returns something, the next use replaces the assigned value with the Value's result. To carry a result from a Code node, set the Value to
null.
For example, to keep a customer tier that a Code node works out:
-
Create a dynamic variable with Key
CustomerTierand Valuenull. -
In a Code node, assign it:
javascript context.dynamic.CustomerTier = "Gold"; -
Later nodes, in this flow or any other flow, can use
%CustomerTierand getGold.
Custom variables
Any JavaScript global in the conversation is a custom variable. Examples are the output name you give an HTTP node, a name assigned in a Variable node, and a name a Code node assigns without declaring it. To use one, type % and then its name. The picker offers whatever you type as a Custom mention.
A custom variable lasts for the whole conversation and is visible to every flow the conversation enters. It is not kept after the conversation ends.
Setting values in a flow
Variable node
The Variable node has one required input, Operation, which holds a single JavaScript statement, for example:
paymentAttempts = 0
The statement runs in the conversation's global scope, so paymentAttempts becomes a custom variable. The node has one output.
Code node
The Code node runs JavaScript. Your code runs inside a function:
- Names declared with
var,letorconstexist only inside that Code node. - Names you assign without declaring them become custom variables, which later nodes can use.
- Dynamic variables are available as
context.dynamic.<Key>. - No helper libraries are loaded.
For example, to check that a customer number collected into the CustomerNumber dynamic variable has eight digits:
var raw = "" + context.dynamic.CustomerNumber; customerNumberIsValid = /^[0-9]{8}$/.test(raw);
raw stays inside the node, and later nodes can branch on %customerNumberIsValid.
Reading values from the incoming message
In the Create dynamic context window, Select element from activity lets you pick a value from the message the channel sends, and use it as the variable's Value.
SIP headers
On a voice channel, the SIP headers of the call are under SipInfo > Headers. In the tree you can select only the Headers object as a whole. To read one header, type the Value yourself:
| Header name | Value |
|---|---|
A plain name, such as CustomerId |
context.activity.channelData.SipInfo.Headers.CustomerId |
A name with a hyphen, such as X-Customer-Id |
context.activity.channelData.SipInfo.Headers['X-Customer-Id'] |
Give the dynamic variable a key such as SipCustomerId, then use %SipCustomerId in any node. You can also read the same path in a Code node.
Location
When the customer shares a location, for example on WhatsApp, read it from the static variables LocationLatitude and LocationLongitude.
How long values last
Each time the conversation returns to the start of the Main flow, these values are cleared:
- LastUserInput, LastInputType, LastIntent, LastIntentConfidence and CurrentVirtualAgent
- the LastAiAgent values
- intent entities
Everything else lasts for the whole conversation: dynamic, custom and project entity variables, and the other static variables.
