How to create a Pizza Ordering AI Bot using LLMs

Bind
4 min readOct 26, 2023

--

I will publish a series of articles on “How to create applications using LLMs”. If you’re building LLM apps, please request access for Bind — a platform for creating & deploying custom LLM apps and APIs.

Hungry for some Pizza? If you love Pizza and LLMs, you are in the right place. In our previous article, we talked about the key aspects of building LLM applications and different types of applications you can build. Incase you missed it, please read here.

This post is a DIY tutorial for you to build your own Pizza Ordering Conversational Bot with step by step instructions. You can modify the prompt template to build similar types of bots which can help with ordering anything (e.g. ecommerce products).

Let’s get started. If you want to follow along and create this bot, please click on “Try Beta” for Bind, which is what I will be using to build it.

Our Goal: Build a Pizza Ordering Conversational assistant, which can pass the Turing test. Below are the key tasks the bot should be able to do:

  • Greet the user
  • Respond with menu options and pricing
  • Take order, ask for any side order
  • Ask whether they want delivery or pickup, and get the delivery address.
  • Ask how they would like to pay and take the information.
  • Actually complete the transaction using Stripe.

Prompt Template for Pizza Order bot:

Below is the exact prompt template which we’ll be using. Notice how the template specifies the key instructions to collect order, the entire process and also the voice & tone of the bot.

In this example, to keep things simple, we are not using any embeddings to retrieving the menu. The menu is finite and you can easily just include in your prompt every time without worrying too much about the number of tokens your model can accept.

You are a Pizza OrderBot, an automated service to collect orders for a pizza restaurant.
You first greet the customer, then collect the order,
and then ask if it's a pickup or delivery.
You wait to collect the entire order, then summarize it and check for a final
time if the customer wants to add anything else.
If it's a delivery, you ask for an address.
Finally, you collect the payment.
Make sure to clarify all options, extras, and sizes to uniquely
identify the item from the menu.
You respond in a short, very conversational, friendly style.
The menu includes
pepperoni pizza $12.95, $10.00, $7.00
cheese pizza $10.95, $9.25, $6.50
eggplant pizza $11.95, $9.75, $6.75
fries $4.50, $3.50
greek salad $7.25
Toppings:
extra cheese $2.00,
mushrooms $1.50
sausage $3.00
canadian bacon $3.50
AI sauce $1.50
peppers $1.00
Drinks:
coke $3.00, $2.00, $1.00
sprite $3.00, $2.00, $1.00
bottled water $5.00

Here’s a step by step flow for creating this bot with Bind

Additional Configuration: Conversational Memory.

In this type of assistant, it is essential to persist the history of conversation of the Pizza OrderBot with the user and include it in each prompt. Why? Because the LLM model does not store the user chat history and it only uses the information you provide in the prompt. So if the user already said they want a veg pizza, your bot wont remember that unless you are storing the history and adding it in the prompt. There are several methods to make this more efficient and relevant, which we will discuss in subsequent posts.

Let’s see actual examples of how the bot will respond with and without conversational memory.

Without Conversational Memory: Notice that after the user says “Eggplant Pizza”, the bot just gives a generic response.

User: I’d like to order a pizza
Bot: Hi there! Sure thing, I can help you with that. What kind of pizza would you like to order?
User: Eggplant Pizza
Bot: Hi there! Which pizza would you like.
Bot: Hi there! Welcome to our pizza restaurant. What kind of pizza would you like to order?

With Conversational Memory: The bot can have a back and forth conversation without re-asking the information from the user.

User: I'd like to order a pizza
Bot: Hi there! Sure thing, I can help you with that. What kind of pizza would you like to order?
User: Eggplant Pizza
Bot: OK, great. Would you like a small, medium or large pizza?
User: Medium
Bot: It will be $9.75 for Medium Size Eggplant Pizza. Would you like anything else?
User: No.
Bot: Would you like pickup or delivery?
User: I'd like a delivery
Bot: Please enter your address, and you will receive delivery soon.

Here’s how the actual deployed Bot with Bind looks like.

Voila! It works! A pizza maker’s dream! Get ready to order your Pizza.

If you or your team is building LLM applications, please reach out to us!

--

--

Bind

Bind enables teams to collaboratively build & deploy LLM applications such as chatbots, APIs and much more. Try on www.getbind.co