Apr 18, 2023
2 minutes read

Variables

Getting Started toggle

Within the Scripted Chatbot we know the concept of variables. This is expressed in a few ways:

  1. System variables; these are filled by the bot runtime and usable within the scripts.
  2. System functions: functions defined within the bot platform that can be called to produce variable output.
  3. Variables from input: user input put into a variable.
  4. Variables from regular expressions: use capture groups to capture parts of input into a variable.

Below we will discuss these one by one.

System variables

When a session starts the following system variables will be automatically created:

  • $startSequence
    • The text that was sent to start the current session, triggering the entry step.
  • $conversationClientId
    • The id which identifies the client, i.e. over channel WhatsApp this will be a phone number, on Apple Business Chat this is a hash.
  • $conversationClientIdNormalized
    • Normalized (00) version of the conversationClientId. This only works for and should be used with phone numbers.
  • $conversationHostId
    • The id which identifies the hosts. See $conversationClientId for more details.
  • $conversationClientName
    • The name of the client. This is not supported by all channels.
  • $channel
    • The channel over which the conversation takes place.
  • $chatId
    • Fixed hash; based on the channel, conversationClientId and conversationHostId.

System functions

When a session start the following system functions will be automatically created.

  • $GetNow()
    • Get the current time according to the given parameters.
      • TimeZone is required, and allows you to specify the time zone for which to get the time. You can use any time zone supported by the tz database. Refer to the "TZ identifier" column in the table on that page for the value to use as this parameter.
      • Format is required, and allows you to specify the format to apply to the time. For example, using yyyy-MM-dd hh:mm:ss will get you the current year, month, day, hour, minute and seconds. All the possible formatting options can be found here and here.
      • Language is an optional third parameter, which allows you to specify the language to apply to the output. If you get the weekday and supply it-IT , for example, you will get the weekday in Italian. You can see a list of supported language tags here. Refer to the "Language tag" column in the table on that page for the value to use as this parameter. If you omit this value the output will default to "en-US".
    • An example of this would be getting the current date and time in the timezone of our HQ in Breda: $GetNow("Europe/Amsterdam", "yyyy-MM-dd hh:mm:ss") .
    • It might also be helpful to get the current day. Let's make it more exciting by getting the italian variant: $GetNow("Europe/Amsterdam", "dddd", "it-IT") .

Variables from input

Variables can be created from input given by the user. Please refer to the input step in the steps docs for more information on how this works.

Variables from regular expressions

Variables can be created from entry input given by the user. Please refer to the entry step in the steps docs for more information on how this works.


Previous: Steps
Next: examples Intro

group icon
Get support

Can’t find the answer you are looking for?
Ask for the help of our chatbot, or get in touch with our support team.

Contact Support
Is this region a better fit for you?
Go
close icon