Pizza Ordering Bot Tutorial
This tutorial demonstrates how to build a simple conversational flow using a pizza ordering bot. This example shows how to handle straightforward ordering processes with basic branching and order validation.
Flow Overview
Here's the conversation flow we'll build:
What You'll Learn
This tutorial covers:
- Building simple conditional flows
- Handling user corrections and order modifications
- Using entities for structured data collection
- Creating confirmation and validation steps
- Managing conversation state across multiple turns
Building the Pizza Bot
Step 1: Set Up Basic Structure
- Create a new bot called "PizzaBot"
- Set up the welcome intent with a greeting:
Welcome to Tony's Pizza! I can help you order delicious pizzas. What would you like to do today?
Step 2: Create Pizza Ordering Entities
Create these custom entities:
Entity: pizza_size
- Values: small, medium, large, extra-large
- Synonyms:
- small: personal, individual, 10-inch
- medium: regular, 12-inch
- large: family, 14-inch
- extra-large: xl, jumbo, 16-inch
Entity: pizza_toppings
- Values: pepperoni, mushrooms, sausage, peppers, onions, olives, cheese
- Synonyms:
- pepperoni: pepperoni, salami
- mushrooms: mushroom, fungi
- sausage: italian sausage, meat
- peppers: bell peppers, green peppers
Step 3: Create the Order Intent
Intent: order_pizza
- Example Phrases:
- "I want to order a pizza"
- "Can I get a large pepperoni pizza?"
- "Order pizza for delivery"
- "I'd like to place an order"
Step 4: Build the Ordering Flow
Story Node: Pizza Order Start
- Entry response: "Great! Let's get your pizza order started. What size would you like?"
- Form parameters:
size
(type: @pizza_size) → prompt: "What size pizza would you like? We have small, medium, large, and extra-large."
Story Node: Toppings Selection
- Entry response: "Perfect! Now, what toppings would you like on your $session.params.size pizza?"
- Form parameters:
toppings
(type: @pizza_toppings, allow multiple) → prompt: "What toppings would you like? You can choose multiple toppings."
Story Node: Order Confirmation
- Entry response: "Let me confirm your order: One $session.params.size pizza with $session.params.toppings. Is this correct?"
Step 5: Add Confirmation Logic
In the Order Confirmation
Story Node, add these routes:
Route 1: Confirmation
- Intent:
confirm
(create with phrases like "yes", "correct", "that's right") - Transition:
Checkout
Route 2: Modification
- Intent:
modify_order
(create with phrases like "no", "change that", "modify") - Agent Says: "No problem! Let's start over with your order."
- Transition:
Pizza Order Start
Step 6: Complete the Checkout
Story Node: Checkout
- Entry response: "Excellent! Your $session.params.size pizza with $session.params.toppings will be ready in 20-25 minutes. Your total is $15.99. Thank you for choosing Tony's Pizza!"
- Add a route with condition
true
that transitions toEnd Session
Advanced Features to Add
Once you have the basic flow working, try adding these enhancements:
Price Calculation
- Add price entities for different sizes
- Calculate total cost based on size and number of toppings
- Display the price before confirmation
Delivery Options
- Add entities for delivery vs pickup
- Collect address information for delivery orders
- Estimate delivery times
Special Offers
- Create intents for checking deals
- Add conditional logic for applying discounts
- Handle promotional codes
Order Tracking
- Create intents for checking order status
- Store order information for later retrieval
- Provide estimated completion times
Testing Your Pizza Bot
Test these conversation paths:
- Happy Path: "I want a large pepperoni pizza" → confirm → complete order
- Modification Path: Order → change mind → reorder → confirm
- Unclear Input: Test with ambiguous requests to ensure fallbacks work
- Multiple Toppings: "Large pizza with pepperoni, mushrooms, and sausage"
Best Practices Demonstrated
- Clear confirmation steps: Always let users review their orders
- Flexible modification: Allow users to change their minds
- Comprehensive testing: Test all possible conversation paths
- Graceful error handling: Provide helpful responses when things go wrong
This pizza ordering bot showcases how Botnex can handle real-world ordering scenarios with multiple decision points and user interactions.