Build a Quote Calculator using Dynamic Variables

Popular:

# Build a Quote Calculator using Dynamic Variables

July 24, 2024

Dynamic Variables allow you to capture both text and numerical values. You can use this in the bot logic and dialogue either from user input or in setting values in the background. Learn how to use Dynamic Variables to build a quote calculator for your own business.

Watch the explainer below from one of our Technical Account Managers, Gavin or, read on for a step-by-step guide.

## Price calculator bot for a pizza order

Let’s say you want to create a bot that calculates and displays the breakdown of the total price of a pizza order. The equation for the total price could be

base + toppings delivery = total price

## Here’s how to build the bot

### Step-by-step guide

If you’re unsure how to apply this example to your use case, contact your Customer Success Manager for personal guidance.

#### Step 1: Create the Dynamic Variables

To use Dynamic Variables you need to add them to each bot you want to use them in and set the values you want them to have.

Open the Dynamic Variable Management panel by activating the toggle in the upper left corner of the bot builder.

Add your first variable by clicking the blue button in the Dynamic variable control panel.

Type the name of the first variable in the Variable Name field. Confirm the name by clicking it on the dropdown that appears.

Switch the Type to number, since price is a numeric variable.

As we are calculating the price through selections set the default value field to 0.  Repeat this to add the other variables below.

PizzaSizePrice – number – 0
IngredientsPrice – number – 0
Pizza Total – number – 0

#### Step 2: Build the bot logic

Using a combination of single and multiple choice nodes add all the options you need the user to select to build their pizza.

#### Step 3: Assign the Dynamic Variables to each answer choice and set their value.

Double-click to edit the node, click show options -> Variables and then select the variable name you want to assign to the selection along with the value in numbers only

Do this for all the options that have a cost using these prices:

Pizza base price:
– Small (7€)
– Medium (10€)
– Large (15€)

Pizza price
– Pepperoni (2€)
-Margherita (2€)
-Vegetariana (2€)

Toppings price:
– Pulled Pork (1€)
– Salami (1€)
– Pepperoni (1€)
– Chicken (1€)
– Paprika (0€)
– Feta cheese (1€)
– Extra cheese (1€)
– Pineapple (1€)
– Minced meat (1€)

Delivery cost:
– Pick up from the restaurant (free)
– Delivery (5€)

#### Step 4: Use the Calculator node to calculate the price

Now that all the prices are added and the user has selected the pizza they want – we need the calculator node to total it all together. Add the node from the menu and add the equation pizzaSizePrice + ingredentsPrice + PizzaDelivery with the Output value of Pizza Total.

You can either select these options from the inputs dropdown or by typing them in. Any Dynamic Variables will be highlighted in pink so if yours are in grey – try again.

#### Step 5 : Display a breakdown of the total price to the user using variable repetition

If you want, you can display the breakdown of the total price to the user using the Variables dropdown in a node.

Add a bot says node to present the total price along with the breakdown by selecting the variable in place of where the price should be. Remember to add the currency and any text you want to appear with the price.

#### Step 6: Preview your pizza bot!

Click the preview button at the top of the page to see how your pizza calculator works.