Let us run our scenario to check that all of the things are perfect or not.
Click on save.
Click on run once.
Go back to Vapi dashboard.
Hello, this is Mary from Mary's Dental.
Yeah, I want to book an appointment.
And my name is Manthan Patel.
Hey, Manthan.
Nice to meet you.
What's the purpose of your appointment?
Yeah, I have a root canal operation.
Got it.
When would you like to come in?
Let's see tomorrow.
Hold on a sec.
All right.
Thank you.
Mary.
Okay.
Here are five of you.
Awesome.
Our Make scenario is running successfully.
So if we click on this and the message is
Time: Tomorrow.
Let us check that our OpenAI model is able to perform that action or not.
In output section, you will be able to see our start time is 20204 eight, which is August and the first
date from 9 to 5 because right now is 31st July.
As you can see, the created date is 31st July and tomorrow is obviously the 1st of August.
Amazing.
Now we need to transform this output into a parse JSON format.
So click on add another module and under JSON we will select parse JSON.
And don't worry, it is very easy.
All we need to do is create a data structure.
We will click on add.
We will name our data structure as let's say DS.
And then all we need to do is we need to enter our start time and date time.
And we don't have to do anything else.
So under specification, add our item and under name
We will say our start time.
And you don't have to change anything here.
And let us add our end time.
Again don't worry about this information.
Simply click on save. Under JSON string,
We actually need the information from our OpenAI output.
So you will find the output under choices, under messages, and then content.
You will be able to see the start time as well.
Amazing.
Then click on okay.
Now we will actually need to check that if they are booking on Sunday or Saturdays, because we are
actually closed on Sunday and Saturdays and we are only open from Monday to Friday.
So we need to check that the day is Saturday or Sunday, so we will reject the appointment.
And if it is on Monday to Friday, we will accept the appointment.
So we will need to convert our date into day of week.
I hope you got my point and for that we will be using a special tool or simply go to tools and then
we will select a variable.
Let us give this variable name from day of week.
Let's say day_of_week.
Again, why we are creating this tool is because we don't want to book appointment on Saturdays and
Sundays, and that's why we have to transform our date information or 'date' output into 'day' output.
So under variable value, all we need to do is structure this or format this start time in day of week.
So we will simply search for format and you will be able to find this format date option as well as
you can find this format date option under Calendar. Format Date here.
Simply click on this before the semicolon.
We will add our start date or start time.
So under JSON we will add our start time. No, not right here.
Just before the semicolon.
Start time.
And let us format this as 'dd'.
For example, Saturday stands from SA or Sunday stand from Su.
That's why we are formatting this in this order.
Then click on okay.
We will actually use a router to divide both of these information.
If they are booking on Saturday or Sunday, we will actually reject them and we will only pass the information
if they are booking on Monday to Friday.
Let us add a router. For first,
We will select a webhook and we will say we are not available on weekends, but this is not the right
format as you can remember.
So we will go to Vapi documentation.
Copy this thing.
And again it is very easy.
And the result all we need to associate this X with is our toolcallID.
And our result.
So paste our format.
Clear this 'x' and we will find our toolID right here.
And in result, we actually want to say that we don't book appointments on weekends.
We are not available on weekends.
Then click on okay.
The next step is you already know.
The answer is we are going to set up the filter so that only Saturday and Sunday appointment goes to
this webhook.
Click on this filter and set up a filter.
We will say, don't book appointment.
And don't worry, this is just an label.
And let us use this as a route as a fallback.
Now under condition, we want the day of the week to be Saturday or Sunday in order to pass to this
webhook.
So under condition, we will search for this variable or under tool.
And that's why we have created this tool, because we want the format in days and not in date equals
to, let us say Saturday.
Then we also need to block appointments on Sundays.
So simply click on this, again day of weeks and which is Sunday or Su.
And again under tools we have defined this dd and that's why we are using Sa or Su.
Then click on okay.
Let us set up our filter, set up our filter and label this as book or let's say check.
Under condition, we will select Day of Week.
And this time we will not add all of this information.
For example Monday Tuesday, we will simply select not equal to
Sunday.
Click on this.
Not equal to Saturday.
So eventually Monday Tuesday Wednesday, Thursday Friday we'll pass this filter and click on okay.
All right.
It's time to introduce Google Calendar or Calendly from booking and checking our appointment.
But most of you guys are using Google Calendar, so we are using that one in this example.
Click on plus search for Google.
Then what we are doing, we are making an API call to check that there are available time slot in our
Google calendar or not.
So search API or click on this make an API call.
I have connected my Google Calendar account.
How do we find the URL that checks that our calendar is busy or free?
So simply use this /v3.
as you can see from here, and freeBusy.
And I'm not just pulling out of thin air.
I have actually read Google documentation, and it says that if you want to check that if your calendar
is free or busy, you can use this URL here.
It is free and busy returns /freeBusy information from a set of calendars.
So all we need to do is use POST method and /freeBusy.
Again, the method will be post because we are posting the information to our Google calendar to check
that if you are available or not, and we are not receiving information from Google Calendar, we are
posting information and that's why we are going to use method post.
Then leave the header as it is and the body section,
We will add the information of our time.
Use curly brackets, ", and let's say our start time or time minimum.
Is going to be our start time.
So under from json.parse.
Select start time then comma then maximum time which is our end time.
Time Max.
:
We will use our end time then our time zone.
So time zone.
Make sure to add your time zone and not my time zone.
Otherwise it won't work which is +05:30.
After that, we need to add our email ID that we have connected with our Google Calendar.
And don't worry, all you need to change here is your time zone and your ID, because I will be providing
this blueprint in the resource section.
Then click on okay.
Amazing!
We have made our API call to Google Calendar.
After that, we need to check that if there are any free slot available in our calendar or if there
are available, so we will need to display 5 available times from our slot.
So again we will use a router.
Under flow control, we will use a router.
And for this part, we will say there are no available time zone.
Please try for the next day.
So we will simply add a webhook.
Go back to our VAPI documentation, copy this, paste it here.
In place of X, we need our toolcallID.
So go to toolwithtoolCallList and a toolcall.
Select our ID any place of Y.
We will say all time slots are booked.
Please check for another date and then click on okay.
And we have to set up the filter as well.
But we will set up the filter later on.
So we need to convert array into bundle of texts, so we will use iterator for that.
Click on +, under flow control.
You will be able to find this iterator.
Again, don't worry, it is very easy.
Here we need to select the array of our Google Calendar.
So under Google Calendar all we need to do is select body which consists of array.
Then click on okay.
Therefore it will convert our array successfully.
Now again we need to transform this bundle of text into JSON format.
So we will use yet another tool which is again JSON.
And we need to actually create JSON.
And we will add another data structure.
Click on add and let's say Ds2.
We have to add the specification for our start date and our end date.
Click on Add item and the name of the property, we have selected as value.
So type value.
And then type of this value will be in form of array.
So select array and under array.
It is a collection or bundle of texts.
So we'll select collection and under specification,
we'll start our start date and end date.
So we can simply write this as start date, start time whatever you like even start.
But we have to change the type to date format.
Awesome.
Then we have to do the same from end date.
We will say end only and let us change the type to date.
And you don't have to play around with any of these.
Simply click on save. Under value,
We have to actually add the value from the iterator, so it is not available right now.
So click on this advanced map and simply select the value of iterator.
Amazing.
Click on okay.
Both of these model will consist of 5 available time slot.
Or if there are let's say 3 to 4 available time slot, it will show 3 to 4 only and not 5.
So we need to actually convert this into proper format of an speech or proper format of text.
So we will use ChatGPT or OpenAI model.
Click on OpenAI.
And then again we are completing our chat.
We will use the model GPT-4o whatever you like.
And again under messages, we will have 2 roles, system role and user role.
Select system for the first one and under message content we will say you will be provided with a busy
slot from calendar.
Your task is to list the available times between 9 a.m. and 5 p.m.
After extracting the busy slot, just output the available time and date.
I hope you got my point.
What I am trying to say here is from this message content.
What we are trying to say is extract the busy slot which is for example 1 p.m. and just output the available
time and date and don't output 1 p.m. because it is already booked and here we have rules, so feel
free to play around with this.
Then simply we have to add another message for user.
For user, what we are going to use in message content?
Because what we have said in system that, let's say 1:00 pm was booked.
So whenever the user say, I want to book an appointment at 1:00 PM, so our message content will say
like these are the book slot or the slot that are already booked.
And how do we know what slot are busy or not.
So we will use our JSON string for that response.
After that, we can also add each start and end pair represent one busy slot, for example 9 a.m. to
10 a.m..
I hope this makes sense.
And from maximum token we can say 250 to 300, whatever you like.
All right then click on okay.
Lastly, we are going to use a webhook to actually send the information back to our Vapi dashboard,
click on add another module.
Then copy our code from the server response. Under body paste this,
Click on ID and in result, we will say these are the slots that are available.
These are the available slots.
And then we will add that available slot.
So how do we find this?
Again we are going to use our openAI content message response.
So under choices, under messages,
And we will select the content and make sure that we are using this openAI model for this response
and not the first one.
Amazing.
Click on save.
Finally, we are done with our scenario.
You should be proud of yourself from making this scenario from scratch as well as you can import the
blueprint.
Now let us actually test our a scenario.
Go back to dashboard and let us call our favorite person Mary.
Before that, make sure your scenario is running on.
Hello, this is Mary from Mary's Dental.
Hi, Mary.
Hey there.
I'm doing great.
Thanks for asking.
How can I help you today?
Can you book an appointment for me?
Sure thing.
What's your full name?
My name is John Cena.
Nice to meet you, John Cena.
What's the purpose of your appointment?
I cannot see my teeth.
Got it.
John, when would you like to come in?
Let's say day after tomorrow.
Give me a moment.
All right, John, her's some available time:- 9 a.m., 10 a.m., 12 p.m., 1 p.m. and 3 p.m..
Which one works for you?
Yeah, let me just check.
Congratulations, guys.
This scenario is working perfectly.
And don't worry about this error.
It is actually an error of booking an appointment.
Here, what we have done in this scenario is we are just checking the availability from our calendar, and
we are yet to set up another scenario to book an appointment from our calendar.
Here we are just checking that.
So all we need to do is create another scenario to book an appointment, which is very small scenario.
Don't worry about that.
Go to your new scenario and let us say book appointment.
Go to our custom.
We will say book an appointment.
Then click on save copy this URL.
Then we have to actually create another tool to book the appointment for the user.
Go to Vapi dashboard, click on tools,
Click on Create New tool, in Make, paste our server URL.
Next, we need to store all of the information of our user.
Under our schema, we are actually storing a lot of properties.
For example name of our user, then email of our user, the appointment booking date as well as appointment
booking time.
Even you can also add the purpose of the booking, but I am not going to add this because it will make
the lecture lengthy.
So we will say name, under description,
We will say name of the user, simple as that.
Then email, and email of the user, then the date of the appointment and in the description we will say
date of the appointment from the date that the user has called.
After that, we have to add the start timing of our meeting.
So under property we will say start time.
Under description there is the twist,
We have to actually use the format of the start timing so that our schema or our tool will know how
to format their structure.
We will say start time of the slot you want to book, and the date and the time should be in the format
like this as an example.
So go back to our make, go to our OpenAI.
And as you can remember from the output example, we can copy this format as well as it will also include
our time zone.
Then paste here, click on save.
And that's all we need to do.
We can name this tool as book_appointment and under description, we can say use this tool to book_appointment
after checking the availability, then create.
After creating our new tool, we have to actually add in the assistant.
So go to Mary, under functions,
We will also select our book appointment, then hit publish. Now we have to set up the scenario to book
appointment in Make.com.
We have to add our Google Calendar in order to book the appointment, search Google Calendar and we
are actually creating an event for our appointment.
So we will use create an event.
Connect your Google account and under calendar ID you will select yours.
And then in here, event name.
We don't have any variable as of now.
So we have to make a call first of all to trigger our new tool.
So we can simply just delete all of this.
Yes.
Delete this module.
Click on save.
Click run once and we have to run this as well.
Go back to your Vapi dashboard.
Talk with our friend Mary.
First this scenario will get active and after that this will.
Hello, this is Mary from Mary's Dental.
Hi.
I want to book an appointment.
And my name is Manthan.
Nice to meet you,
Manthan.
What's the purpose of your appointment?
I want to clean my teeth.
Got it.
When would you like to come in?
Tomorrow.
All right.
Let me check the available times for tomorrow.
One sec.
Hold on a second.
Here are five available times for tomorrow.
9 a.m., 10 a.m., 11 a.m., 1 p.m., 2 p.m..
Which one works for you?
Yeah.
I will book my appointment at 9 a.m..
All right.
Manthan, can I have your email to confirm the appointment?
Yeah, my email is john1234@gmail.com.
Give me a moment.
Thank you very much.
All right manthan.
After we have provided our email and all of the property has been filled, it has triggered
our new tool.
And under message toolwithtoolcallList
You will be able to find all of the information.
I know it has spelled my name wrong, but sometime due to Indian accent this can happen.
So again we will create a Google calendar.
Select your ID and event name.
We have all of the variables and information, so we can say meeting with-
We can add the name of the person or the client.
So under tool with call to list tool call function and the arguments you will be able to find name.
We can use this name and feel free to customize because it is like your choice and your preference.
And for start date which is actually very necessary, we will simply select our start time.
Awesome.
Just like that.
And then the minute or duration of our meeting could be in format of hour and minute.
We will say we will have one hour meeting or appointment, and you don't need to add the end date because
it is but obvious.
Then let us configure our meeting furthermore.
Click on this show advanced setting and here we will have description, location, etc.
So in description you can see the name of the person is this and the email of the person is this.
We will say name, select this name and then email which is important to us and we will select the email
and that's how the meeting description will be get.
Then you can add the location.
You can add reminders as well and let us add attendees for name.
We will select the name again and the email again.
So our client will get the information in email about the meeting as well as into the calendar.
Show me as Busy, etc.
Feel free to modify as per your liking.
Like example,
Send notification about the event creation.
We can say to
All Guest.
All right, that's all.
So click on okay.
And then we have to actually send the response back to our Vapi assistant via a webhook.
Create webhook again go to Vapi Documentation.
Copy this.
Come back to our make paste it here, in toolID we will select our toolID.
And the toolcall select ID and the result,
We will finally say you have successfully booked the appointment.
The appointment was booked successfully at -
And then we can also add the timing.
You can do the customization as per your liking. Under function, under arguments,
We can select the start time, then click on okay.
Now save this and let us check if this is working or not.
Click on run once.
This is my Google calendar and you can see there are no events right now.
Let us go back to our assistant and have a talk.
Great choice.
Could I get your email to confirm the appointment?
Yeah, my email is manthanp037@gmail.com.
All set John on your cleaning appointment is booked for 11 a.m. the day after tomorrow.
See you then.
So it wasn't able to book any appointment and we have found out the bug which is we haven't actually
set the start time or time minimum perfectly.
So as you can see, there is no value.
So let us configure this.
Here you can see the start time we are using is this one which is empty