Dynamic Call Transfers
Introduction to Transfer Destinations
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.
Step 1: Create a Custom Transfer Tool
To get started, create a transfer tool with an empty destinations
array:
This tool acts as a placeholder, allowing dynamic destinations to be defined at runtime.
Step 2: Link the Tool to Your Assistant
After creating the tool, link it to your assistant. This connection enables the assistant to trigger the tool during calls.
Step 3: Configure the Server Event
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.
Step 4: Set Up Your Server
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.
Step 5: Trigger the Tool and Process Requests
Use the following prompt to trigger the transfer tool:
When triggered, the assistant sends a transfer-destination-request
webhook to your server. This webhook contains all the necessary call details, such as transcripts and messages, allowing your server to process the request dynamically.
Sample Request Payload:
Step 6: Respond to Transfer Requests
Your server should respond with either a valid destination
or an error
to indicate why the transfer cannot be completed.
Transfer Destination Request Response Payload
Number Destination
Transfers the call to a specific phone number, with options for caller ID and extensions.
SIP Destination
Transfers the call to a SIP URI with optional custom headers.
Error Response
If the transfer cannot be completed, respond with an error:
- Field:
error
- Description: Provides a clear reason why the transfer failed.
Destination or Error in Response
Every response to a transfer-destination-request must include either a destination
or an error
. These indicate the outcome of the transfer request:
- Destination: Provides details for transferring the call.
- Error: Explains why the transfer cannot be completed.
Conclusion
Dynamic call transfers empower your assistant to route calls efficiently based on real-time data. By implementing this flow, you can ensure seamless interactions and provide a better experience for your users.