VAPI.ai Integration
Voice Agents use artificial intelligence or machine learning technologies. As you integrate with any 3rd party AI/ML service provider, you must make yourself aware of the services' privacy and security policies. Cloudonix will not be liable for any damages incurred to you or your customers, in relation to the usage of 3rd party AI/ML services via the Cloudonix platform.
Introduction
What is a Voice Agent?
To explain what a Voice Agent is, let's ask the agent itself - via ChatGPT:

While Alexa and Siri hold their grounds as the pioneers of the Voice Agent era, today, Voice Agents are mostly related to AI based agents that use phone calls to communicate with customers. A Voice Agent can be used for customer care, lead prospecting, cold calling and even providing basic health related services—as AI advances and language models improve, Voice Agents become more "human like", providing a seamless experience for customers.
What is VAPI.ai?
VAPI.ai is a Voice Agent platform, that enables its customers to build Voice Agent experiences in an easy and affordable manner. While there are multiple Voice Agent platform vendors, such as synthflow, retell and others, we've decided to provide a tutorial for VAPI.ai, as the over all process for these is identical.
To work, a VAPI assistant requires a phone number. You may purchase phone numbers from VAPI via their service, however, to integrate your own phone numbers or on-premise PBX with VAPI using Cloudonix, no phone number purchase is required on VAPI. Simply use the VAPI API to 'declare' your desired phone number to VAPI, and that's it.
Follow this link to the VAPI API page on creating phone numbers.
Examples
The following assumes that you already have an existing phone number assigned to your VAPI voice agent. For a more detailed guide, about Cloudonix/VAPI SIP trunking, please refer to the VAPI.ai SIP Trunking Guide.
Inbound Calling
The following CXML code will route and inbound call to VAPI.ai, to a predefined phone number. The code below assumes that the phonenumber (eg. +12127773456) used and the VAPI.ai assistant are already fully provisioned.
<Response>
<Dial>
<Service provider="vapi">+12127773456</Service>
</Dial>
</Response>
Adding Variables
To pass variables (or Template Variables as VAPI calls them) to VAPI, we are required to add SIP Headers to our outbound
call to VAPI. To do so, we'll use the Cloudonix <Header>
noun, as part of our <DIAL>
operation. Learn more about
VAPI Template Variables here.
To send a Template Variable named fullname
, you will need to add a Header called X-fullname
. Pay attention that
Header names may only use alphanumeric characters and underscore (_).
<Response>
<Dial>
<Header name="X-first_name" value="Andrew"/>
<Header name="X-last_name" value="Higgins"/>
<Header name="X-birthdate" value="1974-04-15"/>
<Service provider="vapi">+12127773456</Service>
</Dial>
</Response>