SmartbotPro
  • Smartbot Pro – messenger marketing tool
  • Most important
  • Mini-course
    • Registration and personal account
    • Initial scripting tools
    • Creating the first script
    • Users and collection of information
    • Applications, variables and managers
    • Data validation
    • Collection of applications for a webinar within Telegram
    • Testing unpublished scripts
    • Newsletters
    • Template "Test with a set of points"
    • Statistics
    • Interface hacks
  • Beginning of work
    • Registration in the service
    • More about scripts
    • How to add messenger
      • Adding Telegram
        • Adding a bot to a group chat in Telegram
      • Adding ВК
      • Adding Viber
      • Connecting a channel to a script
      • Linking a social network account
  • Scripts
    • Basics
      • Create a script
      • Script templates
      • Editor interface
      • Publishing a script
      • Script testing
      • How the script is chosen
    • Script events
      • Message from user
      • No appropriate script
      • First message
      • VK Events
      • Webhook
    • Actions
      • Send a message
        • Buttons
      • Process message
      • Extract data
      • Change context
      • Write to statistics
      • Send Notification
      • Switching to another script
      • Working with the user
      • Set variable
      • Scheduled transitions
      • Run SmartQuery
    • Conditions
      • Condition
      • Condition with options
      • Conditions of VKontakte
    • Variables
      • Special Variables
      • User variables
      • Global variables
      • Variable %ref%
    • Acceptance of payment
    • Telegram bot menu
    • Integrations
      • Google-таблицы
      • http request
      • amoCRM
      • Get Course
      • Yukassa for receiving payments
    • Reactions
  • Newsletters
  • Settings
    • Projects
    • Cabinets
  • Information sections
    • Statistics
    • Users
  • SmartQuery
    • Introduction
    • Language syntax
    • Function Reference
  • The documents
    • Privacy Policy
    • Terms of service
    • Subscription and rates
Powered by GitBook
On this page
  1. Scripts
  2. Actions

Set variable

In this article, we will look at how to change variables during the script.

PreviousWorking with the userNextScheduled transitions

Last updated 2 years ago

This action allows you to set and change the value of variables for the user at the right place in the script.

Thus, you can accrue bonus points, save information from the user, set statuses and much more.

To set a variable, we add this action to the screen of our script by right-clicking in an empty space, or by selecting the desired action from the additional menu.

In the block menu, we can give the action a name, choose which variable to change, or create a new variable.

For example, let's create a new variable for accrual and calculation of user's bonus points and call it "Points"

A window for creating a variable will appear. Let's choose the variable type - number, so that it can be increased and decreased as needed.

The access level is local, that is, its value will be different for each user.

When everything is ready, click "Create":

Now in the block menu, increase its value by +1.

Let's write a simple arithmetic operation in the right field:

{{%Points%=%Points%+1}}

Please note: for operations with variables, all expressions must be framed with double curly braces {{ }}

By the way, you can write more complex mathematical calculations in the right field, as well as use the SmartQuery syntax. Excellent! We just have to link this block with the key user action, for which he will receive a bonus. Let's say we'll award points for the first post in a group.

You can also set several variables at once in one block by clicking the "Set one more variable" button

Now you know how to work with the "Set Variable" action