Categories
LLM

How to create AI chatbots using LLMs and Generative AI

In our previous article, we talked about the foundational aspects for building LLM applications, such as models, knowledge base, embeddings, model refinement, vector databases. Now lets deep dive into how to build Conversational AI or AI Chatbots using Generative AI.

What is an AI chatbot?

Conversational AI chatbots are applications which can have human-like conversations with users. This isn’t really a new concept, (so called) AI chatbots have existed for several years, however up until now they lacked the sophisticated reasoning ability which LLM models such as GPT provide. If you have interacted with AI chatbots on various websites, most likely, you’ve just asked to “speak to an agent”. 

Traditionally, the way to create AI chatbots is by manually creating intents which map to user questions, and map the intents to responses the bot can provide. Example: If user says “When will my order get delivered?”, Map it to the intent “Orders” and create a pre-defined response “To get a status of your orders please check the status tab and click on where is my order”. Imagine doing this for thousands of intents manually and writing hundreds of manual responses. Customer Support teams spend countless hours doing this. So, in order to create an AI chat bot with traditional tools such as Intercom or Ada, you need a lot of human beings doing manual work.

For AI chatbots to truly provide human-like interactions and to pass the Turing test, it is critical for the models to understand, interpret, and respond to user queries in a natural and contextually relevant manner using factually accurate information about the products and services they are providing assistance with. They are widely used in various sectors for customer service, information retrieval, and interactive engagement, enhancing user experience by providing quick, accurate responses and learning from each interaction to improve over time.

LLMs for AI chatbots vs Traditional chatbots such as Intercom

There are several tools for creating chatbots, such as Intercom, Zendesk, Zoho which offer the ability to include smart responses to user questions. One of the biggest challenges which the existing systems is the amount of work it takes for the customer support team to manually create intents, setup workflows and rules which could easily take several days or weeks. Even after that, the experience isn’t human-like and it typically spits a robotic recommendation or a message which isn’t really appealing to the end users.

The biggest benefit of using LLMs based systems such as Bind AI for creating or enhancing your conversational AI chat bots are the following:

  1. Ability to understand the user questions and produce a human-like response
  2. Provide deep insights and details in responses using your own knowledge bases
  3. You can just copy paste your knowledge base and FAQs and completely skip the manual workflow builder steps.
  4. Increase your customer experience, NPS and even sales using AI bots!

Step-by-Step Tutorial: Create a Conversational AI Chatbot for Pizza Ordering

In this post, we will show a step-by-step tutorial for creating your own Pizza Ordering Conversational AI Bot with step-by-step instructions using Bind AI. You can modify the prompt template to build similar types of conversational AI assistants and bots which can help with a variety of use cases such as e-commerce shopping and checkout bots, customer support bot, sales support assistant and developer API documentation assistant and much more).

Now, hungry for some Pizza? Let’s get started. If you want to follow along and create this bot, please create an account and “Try Bind“, which is what I will be using to build it.

Our Goal: Build a Pizza Ordering Conversational AI bot, 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 Ordering Conversational AI chatbot:

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.

Try the bot using this link: https://app.getbind.co/webbot/6566c5aff7b5b4fae6758940

 

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

If you or your team is building Conversational AI chat bots or using tools such as Intercom or Ada to create AI flow for chatbots, please contact Bind AI

Comments are closed.