Using variables in EngageOne Converse

Using variables in Converse

You can define variables for use by any interaction in the current bot or in linked bots. Variables are set per session and the values exist only for the duration of the user's session. Some default variables are accessible in Designer and these provide information about the conversation session and the user.

Defining variables

There are several ways of defining variables in Converse. Depending on their intended purpose, you define them when you set up:

  • An interaction, such as on the Answers tab of the Question interaction
  • An Action interaction, on the Set Variable tab where you can define variables like this:
    var myvariable = context.policySelected; 
    where policySelected is a variable set by another interaction in this bot or by a linked bot.

Regardless of how you define them, most variables are defined on the context object. Some user data is available from the user object. See User details.

Variables in messages

In messages sent to the user enclose the variable (including any system function that you are using) in single curly brackets like this:
You have {employees} employees. Do you already use e-payslips?
Do you want more information about our {system.toProperCase(product)}?

User data is accessed through the user object like this:

Hello {user.full_name}

Note: In messages you do not need access the variable through the context object.

Variables in Action interactions

For variables defined in an Action interaction, on the Set Variable tab, access the variable through the context object: context.myvariable. In this example, the variable is set to the last message sent by the user:
context.selected_item = context.lastSentText;

For variables defined in Action interactions on the Condition tab, use the format {myvariable} (same as messages).

Variables in the body of a REST call

In the body of a REST call, enclose the variable in double curly brackets (because the REST body is a JSON object). For example: {{myvariable}}

Variables in the response to a REST call

For variables returned by a REST API call, you access the variables through the variable set on the Settings tab of the Action interaction. This variable stores the API response. The variable path will depend on the structure of the response. For example, if the response to the API call is stored in a variable called accountDetails then you might access the balance in a message like this:
The balance on your account is €{accountDetails.balance}
UPDATED:  October 9, 2019