Scheduling Appointments via SMS using Vapi
I have seen that many people on Discord face difficulties setting up appointments using Vapi. Therefore, I'll provide a tutorial to help you schedule meetings effectively and ensure it's ready for production.
One disadvantage of this method is that you may need to handle the entire process via voice call. Issues might arise in getting the data correctly formatted. For instance, you may have encountered problems like the Large Language Model (LLM) being unable to identify today's date, or failing to collect data accurately for use in custom functions. Sometimes, the synthesiser speaks too quickly when announcing available time slots, among other issues.
However, this method will enable you to schedule meetings without errors. Since it's manually done by users, your only task will be to send the message with the meeting link.
Tools which we will be using to achieve it:
Vapi
Pipedream
Twilio
Calendly
Step-by-Step Guide to Setup the Scheduling Appointments via SMS using Vapi:
If you are already familiar with Vapi or used it before then you might know what my next step will be it is simply to add System Prompt and custom functions. Apart from it, you can select the best LLM Models (GPT 4 is usually the best choice in most of the cases), Transcriber and Voice.
System Prompt:
When the user needs to schedule a meeting, you will execute the schedule_meeting function with the parameter phone_number, which contains the phone number from the user details section.
[User Details]
Phone Number: {phone_number}

Create a new workflow with the name schedule_meeting and then change the Event Data to HTTP body only and HTTP Response to be Return a custom response from your workflow.

Now, we need to setup the calendly account and connect it via Pipedream using create scheduling link action in calendly. After, this you need to connect your calendly account and then select the meeting link followed by this you need to provide how many times a user can use this link to book the meeting. After doing this all it will look something like this

Now, press test and then create a new flow related to sending sms using twilio and connect your account and fill the complete details you want to send the message from which number and to whom (you will get this data from the custom function call) leave this part for now we will setup while configuring our function call in vapi. Also, setup the message body by click on copy path on the booking_url and setup the your message followed by pass the booking_url by the path that you copied. After all this, It will look like this after it is

Now, finally setup one more flow of HTTP response data and then copy and paste this JSON data. After this it will look like this

Now, let's set the function call on our Vapi Dashboard by going to vapi dashboard then to functions and create a new functions and put all these details as given below.
fuction_name: schedule_meeting
description: Schedule a meeting by sending a Calendly invite link via SMS.
Parameters: phone_number
description: User's phone number, including the country code
Server URL: https://eotukmj0fohftzu.m.pipedream.net (Replace it with your URL which you got at the starting of the schedule_meeting flow)
After this it will look something like this

Now, click on the setup pipedream and use this sample payload
{
"phone_number": "+14154232938"
}
and click on the test button

Now, you will get a request on the Pipedream of how your HTTP body will look like when a user wants to schedule a meeting. After this go to the pipedream then select that post request and you will have the access to the phone number. It will look something like this

Now, finally add the customer phone number where you want to send the data using this data. After setting up it will look something like this

Now, just press deploy button and let move to the next step which is to import the twilio phone number for inbound call
After this, go to the phone number import your number fill all your necessary data and import your number.

Now, these parts must be pretty clear but you might be wondering why you put {phone_number} in this way and how we are going to get the phone number of the user.
Well, to do this we need to set up an assistant with a URL. Why? Basically, I am currently setting up this flow for the inbound call which means when someone calls to your bot number. For outbound call, you just need to configure it via /call api endpoint and pass the phone_number directly through Pipedream from your CRM tool.
Now, let's create workflow for the inbound call in Pipedream and plug in the webhook URL in the dashboard.
Create a new workflow with the name inbound call and then change the Event Data to HTTP body only and HTTP Response to be Return a custom response from your workflow. After the press continue and you will get a webhook url. You need to copy it

Now go to settings and add your Server URL

After this whenever you will call to your bot number which is the Twilio number that you setup you will get a request in your pipedream server which will contain the user details.
Now call your bot number with your other number so that you can see the request payload in the pipedream setup. Also, add the return http response flow after this It will look like this

After this, just click on the return_http_response configure and paste this below code but make sure to change the schedule_meeting url with your pipedream url.
{
"assistant": {
"name": "Schedule Meeting",
"voice": {
"voiceId": "jennifer",
"provider": "playht"
},
"model": {
"model": "gpt-4",
"messages": [
{
"role": "system",
"content": "When the user needs to schedule a meeting, you will execute the schedule_meeting function with the parameter phone_number, which contains the phone number from the user details section.\n\n[User Details]\n\nPhone Number: {phone_number}"
}
],
"provider": "openai",
"functions": [
{
"name": "schedule_meeting",
"async": false,
"serverUrl": "https://eotukmj0fohftzu.m.pipedream.net",
"parameters": {
"type": "object",
"properties": {
"phoneNumber": {
"type": "string",
"description": "User's phone number, including the country code"
}
}
},
"description": "Schedule a meeting by sending a Calendly invite link via SMS.",
"serverUrlSecret": ""
}
],
"maxTokens": 250,
"temperature": 0.7
},
"recordingEnabled": true,
"firstMessage": "",
"voicemailMessage": "",
"endCallFunctionEnabled": false,
"endCallMessage": "",
"transcriber": {
"model": "nova-2",
"language": "en",
"provider": "deepgram"
},
"clientMessages": [
"transcript",
"hang",
"function-call",
"speech-update",
"metadata",
"conversation-update"
],
"serverMessages": [
"end-of-call-report",
"status-update",
"hang",
"function-call"
],
"dialKeypadFunctionEnabled": false,
"hipaaEnabled": false
}
}
After this, it will look something like this

Now press deploy and Voila it is done. Now, you can call on your number and schedule the meeting.
