Header.
In the last tutorial, I showed you how to build an AI voice agent in retail AI that gets triggered
when someone submits a form like for example, on your website, it replies using a single prompt.
So that setup works fine, but it does have its limitations, like hallucinations or doing the wrong
thing, especially as your use cases gets more complex.
So basically, we created a single prompt voice agent.
We added a prompt that tells the agent what to say, the tone, the style, and how to behave, and
to make it a bit more dynamic.
We passed in a few variables, but everything still runs through that one single prompt, and that's
what we call a single prompt.
A voice agent.
So even if you use the best large language models like GPT four or cloud 3.5 or 3.7, and single prompt
agents can still run into issues like hallucinations so they can hallucinate or doing the wrong thing,
especially especially as your use case gets more complex.
So single prompt voice agents are great, but as your logic grows, they can become less accurate and
which can often lead to hallucinations or issues when handling multiple function calls.
At this time, we are going to build a more advanced AI voice agent using something called a conversational
flow.
So it's a relatively new method of building a voice agents.
So you have control of every step.
So what does that actually mean?
So think of it like designing a conversation using a flowchart.
So.
Instead of including everything into one big prompt, we break it down into smaller parts.
So each step handles a single task.
So this approach is way more powerful when you are building something for a reward because it keeps
the AI focused.
So each part of the flow does one thing, and you can create a separate path for things like checking
calendar availability, sending an email, booking a meeting.
So it only makes your agent way easier to manage and scale.
And you can add logic at every step.
So trigger automations in n810 and control how the conversation flows.
So in this video I will show you a quick demo and then we will build it together step by step.
And by the end of this tutorial you will have a very powerful voice agent.
All right.
Now I'm going to play a demo video I recorded earlier.
So it includes a walkthrough.
So you will get a clear idea of how the system works.
Hi everyone.
Today I'm going to show you a very powerful AI voice agent I built using retail AI and N810 that can
completely replace receptionist appointment setters, virtual assistants, and you can use it for many
more use cases and tweak to any industry.
And this is not just a prototype.
This system is production ready so you can implement it into your business or sell it to your clients.
Now let's do a quick demo.
So I'm going to call this physical therapy clinic.
Just bear with me.
Hello.
This is Sophia.
How can I assist you today?
Hi.
I'm looking for a chiropractor, please.
Would you like me to book an appointment for you with Kate, our chiropractic specialist?
Yes, please.
Can I have your name, please?
I'm Damien.
What's your email address?
It's n I n d e m o at gmail.com.
I also need your mobile number, please.
It's 07 5648 2602.
Can I ask what symptoms you have and if there is anything else you would like me to pass to Kate?
So my knee is very painful and it's a sport injury.
Thank you for the details.
What day and time worked best for you?
Can we do on Monday at 2 p.m., please?
I'm checking the availability for you.
Give me a moment, please.
Hello.
Thank you for your patience, Damon.
It looks like the time slot on Monday at two in the afternoon is not available.
Would you like to try for a morning slot at 11 in the morning, or an afternoon slot at three in the
afternoon on the same day?
Yeah, I can do at 11 a.m., please.
Great.
So just to confirm, I have you scheduled for an appointment with Kate, our chiropractor, on Monday,
at 11 in the morning.
Your details are name, daemon, email, end date and demos at gmail.com.
Mobile 07 5648 2602.
Appointment Monday at 11 in the morning.
Is everything correct?
Yes.
Everything correct.
Thank you.
Your appointment is confirmed.
You will receive a confirmation shortly.
Have a nice day.
Thank you.
Bye bye.
Now, as you can see, the meeting has been successfully booked and we got an email.
So I'm using my test email for a specialist.
So a chiropractor, um, and we got a summary email with all the details.
So we've got a client name, contact details and the reason for the appointment.
I designed this invoice agent specifically for a physical therapy clinic.
It handles all appointment bookings for three specialists chiropractor, massage therapist and physiotherapy
rehab specialist.
Each of these specialists has a separate calendar in Qualcomm AI voice agent has human in the loop functionality
so it detects when a caller is frustrated or requests a real person, and seamlessly transfers the call
to a human agent or directly to the specialist.
Also, it provides a summary of the conversation before the transfer, ensuring that the human agent
has full context.
Because this system is built using the conversation flow method, it cuts down AI hallucinations by
90%, so it stays on track and doesn't make things up.
You have full control over what the agent says, but if you want, you can also give it more flexibility
to handle open ended conversations, which isn't possible to achieve with other tools without coding.
The agent is also trained on the company's knowledge base, so it can instantly answer frequently asked
questions and provide accurate information without needing an intervention.
So here's what happens when someone calls the clinic looking to book an appointment.
The AI voice agent picks up the call and guides them through booking an appointment.
Then it checks the specialist's availability in real time.
Once they pick a date and time, the system locks in the appointment.
Automatically, the client receives an email confirmation and the specialist gets an email summary of
the conversation, including the client's contact details, their symptoms, and any extra notes or
comments, they added.
Each specialist has a dedicated AI Agent built in N8N that processes and analyses all the information
before sending a detailed email summary to them.
This system is designed to be super adaptable.
You can tweak it for different industries.
For example, instead of a clinic, you could use it for routing calls to different departments in a
business.
Automating scheduling for beauty salons and spas.
Handling customer inquiries before escalating to a human.
Processing appointments for any service based business.
Handling inbound support for real estate agencies.
Automating customer service for e-commerce stores.
And much more.
Honestly, this tech is a game changer.
Whether you're a clinic, an agency, or any business that handles a lot of calls, an AI voice agent
like this can save time, money, and frustration.
All right, so now let's, um, get our hands dirty and start building this voice agent from scratch
in little AI.
And in the meantime, we'll jump will jump into an A-10, uh, to build a agents, to integrate the
score analysis function and also to send a confirmation email with the notes the AI captures during
the conversation.
And let's create an agent from scratch.
This time we are going to build a conversation flow agent.
So this step, this type of AI voice agent is best for tasks with complex transitions.
So let's start from blank.
But you can also use pre-built templates such as for patient screening, real estate qualification,
and others.
So start from blank.
Alright, so the first thing is to configure our welcome node.
So this is so basically this is the conversation node.
So we'll use this node most of the time just by clicking on conversation right here.
But for now let's delete this one.
So in this welcome node we need to type what we want our voice agent to say as a welcome message.
So by default we have hello this is customer support department.
How can I help you today.
But we can change it.
And I'm going just to copy and paste.
Hello, this is Sophia.
How can I assist you today.
All right.
And here we can add transitions.
So it's basically like a path we want a AI voice agent to follow.
So by default we have user needs to return the package, or user needs to check the order status.
And because we are building a voice agent for a physical therapy clinic with with three specialists,
for chiropractic care specialists, for therapy specialists, and for physiotherapy and rehabilitation
specialists.
So we need to add three transitions.
So the first will be for chiropractor specialists.
So I'm going to copy and paste it.
The user needs to talk.
Chiropractic care specialists and change it.
Change this one.
The second transition would be to massage therapy specialist.
I'm just going to copy and paste it.
And the transition I'm going to add by just clicking on this plus button.
And using it to talk to physiotherapy rehabilitation specialists.
So after our voice agent says this line, it analyzes the customers response.
And based on that it transitions the flow so it moves the flow to the appropriate next node.
So in that case it would move the conversation just following this path to the next node.
So to the appointment handler.
And then it will say would you like me to book an appointment for you with Rob our physiotherapist and
rehab specialists and so on.
So we are going to as a third transition add user needs to talk to physiotherapy and rehabilitation.
So this time I'm going to type it manually.
During the talk, the user needs to talk to.
Ezio.
Therapy.
And rehabilitation specialist.
All right.
Great.
So the first one is is for chiropractic care specialists.
So we are going to add the same type of node.
So conversation node.
Let's move it up.
And then we are going to connect them together.
And then let's Ask another question.
So?
So, would you like to book?
An appointment.
With.
Our chiro.
Practic.
Specialist.
You have two options to choose from in the conversation node.
The first one is prompt, but 90% of the use cases will use static sentences.
This is the exact sentence we want our voice agent to say.
The prompt gives an LLM more flexibility, but is less accurate.
So again, because if you want to use a prompt, really allow for more randomness and consequently this
can cause more hallucinations.
Going to stick with static sentence option.
All right, so now we are gonna add transitions to this node.
So in other words instructions to our voice agent.
So.
If the user wants to book an appointment you can say something like if the user wants to book an appointment.
So this is the first branch and the second transition.
If the user the customer is not interested in booking an appointment but has some questions, we can
ask something like we can add something like if the user have questions answered shortly based on the
knowledge base.
So for the AI voice agent built using conversation flow method, we can also add knowledge base.
So the agent can go through the knowledge base and find the relevant answer for the user questions.
Let's rename this node to Appointment Handling.
And now we need to add another conversation node if the user want to book an appointment.
We want to ask them about the details.
So our agent can.
Capture capture of of all this information.
And then and then use it to to book an appointment.
And this time we want to ask About their name and as a transition.
If the user answered the question, we want a reverse agent to move to the next node.
So let's add another conversation node and connect it right here.
And let's rename this node to.
Collect details.
And let's say we want to ask about their email.
So we can always follow up.
So what's your email address.
And as a transition let's add the same condition.
So once the user.
Answer the question, move to the next node.
Then we need another conversation node to ask about their phone number.
So we're going to do the same thing.
So switch to the static sentence and ask about the mobile phone.
So I also need your mobile number please.
And let's rename this node to.
Collect email address.
This one to collect.
Number.
All right.
Now while you are building your conversational flow, retail actually gives you a really handy way to
test your agent in real time.
So over here you've got the test.
So let's just click on that.
And here you have two options.
Test audio.
So you can actually you can literally talk to your agent like you are on a call.
That's great if you want to hear how it responds with voice.
So let's test it.
Hi there.
Hello, this is Sophia.
How can I assist?
Hi, I'm looking for a chiropractor.
Would you like me to book an appointment for you with Kate, our chiropractic specialist?
Yeah.
So as you can see, it simulates the conversation.
But honestly, what I use most of the time is the test feature, so it's just quicker and more.
So when you click on this manual chart, you can manually chat with the agent.
And you can start the conversation from any note in the workflow.
So let's start from the welcome node.
Now let's move on to the calendar availability node.
As you can see, it's actually tries to call the function to check availability.
This is how you can test your agent while you are building your conversational flow.
So it's super useful way to debug and make sure everything works as expected before you actually go
live.
So now at this step, once our voice agent has captured all the key details like the name, email address,
mobile number, you can use that to ask the customer about their symptoms and record that information
too.
So that way when the agent sends a confirmation email with the full summary of the conversation to the
specialist.
It can include the symptoms as well.
So this helps the specialist prepare properly before the appointment.
So let's add the conversation note again.
And this time.
We are going to add this as a static sentence.
So can I ask what symptoms you have.
And if there is anything else you would like me to pass to Kate.
And as a transition of the previous note, we want to use the same condition.
So I'm just going to copy and paste it.
Okay.
Great.
Just to.
Fix it.
And it's called a number.
Now let's connect these nodes.
So the transition will be exactly the same as in the previous nodes.
So once you answer the question move to the next node going to place it here.
And then I'm going to add another conversation node.
And this time I'm going to.
Say something like thank you for the details.
What day and time works best for you.
And also let's say.
Here.
Ask for.
Additional information.
So then it will be easier to reference to this node.
And here.
Don't forget to switch over to this static sentence mode.
And as a transition, we want to say something like.
If user provides a valid date and time, move to the next step.
So only if the user provides the valid date and time, move to the to the next step where we will check
availability.
So now if the user wants to book an appointment and provided all the relevant information such as contact
details and the date and time that works best for them.
We want our AI voice agent to check availability.
And in that case, and this time we are going to use different type of node.
The function node.
So let's click on that.
And now we have to add a tool.
So click on add button.
And as you can see retail AI has built in integration with Calcom.
To check the calendar availability.
So let's select this one.
And here we need to provide the API key from Calcom.
And event type ID from Calcom.
So in the previous tutorial I showed exactly how to find the API key and the type ID.
So if you are not sure or you have forgotten, just go back and check that video.
So I've added mine.
Just going to save it and add.
All right.
So this node is configured.
Now let's Connected to the last node in our flow.
So if user provides a valid date and time, move to the next step.
So to this node.
Now once the user provides the date and time and our agent is ready to check the specialist calendar
to see if that slot is available, and we want our agent to sound as natural, to sound as natural and
human like as possible.
So on the right hand side you will see more configuration options for this node.
So let's go ahead and toggle the speak during execution feature.
And in this node again let's change to the static sentence.
And here you have to define what to say when calling the function.
so there will be no silence when our agent will analyze the calendar.
So let's say.
I'm checking the availability for you.
Give me a moment, please.
Now we are gonna add two transitions.
One to check the calendar for a time that matches the user's schedule, and another to handle cases
where the user asks to speak with a real person or sounds frustrated for any reason.
So I'm going to add, um.
Find the time on on a calendar that fits the user schedule as the first transition, and as the second
one.
I'm going to describe it as, uh, if the user requests to speak with a real person or express frustration,
move to this node.
So here we need to add another type of node.
So the transfer call node so that if the user asks to speak with a real person or gets frustrated,
the agent can try to hand off the call to a human.
So let's click on that node and let's connect it to this transition.
Now the configuration settings on the right hand side, just enter the phone number you want the call
to be directed to.
And if the transfer doesn't go through, we will add a fallback conversation to let the caller know
and and end the call politely.
So we are going to add another conversation node.
Move it right here and connect this transition.
And in that case we want our agent to say something like, I'm sorry, the specialist is currently unavailable.
Please call later to talk directly to the specialist.
Thank you for your patience and goodbye.
And we want to end a call.
So we are going to use the.
Ending call function.
So is this one.
And just connect these nodes together.
All right so let's zoom out.
So this is the conversation flow we have built so far.
Okay.
So let's carry on.
Now let's add one more conversation node with the condition I connected.
And the a condition, we want to describe the transition as if you agreed on the day and time with the
user, move to the next node.
So as the user and the agent agree on the date and time, the agent should book an appointment.
So let's go.
Let's go ahead and add another function node.
But this time let's add book on the calendar built in Chalcombe function.
You can also build your own custom function, but it's more complex.
So select this one.
You can leave the description as it is.
So when the users ask to book an appointment, book it on the calendar.
But you have to provide API key from the and event type ID.
so let's do it now.
So I'm in my calendar now.
Let's go to settings.
API keys.
Add.
A name.
Never expires.
Save.
Copy it.
And paste it here to event type ID field.
You have to go to our calendar.
So back event types.
I have 15 minute meeting.
So I'm going to click on this one.
And from the URL bar.
Copy the number.
And paste it here.
Select your time zone and hit save.
And click add.
Alright, so now we have configured book Appointment node to use this function calling.
And when we want our voice agent to book an appointment.
So let's connect it.
Now let's say.
We want our agent to speak during execution and we want it to.
We want it to say something like your appointment is confirmed.
You will receive a confirmation shortly.
Have a nice day.
Goodbye.
So now the appointment is confirmed.
And before we end the call, we want to send the details of this conversation to Natan because we need
to automate what happens.
What happens next?
So that includes things like summarizing the call and notifying the specialist, and sending a confirmation
email to the specialist with a summary and notes from the conversation, or saving the info for for
later.
So we are going to create a custom function and use a webhook to pass all the conversations data from
retail AI directly into our workflow.
So let's create a function, click add button and create custom function.
Now let's jump into Nathan.
So let's create a new workflow.
Let's rename it.
Now we are going to add a webhook node.
So let's search for webhook.
So this webhook will trigger our automation.
So we are going to copy this production URL.
Let's go back to our retail account and paste URL in this field.
Now as a description let's say sense users answer to the questions.
And let's name it ten days 2010.
Now let's save it.
And let's add it.
All right.
Great.
Let's add the transition to this node.
So we want to send all the details if the.
If the appointment is successfully booked.
And let's connect these nodes.
Alright, great.
Now the same transition for this node.
So let's add a transition.
If appointment successfully booked.
Now let's end the call.
So we are going to use ending function.
All right.
Awesome.
Now in the webhook node we want to change the method to post.
And now we want to add a agent to analyze all this data.
So let's add a agent.
And let's rename it to Kate.
So this is the name of our chiropractor.
Now you want to add the prompt.
So let's define below.
Let's switch.
Let's switch to expression and let's expand it.
So this is the prompt I have prepared.
So you are an AI assistant specialized in summarizing call transcripts.
Your task is to extract only the most important and relevant details from the conversation.
Always focus on the client's name and contact info.
Reason for the call.
Symptoms.
Issue or concern.
Additional notes from the client.
So you want our agent to summarize the transcript.
So you will get this JSON when you test your voice agent.
While this workflow is active, the current date and time is now Generate a structured appointment confirmation
email using HTML, ensure clear bullet points and proper formatting for readability, so this prompt
will be available for you in the resources.
So example output A new client has booked an appointment with you.
Client name.
So the extracted name from this transcript, email extracted from the transcript, etc..
So ensure proper line break breaks and HTML formatting for a clean display in emails.
And we have one tool.
So use email tool to send emails.
Alright great.
So you can just you can simply copy and paste this prompt into your agent or you can modify it to fit
your needs.
Let's close it.
Now let's add chat model.
I'm going to use OpenAI.
GPT four should be fine.
Make sure you OpenAI account is connected.
Okay, as a memory, I'm going to add simple memory.
Alright, great.
And as a tool I'm going to add Gmail.
So Gmail tool.
We want to send an email I want to send the email to this email address.
But you would use the specialist's email address so Lehman's gmail.com.
As a subject your appointment booked.
Now for the message field just click on this.
Let the model define this parameter feature.
It will automatically and intelligently write an expression for you.
So GPT four will be able to define this parameter.
All right great.
So let's close it.
And now let's make this workflow active.
Confirm.
Now let's go back to retail AI.
Here in the global settings you can switch to other languages.
You have Spanish, French, Chinese and so on.
You can select your favorite voice.
You can add your custom voice for example from 11 labs you can change the gender, you can change accent,
and so on.
Let's close it for now.
And here you can change the large language model for a global prompt.
GPT four is fine and is very cost effective.
So let's choose this one.
And here we are going to enter our global prompt.
So we are going to guide this AI voice agent and provide more details on the context of the of its role.
So I'm going to paste the prompt here.
And you can also find it in the resources.
So here Sophia, a customer support representative at Physical Therapy Clinic, offers physiotherapy,
chiropractic care, massage therapy and rehabilitation.
Your role is to assist potential clients in scheduling appointments with the appropriate specialist,
including physiotherapists, chiropractors, massage therapists and rehabilitation experts.
Always use the current date and time, and we specify our time time zone and also pass the general current
date time variable and assume that all appointments are for future dates only.
So as objectives assist in scheduling an appointment for physiotherapy, blah blah blah and best practices
during the call, ask one question at a time to keep the conversation natural and engaging.
Listen actively.
Now when collecting client information, ensure to gather their name, email address and mobile number.
So this is very important.
And waiting for each detail before proceeding to the next step.
So when presenting available time slots clearly state them in spoken language.
And if the user selects an unavailable time slot, provide two alternative options one in the morning
and the one in the afternoon on the closest available day.
And keep your responses clear and concise.
Avoid rambling.
Okay, great.
Here you can choose the knowledge base.
So basically you can add the knowledge base.
As I as I showed in the previous tutorial.
You just simply go to your AI dashboard.
So under Knowledge base section you can just click on this plus button and give the Knowledge base name.
You can add a web page.
You can upload files and you can add text manually and then hit save.
And when you go to your, uh conversational flow agent, you can add the knowledge base right here.
So it will have access to the documents.
Here you can play with some speed settings such as you can.
You can add the background sound.
You can adjust responsiveness so control how fast the agent responds.
After users finish speaking, you can add some interruption, sensitivity, etc. I'm not going to dive
deep into the settings.
Now this is really important because by adding the post analysis feature, you can automatically pull
out key details from the conversation.
So let's add text and click save.
And here you can choose.
And here you can switch between different LMS for this post call data retrieval.
But let's stick with the GPT four.
So now the final step in this setup is making sure that you We have a fallback plan in case things don't
go as expected.
So like when a human agent is not available.
And for that, we are using a special type of node which is called a global node.
So you can enable this feature in every conversation node.
When you click on the conversation node, like any of them, you can see that there is a global node
option.
So you can toggle it and it will allow other nodes jump jump to this node without edges.
So this node doesn't need to be connected to the rest of the workflow.
The global node is basically a part of your agent that can be triggered from anywhere in the flow.
So no matter when the conversation is and in this case It kicks in whenever the user says something
like, I want to speak to a real person or they sound frustrated.
So in this note, the agent responds with something like, I'm transferring you to a human agent now.
And then it tries to hand off the call.
But just in case the transfer fails, maybe no one is around.
We've got a backup message ready, so the agent politely lets the caller, uh, know support is not
available at the moment and ends the call nicely.
So this way we can keep everything professional and user friendly and and avoid bad customer support
experience.
So this is our conversational flow agent.
As you can see we have a quite a few nodes.
And this is the second part of the workflow.
So this is our global node right now for the other two specialists in our physical therapy clinic.
So the massage therapist and the physiotherapy rehab specialist.
The conversation flow is going to be exactly the same.
All you need to do is set up a separate calendars for each of them in Calcom, and then create dedicated
agents in Naa10.
To handle the color summaries and send out confirmation emails.
So really, it's a simple copy and paste job.
Just duplicate what we have already built and adjust the names and calendar links.
And of course, this setup is not just for small clinics.
You can easily scale it up for bigger businesses with five, ten, or even more team members.
It's flexible and ready for production.
All right, I hope this was helpful.
Now go ahead and build it out for your practice.
Thanks for listening and see you next time.