Variables

Predefined Variables

{$username}

The user’s human readable username, taken from the messaging platform.

{$userid}

Arbitrary identifier assigned to each user by the BotCentral platform.

This is mostly used for debugging purposes. Say display userid to the chatbot and the chatbot will return the User ID.

Asking the bot to display userid

Asking the bot to display userid

You can then use it to view the debug logs associated with that conversation.

Getting the debug logs with the User ID

Getting the debug logs with the User ID

{$query}

The most recent user input.

{$botContext.starVar1} & {$botContext.starVar2}

The portions of the user’s input represented by prefixed and postfixed asterisks (*) in the Message Pattern.

For example, if the pattern is *hello*, and the user enters Well, hello there chatbot! — then:

  • {$botContext.starVar1} == Well,
  • {$botContext.starVar2} == there chatbot!

{$location}

If you set up a Required Context or a Quick Reply that uses the location type, you create a special variable called $location.

The properties of this location object can be accessed with:

  • {$location.city}
  • {$location.state}
  • {$location.zip}
  • {$location.lat}
  • {$location.lng}
  • {$location.latlng}

You can access these values from embedded JavaScript with the getUserLocation() function.

Developer-defined Variables — {$botContext.*}

You can create and set any variable inside Embedded Code with setBotVariable(). These can be accessed in Message content with {$botContext.<variablename>}, or in embedded code with getBotVariable().