In this video, you will learn how to perform mathematical calculations with the action block in Wabb
In WhatsApp Bot Builder (WABB), mathematical calculations can be performed using action blocks and user fields. When asking customers for input, store their responses in a user field.
Note: Ensure that the data type of your user field or bot field is numeric to avoid errors during calculations.
Below is an example of how to implement this effectively:
Example: Calculating Order Costs
Set Up User Fields:
price_per_cup: To store the price based on the selection.
quantity: To store the number of items ordered.
total_cost: To store the calculated total cost.
Create a Menu for Product Selection:
Use a button menu to offer options like "Coffee (₹50)" and "Tea (₹40)."
Save the user's choice in the selected_product field.
Set Price Based on Selection:
Use an action block to assign ₹50 to price_per_cup if "Coffee" is selected.
Assign ₹40 if "Tea" is selected.
Ask for Quantity:
Prompt users with, “How many cups of {selected_product} would you like to order?”
Save the response in the quantity field.
Calculate Total Cost:
Check for Numeric Input:
Before performing the calculation, ensure that the quantity field contains numeric data. You can implement a check to validate this input and prompt the user again if necessary.
Inform the Customer:
Managing User Fields
To edit or delete a user field, go to the User Fields section in Settings, select the field you want to modify, and choose the appropriate action.
This process automates order processing, enhancing customer interaction and improving efficiency. Customize it for different products or services to suit your business needs. If you have any questions, our support team is available through the help center chat.