Transferring calls dynamically based on context is an essential feature for handling user interactions effectively. This guide walks you through creating a custom transfer tool, linking it to your assistant, and handling transfer requests with detailed examples. Whether the destination is a phone number, SIP, or another assistant, you'll learn how to configure it seamlessly.
To get started, create a transfer tool with an empty destinations
array:
curl -X POST <https://api.vapi.ai/tool> \\
-H "Authorization: Bearer insert-private-key-here" \\
-H "Content-Type: application/json" \\
-d '{
"type": "transferCall",
"destinations": [],
"function": {
"name": "dynamicDestinationTransferCall"
}
}'
This tool acts as a placeholder, allowing dynamic destinations to be defined at runtime.
After creating the tool, link it to your assistant. This connection enables the assistant to trigger the tool during calls.
Select the transfer-destination-request
server event in your assistant settings. This event sends a webhook to your server whenever a transfer is requested, giving you the flexibility to dynamically determine the destination.
Ensure your server is ready to handle incoming requests. Update the assistant's server URL to point to your server, which will process transfer requests and respond with the appropriate destination or error.
Use the following prompt to trigger the transfer tool: