SnatchBot Support

Welcome to the SnatchBot Support. You'll find comprehensive guides and documentation to help you start working with SnatchBot as quickly as possible, as well as support if you get stuck. Let's jump right in!

The community forum is not a helpdesk
Let’s put this in the front - the vast majority of people here do not work for SnatchBot.

Get Started    SNATCHBOT API

Custom Variables

Give the possibility to insert custom variable function into the interaction to work with the information your bot has gathered.

📘

Note

To see a working example of a chatbot that uses custom variables to keep track of sales, please go to the SnatchBot Store and choose to edit the Pizza Bot Template.

You will need Custom Variables when you want your bot to be able to work with information it has gathered and, in particular, if you want to perform arithmetic functions during the course of the conversation.

For example, if you are designing a chatbot that can take payments and which calculates a running total, then the bot will store the figures it is adding up using the Custom Variables function.

You must define each Custom Variable with a name and an initial value by placing the following function in an Interaction.

[customVar KEY=VALUE]

KEY - KEY is the name you give the variable e.g. Total Bill.

VALUE - Value is the initial content of the variable

🚧

Note

Only alphanumeric names (English letter) are allowed in Attribute KEY names, please don't use special symbols.

The value of the Custom Variable is typically going to be a number, but you can also define it as statement (a word, characters, or even sentences) or you can assign to it values from responseTo or extractedData.

📘

Note

You cannot use the same name twice for a Custom Variable within the same interaction.

You cannot get a value for the customVar from the same interaction in which it is defined. Although the functionality does allow you to set the “Set value” and “Get value” functions within the same interaction, however, we do not recommend to do this, because a bot may work incorrectly.

Showing the value of the Custom Variable in the conversation

If you want to show users the value of a Custom Variable during the bot’s conversation, for example, to show them the total of their purchases, you place this function in an Interaction:

[ShowVar=KEY]

KEY must refer to a Custom Variable you have already defined. So, for example [ShowVar=Total Bill] will not work unless you have defined CustomVar Total Bill = x first.

As always, we have provided a shortcut to inserting functions. CustomVar and ShowVar can be found along the top of your edit interaction page, toward the left, as drop down options under Custom Variable.

You can assign a random value to your Custom Variable, using the following type of construction:

[customVar random={3}{4}{5}{6}{7}]. This will cause the Custom Variable to have a value of 3, 4, 5, 6 or 7, chosen randomly.

You can use the user's response to any previous interaction as the value of your Custom Variable by inserting a Prior Response.

🚧

Rules for storing the custom variables

Webchat or Embedded chat

  • If you Update the page then the Custom variables are not reset
  • If the Session is expired or you enter the restart command or RecipientID Session is expired (10 days) then the Custom variables are reset

Test chat

  • If you Update the page (pressing the Update button) then the Custom variables are not reset
  • If you Open/Close the chat before the session is expired then the Custom variables are not reset
  • If the Session is expired or you enter the restart command or RecipientID Session is expired (10 days) then the Custom variables are reset

Watch this video tutorial ''How to deal with Custom Variables on the SnatchBot platform''

Updated about a month ago


Next Steps

User Attributes are personal tags or labels that get assigned to each user interacting with your bot.

User Attributes

Custom Variables


Give the possibility to insert custom variable function into the interaction to work with the information your bot has gathered.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.