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 Features
Once you have the controlUrl
, you can use various control features during a live call. Here are all the available control options:
1. Say Message
Makes the assistant say a specific message during the call.
2. Add Message to Conversation
Adds a message to the conversation history and optionally triggers a response.
3. Assistant Control
Control the assistant’s behavior during the call.
4. End Call
Programmatically end the ongoing call.
5. Transfer Call
Transfer the call to a different destination.
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: