Outbound Calling
Quickstart sending outbound calls with Vapi.
An outbound call is a phone call that is dialed and goes “out” from a phone number, & in our case, our AI assistant will be doing the dialing.
There are 3 steps we will cover to send our first outbound phone call:
- Create an Assistant: we will create an assistant & instruct it on how to conduct itself during the call
- Get a Phone Number: we can either import existing numbers we own, or purchase one through Vapi
- Call Your Number: we will set our assistant as the dialer, set the destination phone number, then make the call
We can then send the outbound call, hopefully someone picks up!
It is a violation of FCC law to dial phone numbers without consent in an automated manner. See Telemarketing Sales Rule to learn more.
Vapi’s Pizzeria
We will be implementing a simple order-taking assistant for a pizza shop called “Vapi’s Pizzeria”.
Vapi’s has 3 types of menu items: pizza
, side
s, & drink
s. Customers will be ordering 1 of each.
Outbound Scenario: We will imagine we are calling back a customer who originally called in to place an order. Our assistant is calling back to complete the ordering process with the customer.
Assistant Setup
First we’re going to set up our assistant in the dashboard. Once our assistant’s transcriber, model, & voice are set up, we can have it call the customer to finish the order.
You can visit your dashboard by going to dashboard.vapi.ai
Sign-up or Log-in to Vapi
If you haven’t already signed-up, you’re going to need an account before you can use the web dashboard. When you visit dashboard.vapi.ai you may see something like this:
Sign-up for an account (or log-in to your existing account) — you will then find yourself inside the web dashboard. It will look something like this:
Create an Assistant
Now that you’re in your dashboard, we’re going to create an assistant.
Assistants are at the heart of how Vapi models AI voice agents — we will be setting certain properties on a new assistant to model an order-taking agent.
Once in the “Assistants” dashboard tab (you should be in it by-default after log-in), you will see a button to create a new assistant.
After clicking the create new assistant button, you will see a pop-up modal that asks you to pick a starter template. For our example we will start from a blank slate so choose the Blank Template
option.
You will then be able to name your assistant — you can name it whatever you’d like (Vapi’s Pizza Front Desk
, for example):
This name is only for internal labeling use. It is not an identifier, nor will the assistant be aware of this name.
Once you have named your assistant, you can hit “Create” to create it. You will then see something like this:
This is the assistant overview view — it gives you the ability to edit different attributes about your assistant, as well as see cost & latency projection information for each portion of it’s voice pipeline (this is very important data to have handy when building out your assistants).
Model Setup
Now we’re going to set the “brains” of the assistant, the large language model. We’re going to be using GPT-4
(from OpenAI) for this demo (though you’re free to use GPT-3.5
, or any one of your favorite LLMs).
Set Your OpenAI Provider Key (optional)
Before we proceed, we can set our provider key for OpenAI (this is just your OpenAI secret key).
You can see all of your provider keys in the “Provider Keys” dashboard tab. You can also go directly to dashboard.vapi.ai/keys.
Vapi uses provider keys you provide to communicate with LLM, TTS, & STT vendors on your behalf. It is most ideal that we set keys for the vendors we intend to use ahead of time.
While we’re here it’d be ideal for you to go & set up provider keys for other providers you’re familiar with & intend to use later.
Set a First Message
Assistants can optionally be configured with a First Message
. This first message will be spoken by your assistant when either:
- A Web Call Connects: when a web call is started with your assistant
- An Inbound Call is Picked-up: an inbound call is picked-up & answered by your assistant
- An Outbound Call is Dialed & Picked-up: an outbound call is dialed by your assistant & a person picks up
Note that this first message cannot be interrupted & is guaranteed to be spoken. Certain use cases need a first message, while others do not.
For our use case, we will want a first message. Since we are calling the customer back it would be ideal for us to have a first message like this:
Some text-to-speech voices may struggle to pronounce ‘Vapi’ correctly, compartmentalizing it to be spoken letter by letter “V. A. P. I.”
Some aspects of configuring your voice pipeline will require tweaks like this to get the target behaviour you want.
This will be spoken by the assistant when a web or inbound phone call is received.
Set the System Prompt
We will now set the System Prompt
for our assistant. If you’re familiar with OpenAI’s API, this is the first prompt in the message list that we feed our LLM (learn more about prompt engineering on the OpenAI docs).
The system prompt can be used to configure the context, role, personality, instructions and so on for the assistant.
Since we are calling the customer back, we will tweak the base prompt a bit so the model understands the situation & new goal (recovering the order).
A system prompt like this will give us the behaviour we want:
You can copy & paste the above prompt into the System Prompt
field. Now the model configuration for your assistant should look something like this:
Transcriber Setup
The transcriber is what turns user speech into processable text for our LLM. This is the first step in the end-to-end voice pipeline.
Set Your Deepgram Provider Key (optional)
We will be using Deepgram (which provides blazing-fast & accurate Speech-to-Text) as our STT provider.
We will set our provider key for them in “Provider Keys”:
Set Transcriber
We will set the model to Nova 2
& the language to en
for English. Now your assistant’s transcriber configuration should look something like this:
Voice Setup
The final portion of the voice pipeline is turning LLM output-text into speech. This process is called “Text-to-speech” (or TTS for short).
We will be using a voice provider called PlayHT (they have very conversational voices), & a voice provided by them labeled Jennifer
(female
, en-US
).
You are free to use your favorite TTS voice platform here. ElevenLabs is another alternative — by now you should get the flow of plugging in vendors into Vapi (add provider key + pick provider in assistant config).
You can skip the next step(s) if you don’t intend to use PlayHT.
Set Your PlayHT Provider Key (optional)
If you haven’t already, sign up for an account with PlayHT at play.ht. Since their flows are liable to change — you can just grab your API Key
& User ID
from them.
Set Voice
You will want to select playht
in the “provider” field, & Jennifer
in the “voice” field. We will leave all of the other settings untouched.
Get a Phone Number
Now that we’ve configured how our assistant will behave, we want to figure out how to dial calls with it. We will need a phone number that we can call from.
There are 2 ways we can get a phone number into our Vapi account:
-
Purchase a Number Through Vapi: we can directly purchase phone numbers through Vapi.
- Vapi will provision the phone number for us via Twilio
- This can be done in the dashboard, or via the API (we will use the dashboard)
-
Import from Twilio or Vonage: if we already have a phone number with an external telephony provider (like Twilio or Vonage), we can import them into our Vapi account.
Provision via Vapi (faster)
The quickest way to secure a phone number for your assistant is to purchase a phone number directly through Vapi.
Ensure you have a card on file that Vapi can bill before proceeding, you can add your billing information in your dashboard at dashboard.vapi.ai/billing
Navigate to the “Phone Numbers” section & click the “Buy number” button:
We will use the area code 415
for our phone number (these are area codes domestic to the US & Canada).
Currently, only US & Canada phone numbers can be directly purchased through Vapi. Phone numbers in other regions must be imported, see our phone calling guide.
Click “Buy”, after purchasing a phone number you should see something like this:
The phone number is now ready to be used (either for inbound or outbound calling).
Import from Twilio or Vonage
We can also import an existing phone number we already own with either Twilio or Vonage.
For example’s sake, we will proceed with Twilio (though the steps are the same for Vonage as well).
Buy a Phone Number via Twilio (optional)
If you don’t already have a number in Twilio, you can purchase one by going to your Twilio console’s “Buy a number” section:
Once you’ve purchased a number, it will immediately be ready for import into Vapi.
Locate Twilio Account SID & Auth Token
To complete the import on Vapi’s side, we will need to grab our Twilio “Account SID” & “Auth Token”.
You should see a section for “API keys & tokens”, the credentials we will need for the import will live here.
Once we are in our “API keys & tokens” section, we will grab the Account SID & Auth Token:
We will use both of these credentials in the next step of importing via the Dashboard.
Import via Dashboard
Navigate to the “Phone Numbers” section & click the “Import” button:
There you will input your phone number, as well as the credentials you retrieved in the previous step:
Hit “Import” & you will come to the phone number detail page:
Your number is now ready to be attached to an assistant for inbound or outbound phone calling.
Call Your Number
We can now make outbound calls to phone numbers, setting our assistant as the one doing the dialing.
In the phone numbers section of the dashboard, go to your phone number detail page. We will:
- fill out our own phone number as the number to dial
- set our assistant as the one doing the calling
You can now hit the call button to make the outbound call. Your assistant will dial the phone number & manage the order recovery process.
Your assistant won’t yet be able to hang-up the phone at the end of the call. We will learn more about configuring call end behaviour in later guides.