Skip to content

Action: Evaluator

The evaluator action is used to evaluate an expression and store the result, which can then be used in subsequent actions. It's a flexible tool that allows performing mathematical operations, concatenating text, using variable values, and much more. The key to its use lies in reusing results.


How does this action work?

  1. Define an expression to evaluate: Write a formula or calculation that the bot should evaluate.
  2. Use the result: Once the expression is evaluated, the result is stored and can be used in subsequent actions, as many times as you want.

How to configure the action?

1. Create the action:

  1. Go to your bot and click on 🛠 Edit to enter edit mode.
  2. Select the button or command where you want to add the action, or create a new one.
  3. Click on Actions 🌟🎯 New action👁 Evaluator.
  4. Click on Configure 🛠 to set up this action.

2. Configure the options:

➡️ Set expression

Write the expression you want to evaluate inside curly brackets { }. You can use variables and action IDs. For example:

  • Mathematics: {5 + 3} → Returns 8.
  • Concatenating text: {"Hello, " + first_name} → Combines "Hello, " with the user’s name, returning something like "Hello, John".
  • Using previous data: {#PreviousActionID.param1# * 2} → Multiplies by two the value of the parameter captured in a previous action.
  • Using functions: {random(1, 10)} → Returns a random number between 1 and 10.

➡️ Delete saved (optional)

Deletes the previously stored expression.

3. Activate the action

Click ✅ Activate to enable this action and make it functional.


What does this action return through its ID?

This action returns the evaluation result. Access the result using:

#ActionID.data#

Replace ActionID with the ID of this action (Evaluator).


Practical example: Calculating a product discount

Suppose you have a command called /calculate_price that calculates the final price of a product after applying a discount.

Example command usage:

/calculate_price 100 20
  • Parameter 1: Original price of the product.
  • Parameter 2: Discount percentage.

What are parameters and how to obtain them?

To learn what parameters are and how to obtain them, check out the Receive parameters action.

The calculation should return:

✅ The final price is: 80

We will use this action to perform the calculation.

1. Create the command

  1. Enter editor mode by clicking 🛠 Edit on your bot.
  2. Create a new command by clicking ✳️ New button | command and naming it /calculate_price.
  3. Click Actions 🌟 to open the command’s action menu.

2. Configure the actions

a) Action 1: Receive parameters
  1. Click 🎯 New action🖥 Receive parameters.
  2. This action does not require configuration, simply activate it by clicking ✅ Activate.
  3. Copy the ID of this action, as you will need it shortly.
b) Action 2: Evaluator
  1. Click 🎯 New action👁 Evaluator.
  2. Click Configure 🛠🪧 Set expression 🪧 and enter the expression to calculate the final price:

    {#ActionID.param1# * (1 - (#ActionID.param2# / 100))}
    
    • #ActionID.param1#: Original price.
    • #ActionID.param2#: Discount percentage.

    Replace ActionID with the Action ID of Receive parameters you copied earlier (action 1).

    Formula for calculating a discount

    We used the standard mathematical formula to calculate product discounts:

    final_price = original_price * (1 - discount_percentage / 100)
    
  3. Return to the actions menu and activate the action by clicking ✅ Activate.

  4. Copy the ID of this action, as you will need it shortly.
c) Action 3: Send message
  1. Click 🎯 New action✉️ Send message.
  2. Click Configure 🛠💬 Set message 💬 and enter the message to display the final price:

    ✅ The final price is: {#EvaluatorActionID.data#}
    

    Replace EvaluatorActionID with the Action ID of Evaluator you copied earlier (action 2).

  3. Return to the actions menu and activate the action by clicking ✅ Activate.

Final result

When you send the command:

/calculate_price 100 20
  1. The Receive parameters action captures:

    • Original price: 100.
    • Discount: 20.
  2. The Evaluator action calculates the final price:

    100 * (1 - (20 / 100)) = 80
    
  3. The Send message action responds with:

    ✅ The final price is: 80
    

Final action setup

VisualMaker action evaluator example


Important notes

  • Combining data: You can mix numbers, text, variables, functions, and results from previous actions.
  • Reusing the result: Store the evaluated value and use it in as many subsequent actions as needed.