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?¶
- Define an expression to evaluate: Write a formula or calculation that the bot should evaluate.
- 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:¶
- Go to your bot and click on
🛠 Edit
to enter edit mode. - Select the button or command where you want to add the action, or create a new one.
- Click on
Actions 🌟
→🎯 New action
→👁 Evaluator
. - 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}
→ Returns8
. - 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¶
- Enter editor mode by clicking
🛠 Edit
on your bot. - Create a new command by clicking
✳️ New button | command
and naming it/calculate_price
. - Click
Actions 🌟
to open the command’s action menu.
2. Configure the actions¶
a) Action 1: Receive parameters¶
- Click
🎯 New action
→🖥 Receive parameters
. - This action does not require configuration, simply activate it by clicking
✅ Activate
. - Copy the ID of this action, as you will need it shortly.
b) Action 2: Evaluator¶
- Click
🎯 New action
→👁 Evaluator
. -
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 ofReceive 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)
-
Return to the actions menu and activate the action by clicking
✅ Activate
. - Copy the ID of this action, as you will need it shortly.
c) Action 3: Send message¶
- Click
🎯 New action
→✉️ Send message
. -
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 ofEvaluator
you copied earlier (action 2). -
Return to the actions menu and activate the action by clicking
✅ Activate
.
Final result¶
When you send the command:
/calculate_price 100 20
-
The Receive parameters action captures:
- Original price:
100
. - Discount:
20
.
- Original price:
-
The Evaluator action calculates the final price:
100 * (1 - (20 / 100)) = 80
-
The Send message action responds with:
✅ The final price is: 80
Final action setup¶
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.