Variables in BotStudio

Variables are essential in BotStudio for creating dynamic, personalized conversations. They allow your chatbot to store and use user inputs, internal states, and system-generated information. This section explains how variables behave in different fields and how to manage them effectively.

Where Variables Are Used

Variables in BotStudio can appear in two types of fields:

  • Code Fields: Fields used for logical operations or system configuration (such as tags or conditions).

  • Non-Code Fields: Fields where the chatbot outputs messages to users (such as Response activities).

Each field type has a specific way of referencing variables.

Using Variables in Code Fields

In code fields, such as those that use a “Code...” placeholder, you should write the variable name directly, without quotation marks.

For example, if a variable named customer_email contains the value "test@example.com", then entering customer_email in a tag field will tag the chat with "test@example.com".

If you want to use a fixed, static value instead of a variable—such as the phrase "Email Problem"—you should enter it with quotation marks. This tells the chatbot to treat it as plain text, not as a variable name.

Using Variables in Non-Code Fields

Non-code fields, such as chatbot responses, treat all text as literal unless you indicate otherwise. To reference a variable in these fields, wrap the variable name in curly braces.

For example, if a variable named customer_name contains the value "Karen":

  • Entering: Hi {customer_name}!

  • Will output: Hi Karen!

However, if you enter: Hi customer_name!, the chatbot will display it exactly as written, without replacing it with the variable's value.

The Variables Page

The Variables Page provides an overview of all variables used in a chatbot and allows you to manage them more easily.

To access the Variables Page:

  1. Open a specific bot.

  2. Navigate to the "Advanced" section in the left-hand menu.

  3. Click on "Variables".

On this page, you can filter variables by type:

  • Read-Only Variables: These are system-defined and cannot be edited, such as thisMessage.

  • Write-Only Variables: These are user-defined and can be edited in your chatbot flows.

You can also search for variables using the “Pick variable” dropdown. When selecting a variable, you’ll see which nodes in your flow are using it. For example, the variable “visited” may be used only in a “Greet” node.

Special Purpose Keywords

BotStudio provides several built-in variables (keywords) that give access to useful runtime information. When using these keywords in non-code fields, wrap them in curly braces.

  • {thisMessage} refers to the user’s most recent message, after entity recognition.

  • {thisMessageVerbatim} refers to the exact message the user sent, with no processing.

  • {transcript} returns the full conversation between the user and the chatbot.

  • {sent_msgs} returns the last message sent by the chatbot. This keyword is only usable in inactivity nodes.

Example Uses

To reference the user’s last input: "I couldn’t recognize an email from {thisMessage}."

To provide a transcript: "Here is your chat transcript: {transcript}"

To repeat the chatbot’s previous message before ending a session: "It seems you’ve been inactive. Here’s what I said earlier: {sent_msgs}"

Collaboration and Auto-Save

BotStudio supports real-time collaboration. Multiple users can work on the same chatbot simultaneously. All changes are saved automatically, so there is no need to manually save progress.

Published

Last updated

0
0