Create an assistant
Weβll start by taking a look at the Assistant API
reference and define our
assistant:Letβs break this down:
transcriber- Weβre defining this to make sure the transcriber picks up the custom word βBickyβmodel- Weβre using the OpenAI GPT-4 model, which is better at function calling.messages- Weβre defining the assistantβs instructions for how to run the call.functions- Weβre providing a bookAppointment function with a datetime parameter. The assistant can call this during the conversation to book the appointment.voice- Weβre using the Onyx voice from OpenAI.forwardingPhoneNumber- Since weβve added this, the assistant will be provided the transferCall function to use.voicemailMessage- If the call goes to voicemail, this message will be played.firstMessage- This is the first message the assistant will say when the user picks up.endCallMessage- This is the message the assistant will deciding to hang up.endCallFunctionEnabled- This will give the assistant the endCall function.recordingEnabled- Weβve disabled recording, since we donβt have the userβs consent to record the call.
Buy a phone number
Weβll buy a phone number for outbound calls using the Phone Numbers API.Great, letβs take note of that
id field- weβll need it later.Configure your Server URL
When the assistant calls that
bookAppointment function, weβll want to handle that function call and actually book the appointment. We also want to let the user know if booking the appointment was unsuccessful.First, weβll create an endpoint on our server for Vapi to hit. Itβll receive messages as shown in the Function Calling docs. Once created, weβll add that endpoint URL to the Server URL field in the Account page on the Vapi Dashboard.Handle function calls
So now, when the assistant decides to call Weβll do our own logic to book the appointment, then weβll respond to the request with the result to let the assistant know it was booked:or, if it failed:So, when the assistant calls this function, these results will be appended to the conversation, and the assistant will respond to the user knowing the result.Great, now weβre ready to start calling leads!
bookAppointment, our server will get something like this:Place a call
Weβll use the Create Phone Call endpoint to place a call to a lead:Since we also defined a
forwardingPhoneNumber, when the user asks to speak to a human, the assistant will transfer the call to that number automatically.We can then check the Dashboard to see the call logs and read the transcripts.
