
Smarter WhatsApp Bots: Prevent AI Hallucinations With Knowledge AI
Using Generative AI to Improve Customer Experience
I’ve always heard that the best developers are lazy developers. I confess I’m a lazy developer. Generative Artificial Intelligence (AI) helps us be even lazier! Not only can we ask for refactored code or even wholly coded applications from this predictive AI. But we can outsource the other annoying parts of our applications, like all the data values we want to give our users.
>> Explore the capabilities of Knowledge AI in our public Beta announcement.
By using Generative AI alongside Vonage’s low-code virtual assistant building platform, AI Studio, lazy efficient developers can now significantly enhance customer experiences. In this article, you will learn how to replace your company’s Frequently Asked Questions (FAQ) site and turn it into a flexible, comprehensive FAQ WhatsApp agent (also known as a chatbot). Most importantly, you’ll learn how Knowledge AI allows you to keep your agent up-to-date and accurate on any new features or offerings in your company.
TL;DR If you don’t want to build out the Agent, copy the ZIP file and import it to AI Studio following these Github instructions.
FAQ page for Vonage AI Studio explaining whether the product works standalone and listing supported languages including English, Hebrew, German, and Spanish.
Mission: Turning Static FAQs into an Interactive WhatsApp Agent
Our mission in this article will be to turn an FAQ site into a WhatsApp Agent. We will use AI Studio’s own FAQ site and turn it into a friendly, flexible chatbot.
You will notice that this page also talks about contacting support. This is important in a Generative AI agent as the user’s intent (more about AI Studio Intents) is not to receive a straightforward text response here but rather to trigger some action. We call these action phrases. Action phrases can be emailing support, connecting users with a human agent, filling an order, and more! In this tutorial, we will mimic contacting support using the Send Email Node, but with AI Studio’s webhook node you are empowered to build advanced integrations.
I always suggest starting with a mockup of the agent we want to build. This is how our agent would look if we wanted to build without Knowledge AI:
Diagram showing an FAQ flow in AI Studio without Knowledge AI, where each intent must be manually mapped to a specific response.
We must create an intent not just for each action phrase but also for each FAQ question and answer pairing. But we are lazy builders and this would take soooo long!
Thank goodness we can now simplify our agent drastically. Now our mockup looks like this:
Diagram showing how AI Studio integrates with Knowledge AI to handle FAQ queries dynamically after classifying user intent.
Unless the user asks a question requiring an action phrase (in our case send an email to support), our Knowledge AI is now the default flow. You no longer have to build intents with extensive lists of user expressions the Knowledge AI will be able to handle inquiries with flexibility.
Prerequisites
You will need a Vonage API Account
DT API Account
To complete this tutorial, you will need a DT API account. If you don’t have one already, you can sign up today and start building with free credit. Once you have an account, you can find your API Key and API Secret at the top of the DT API Dashboard.
How to Create a Knowledge Base with Knowledge AI
The first step before building out the agent is to set up our Knowledge Base. This will be the repository that will guide our Gen AI’s answers. Navigate to the Knowledge AI tab in the AI Studio Dashboard.
Knowledge AI introduces two new concepts: Indexes and Sources. Sources are individual pieces of information and data. For instance, a source can be a URL (page on a website) or a file. Bundled together sources create Indexes. The full volume of information from which agents can generate answers is called an index.
Let’s get started creating our first index.
How to Add a Source in Knowledge AI
Click on Add Source. This will open a form to add a new source.
Add a new knowledge source in Vonage AI Studio by uploading a local file or providing a URL.
You’ll notice that sources can be either a local file (TXT, HTML, or PDF) or a publicly accessible URL. Add the link to the FAQ site, give it a name and click create. Now repeat the process for the WhatsApp Getting Started and WhatsApp Live Agent Routing sites.
Dashboard view of Knowledge AI sources for a WhatsApp agent. Displays three active content sources with their size, type, modification date, and status.
Now that we have a few sources, we’ll be able to ask more flexible questions. Let’s move on to creating an Index.
How to Create an Index in Knowledge AI
Click on the Index Tab in the left-hand panel. Then click on Add Index. First, give your Index a nice name like “AI Studio FAQs”. Then check all of your newly created sources and hit Save & Exit.
Assigning data sources to the 'AI Studio FAQs' index in Vonage Knowledge AI. All three sources—WhatsApp Live Agent Routing, WhatsApp Getting Started, and Studio FAQ Site—are selected.You should now see an Index available.
Index dashboard showing the 'AI Studio FAQs' index built from three knowledge sources: Studio FAQ Site, WhatsApp Live Agent Routing, and WhatsApp Getting Started.
How to Test Indexes in Knowledge AI
Knowledge AI allows you to test Indexes before hooking them up to agents. To do so hover over an index and a play icon will appear. Click on the play symbol and this will open up the Index Tester.
Testing interface for the 'AI Studio FAQs' index within the Knowledge AI dashboard. This allows users to validate how the AI will respond based on indexed content.
You can now ask any questions you want and the test agent will retrieve answers from your Index. Try to ask questions from the FAQ site like, “Which languages does the AI Studio offer?” or questions from the WhatsApp Getting Started page like, “Can I send WhatsApp messages before Facebook approval?”.
Now try a question not found on these pages, like “What is Vonage Knowledge AI?”. The agent says, “Unable to find relevant answer”. Perfect! This means the agent is capable of having human-like conversations but only within the scope of our Index.
Let’s fix this now and upload our PDF called Knowledge AI Information Slides as a new source. Create a new index and now include all our sources. You can now test again and ask the same question. Now we have an answer! This is how simple it is to update existing agents for any new products or features.
Test and refine your Knowledge AI responses by creating and querying an index based on uploaded sources.
Notice the little books symbol in the Knowledge AI response. You can click on it to see which Sources were used to generate the answer. You can use this to help tweak sources for an index to give better results.
Now that we have an Index that we can assign to our Generative AI agent, let’s build our agent!
How to Create an AI Studio WhatsApp Agent
To begin we’ll need to create a WhatsApp agent. You can open AI Studio from inside the Vonage Developer Dashboard and follow the instructions in the AI Studio documentation. There are three important options for our agent, select:
Type: WhatsApp
Template: Start From Scratch
Event: Inbound
How to Use the Collect User Input and Classification Nodes
Let's greet our users with a welcome message using the Send Message node. I like to attach a photo to our welcome message to use our company branding.
Next, we'll accept our user's response with a Collect Input node. We’ll store the response in a parameter called user_inquiry. The expected input should be only text.
Unless otherwise specified, all parameters in this blog post will use the @sys.any entity. For more information about entities (different types of parameters) in AI Studio, please read the documentation.
A Classification node will now dictate where to send our user. Create a single intent called Send Email. Provide some user expressions that deal with email and support. E.g. “Email support”, “contact support”, “support”. The Classification Parameter is user_inquiry.
Finish the Send Email flow. You will need to add a second Collect Input node to store the user’s email address. Then use that email in a Send Email node.
Create a Send Message node that sends a Thank You Message to the user for using the agent.
Conclude with an End Conversation node.
Email fallback flow in Vonage AI Studio for unhandled inquiries. If the agent can't resolve the request, the user's message is classified and routed to collect their email before sending it to a support team.
Now we’re all set to start using our Q&A node!
How to Use the AI Studio Q&A Node
First, let’s select the Q&A node from the Conversation section like so:
Demonstration of the Q&A node in Vonage AI Studio, showing real-time interaction with Knowledge AI. The assistant retrieves responses from indexed FAQ sources to answer user questions dynamically.
The configuration for our node will be:
Index: AI Studio FAQs (or your Index name)
User Input Parameter: user_inquiry
Response Paramter: ai_response
Waiting time: 2 seconds
The maximum time that AI Studio will wait for a response. If the response time exceeds 2 seconds then the Failed exit path will be triggered.
Average Length: 50
Response Guidelines: leave blank or experiment with your own!
How to Handle Our Generative AI Response
Now that we’ve hooked up our node to get FAQ answers, let’s send them to our users! The whole flow will look like this:
Node flow diagram for the AI-powered FAQ assistant in Vonage AI Studio. It includes branches for AI response generation, fallback messages, user repeat prompts, and graceful conversation endings.
This may look complicated, but most of it involves error handling and improving the user experience. The FAQ node creates three exit points: $ai_response (success), Don’t Know, and Failed. Depending on the result, these exit points provide some error handling.
To build it out:
For $ai_response exit point:Use a Send Message node and have it simply send the $ai_response parameter. Connect our $ai_response exit point to this node.
For Don’t Know exit point:Use a Send Message node and have it send an error message. Something like "Sorry, I don't know how to answer that.” Connect our Don’t Know exit point to this node.
For Failed exit point:Use an End Conversation node and have it say something like, “Oops! Something failed. Please try again.”. Connect our Failed exit point to this node.
How to Create a Question Loop
We want to allow the user to ask multiple questions of our chatbot.
To build it out:
Create a Collect Input node called Collect Repeat that will save a new Parameter called REPEAT. The node will receive Reply Button inputs. One button should have a title Yes and value of true. The other button should have a title of No and a false value.
Use a Condition Node which will check against REPEAT. Create one condition to check if REPEAT is equal to true, and another to check if REPEAT is equal to false.
Connect the true condition again to the Collect Inquiry node, the first collect input node we used which stores the value for user_inquiry
Connect the false condition to Thank You Message node form before, which connects to the End Conversation node.
You can now test your agent and ask it questions!
ive demonstration of a Knowledge AI agent responding to user input in a chat interface, showcasing intelligent real-time FAQ handling.
Conclusion
👏Give yourself a round of applause! You did it! You built your first Generative AI WhatsApp agent. Now let’s test using the built-in tester.
Does your classification node work? Is your agent able to differentiate when you want to send an email or ask a question about AI Studio? Try asking questions directly from the FAQ site and seeing how the answers compare. Then try asking your agent questions that deviate a bit from the FAQ and can only be answered from the other Sources. And then questions that are entirely not apart of the training data!
How does your agent behave? Let me know! Join the Vonage Developer Community Slack and tell me what you’re building in the #ai-studio channel. Or find me on X, formerly known as Twitter. And give VonageDev a follow while you’re at it.
Share:
)
Benjamin Aronov is a developer advocate at Vonage. He is a proven community builder with a background in Ruby on Rails. Benjamin enjoys the beaches of Tel Aviv which he calls home. His Tel Aviv base allows him to meet and learn from some of the world's best startup founders. Outside of tech, Benjamin loves traveling the world in search of the perfect pain au chocolat.