In this demo, we will:
PizzaOrderBotA bot to take pizza ordersPizzaSizePizzaSizeAvailable pizza sizessmallmediumlargePizzaTypeAvailable pizza typesmargheritapepperonivegetarianhawaiianOrderPizzaIntent to order a pizzaI want to order a pizza
I'd like a {PizzaSize} {PizzaType} pizza
Can I get a {PizzaType} pizza
I want a {PizzaSize} pizza
Order a {PizzaType} pizza please
I'd like to order a {PizzaSize} {PizzaType}
Get me a pizza
Pizza order
Can I order a {PizzaType}
I need a {PizzaSize} {PizzaType} pizzaWhat type of pizza would you like?PizzaTypePizzaSizeWhat size would you like?QuantityHow many pizzas would you like?You want to order {Quantity} {PizzaSize} {PizzaType} pizza(s). Is that correct?Okay, let's start over. What would you like to order?PizzaOrderProcessorimport json
import random
import string
def lambda_handler(event, context):
# Extract intent name
intent_name = event['sessionState']['intent']['name']
# Extract slot values
slots = event['sessionState']['intent']['slots']
if intent_name == 'OrderPizza':
pizza_type = slots['PizzaType']['value']['interpretedValue']
pizza_size = slots['PizzaSize']['value']['interpretedValue']
quantity = slots['Quantity']['value']['interpretedValue']
# Generate order number
order_number = ''.join(random.choices(string.ascii_uppercase + string.digits, k=8))
# Calculate price (simplified pricing)
size_prices = {'small': 10, 'medium': 15, 'large': 20}
base_price = size_prices.get(pizza_size, 15)
total_price = base_price * int(quantity)
# Prepare fulfillment message
fulfillment_message = (
f"Great! Your order has been placed. "
f"Order #{order_number}: {quantity} {pizza_size} {pizza_type} pizza(s). "
f"Total: ${total_price}. "
f"Your order will be ready in 30-40 minutes."
)
response = {
"sessionState": {
"dialogAction": {
"type": "Close"
},
"intent": {
"name": intent_name,
"state": "Fulfilled"
}
},
"messages": [
{
"contentType": "PlainText",
"content": fulfillment_message
}
]
}
else:
response = {
"sessionState": {
"dialogAction": {
"type": "Close"
},
"intent": {
"name": intent_name,
"state": "Failed"
}
},
"messages": [
{
"contentType": "PlainText",
"content": "Sorry, I couldn't process your request."
}
]
}
return responseI want to order large pepperoni
pizzas2yesI want to order a pizzaVegetarianMedium1YesYesPizzaLex