Definition
A variable in athena is one way to access data, that can be stored in different context:
- Scenario
- Session
- User
Variables are accessible in templates using the %
symbol and the name of the variable:
%myVariable
Note: User variables are only accessible through addins, and therefore cannot be accessed directly through %
notation.
There are different ways to set variables:
- Addins
- Template statements
- Predefined variables
Addins
You can access and set variables through addins:
Templates
You can access variables using the %
notation. As a reminder, only scenario and session variables are accessible using this notation. To access user variables, you need to use contextUser addin.
To assign a variable, you need first to choose the scope (session or scenario). This will impact the notation:
- Scenario: use
%myVar = "value"
- Session: use
$myVar = "value"
When using the variable inside a template, Athena will first try to match a contextScenario variable, and will use the contextSession as a fallback:
? TEST
-: %myVar = "scenario"
-: $myVar = "session"
- %myVar
In the exemple above, the result will be: scenario
? TEST
-: $myVar = "session"
- %myVar
In the exemple above, the result will be session because myVar is not found in scenario context
Predifed variables
lastUserMessage
lastUserMessage is a predefined variable in scenario context, that contains the following structure:
{
"messageId": "id of the message",
"text": "user text",
"type": "type of the message",
"customMessage": {
"key": "key of the custom",
"value": "deserialized value if json, null otherwise"
}
}
type of message can have one of those three values:
- Text
- CustomMessage
- Event