A Variable is a stored value that can be recalled at different points in a Conversation and throughout a Program.

Variables can be recalled in Actions and Conditions, in any field marked ‘Variable’. For example, the Set action will set a Variable to a given value. A Variable that has been set in a script can be referred to within the remainder of the script. If a Variable is recalled before it has been set, its value will return as null. If you have multiple conversations, the Variable can also be used in other Conversations that are part of that same Virtual Human Program.

If there is no explicit field for a Script variable, you can retrieve the value of the Script variable by putting curly braces around its name. For example, if you have a Variable named XY, you can put {XY} into a value field or the Agent Says field, to replace {XY} with the stored value of the variable XY.


A Variable can be set within an Action. To do so, select ‘Set’ from the Action Type drop-down menu. If this Variable has been set before, its previous value will be overwritten by this Action. If this is the first reference to a Variable with this tag, this Action will initialise the Variable with the value specified in the Value field. If the Value field is empty, the value will be populated with the response of the consumer to the current Dialog Piece. For example, if the Response Type (see Dialog Response Types) is a Freeform Text field, the Variable will be saved with the full string entered into the text field by the user. If the Response type is a multiple choice, the Variable will be saved with the full text string of the choice selected.

Evaluate & Set

An alternative to simply setting a variable is to Evaluate & Set it. This will advise the system that some parsing is required when setting the value of a variable. For instance, if you want to set a new value that is the sum of two currently set values, the Variable name would need to be defined in the Variable field, and the Value field would need to be completed with the statement “{variable1}+{variable2}”.

n.b. If the above value was used in a Set action rather than an Evaluate & Set action, it would simply concatenate the two variables. This is useful for appending strings.


The following operators can be utilised in an Evaluate & Set Action:

  • The “+” operator will add two Variables or values together. If used on string Variables, it will join them together in the order they are listed in the statement.

  • The “-” operator will subtract the value listed after the operator from the value listed before it.

  • The “*” operator will multiply the value listed before it by the value listed after.

  • The “/” operator will divide the value listed before it by the value listed after.

  • The “^” operator will raise the value listed before it to the power of the value listed after.


If you wish to perform operations on a Variable, you can list the Variable name within both the Variable field and the Value field. For instance, if you wish to increment a previously set counter, you can enter ‘Counter’ in the Variable field and ‘{Counter}+1’ in the Value field, and on execution of the Evaluate & Set Action, the Variable Counter will be increased by 1.

An example for use would be to have a Number Slider/Textbox Dialog (see Dialog Response Types) in which the Virtual Human asks the consumer what their favourite number is. The contents of their response, entered into the number textbox, is saved to the Variable ‘FavNumber’ using a Set Action (see Implementing Actions).

Once this Variable has been obtained, it can then be referred to later in the Program. A later Dialog Piece could contain an Action that Evaluate & Sets a new Variable ‘DoubleFavNumber’, equal to '{FavNumber}*2'.

Then the next Dialog could have the following content in the Agent Says field:

Remember when you told me that your favourite number is {FavNumber}? Well have you considered {DoubleFavNumber}? It’s twice as good!

If the consumer entered the number 5 in the number textbox, within the application this Dialog would be presented as the following:

Remember when you told me that your favourite number is 5? Well have you considered 10? It’s twice as good!

Back to top