Health bot instance variables
During the scenario execution, the scenario author can store and retrieve variable values. There are also variables that are pre-populated by the framework. All variables are contained in our secure storage during the session of the conversation. This means that even if the connection is lost during the conversation or something happens to our servers, all the variables are restored when the conversation is resumed. User data is maintained between conversations.
There are three types of variables you can use inside the action and other expression fields:
Scenario variables are prefixed with a
scenario
. For examplemyVar
would be accessed using the syntaxscenario.myVar
. Scenario variables live throughout the lifespan of a scenario. When a scenario ends and returns to the calling scenario, the variables are removed. This means you can write reusable scenarios.Conversation variables are prefixed with a
converstion
sign. For examplemyVar
would be accessed using the syntax denoted byconversation.myVar
. Conversation variables can persist accross several scenarios throughout the lifespan of the conversation session.User variables are prefixd with an
user
. For example,myVar
would be acccessed using syntax denoted byuser.myVar
. They persist indefinetly accross conversations with the same user. User variables are deleted when the user makes an explicit request to be forgotten.
All notations (scenario
, conversation
, and user
) are just abbreviation of the actual
place this data is stored. They are expanded during runtime to the
following objects:
Variable | Real data location |
---|---|
scenario.myVar |
session.privateConversationData.<current_scenario_name>.myVar |
conversation.myVar |
session.privateConversationData.myVar |
user.myVar |
session.userData.myVar |
Examples are visible in the Debug Context. In
theory, you can write the long form of the variables (e.g.,
session.privateConversationData.myvar
) but this is not recommended,
especially for scenario variables.
Warning
The old variable notations ($, @, &) are still supported along side the new notations, but will be deprecated in the future. It's highly recommended using the new notations.
Global variables
Instance variables are scoped to a specific user or conversation. Global variables are available to all users and can be accessed from any scenario.
Global variables are managed via the special step in the visual editor or programatically using a special syntax. Learn more about global variables.