Vapi offers two main features that provide enhanced control over live calls:
To use these features, you first need to obtain the URLs specific to the live call. These URLs can be retrieved by triggering a /call endpoint, which returns the listenUrl and controlUrl within the monitor object.
To initiate a call and retrieve the listenUrl and controlUrl, send a POST request to the /call endpoint.
Once you have the controlUrl, you can use various control features during a live call. Here are all the available control options:
Makes the assistant say a specific message during the call.
Adds a message to the conversation history and optionally triggers a response.
Control the assistant’s behavior during the call.
Programmatically end the ongoing call.
Transfer the call to a different destination.
You can also transfer to a SIP URI:
Handoff the call to a different assistant.
The listenUrl allows you to connect to a WebSocket and stream the audio data in real-time. You can either process the audio directly or save the binary data to analyze or replay later.
Here is a simple implementation for saving the audio buffer from a live call using Node.js: