Live Call Control
Vapi offers two main features that provide enhanced control over live calls:
- Call Control: This feature allows you to inject conversation elements dynamically during an ongoing call.
- Call Listen: This feature enables real-time audio data streaming using WebSocket connections.
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.
Obtaining URLs for Call Control and Listen
To initiate a call and retrieve the listenUrl
and controlUrl
, send a POST request to the /call
endpoint.
Sample Request
Sample Response
Call Control Feature
Once you have the controlUrl
, you can inject a message into the live call using a POST request. This can be done by sending a JSON payload to the controlUrl
.
Example: Injecting a Message
The message will be spoken in real-time during the ongoing call.
Call Listen Feature
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.
Example: Saving Audio Data from a Live Call
Here is a simple implementation for saving the audio buffer from a live call using Node.js: