Modify TransferCall Function During Call Based on ...
# support
g
is there any chance to modify the transfercall during the live call after i retrieve some information from a function, this is what happens, i get calls to retrieve information about. a client, we have multiple centers, so based on the client they retrieve information from i want to modify the transfer number to is it possible?? { "type": "transferCall", "destinations": [ { "type": "number", "number": "NEED TO MODIFY THIS NUMBER HERE DURING LIVE CALL", "message": "I am forwarding your call to a representative that will help. Please stay on the line." } ], "function": { "name": "transferCall", "description": "Use this function to transfer the call. Only use it when following instructions that explicitly ask you to use the transferCall function. DO NOT call this function unless you are instructed to do so.", "parameters": { "type": "object", "properties": { "destination": { "type": "string", "enum": [ "NEED TO MODIFY THIS NUMBER HERE DURING LIVE CALL" ], "description": "The destination to transfer the call to." } }, "required": [ "destination" ] ......
@Vapi Support Bot @Vapi
s
You need to modify the transfer call destination number dynamically during a live call after retrieving information about a client. Since you have multiple centers, you want to route clients to the correct destination based on their information. ## Solution Overview VAPI offers a "transfer destination request" event that solves this exact problem. When selected, this event makes VAPI send a request to your server when a transfer is needed, allowing you to dynamically determine the destination number based on your business logic. ## Step-by-Step Implementation ### Step 1: Configure the Transfer Destination Request Event 1. Go to your assistant settings in the VAPI dashboard 2. Locate the "Events" or "Webhooks" section 3. Add a new event handler 4. Select the "transfer-destination-request" event type 5. Enter the URL of your server endpoint that will handle this request 6. Save your configuration ### Step 2: Understanding the Process Flow When a call transfer is initiated during a live call: 1. The assistant invokes the transferCall function 2. VAPI detects this is an assistant with the "transfer-destination-request" event configured 3. VAPI makes an HTTP POST request to your server URL with details about the call and client 4. Your server determines the appropriate destination based on the client information 5. Your server responds with the destination details 6. VAPI completes the transfer to the dynamic destination you specified ### Step 3: Server Response Format Your server must return a JSON response with either a destination or an error: #### Successful Response with Phone Number Destination:
Copy code
json
{
  "destination": {
    "type": "number",
    "number": "+15551234567",
    "message": "I am transferring you to our specialist. Please hold."
  }
}
#### Successful Response with SIP Destination:
Copy code
json
{
  "destination": {
    "type": "sip",
    "sipUri": "sip:user@example.com",
    "message": "I am transferring you to our specialist. Please hold."
  }
}
#### Error Response:
Copy code
json
{
  "error": "Unable to determine transfer destination at this time."
}
## Request Format from VAPI to Your Server For reference, here's what the request from VAPI to your server will look like:
Copy code
json
{
  "type": "transfer-destination-request",
  "timestamp": "2023-05-25T15:30:45.123Z",
  "call": {
    "callId": "call_123456789",
    "phoneNumber": "+11234567890",
    "orgId": "org_123456789",
    // Other call details
  },
  "customer": {
    "customerId": "cust_123456789",
    "name": "John Doe",
    "phoneNumber": "+19876543210",
    // Other customer details
  },
  "assistant": {
    "assistantId": "asst_123456789",
    "name": "Customer Service Bot",
    // Other assistant details
  },
  "artifact": {
    // Call artifact containing conversation history, etc.
  }
}
With this implementation, you'll be able to dynamically route calls to different centers based on client information during a live call.
g
in the prompt, the situation is the same, just say use transfercall() tool, correct?
@Shubham Bajaj im struggling, when using this dinamictransfer option, the transfer does not happen unless the person says a 2nd time, look some example, as you can see it jumps into the idlemessage { "role": "bot", "time": 1742428032825, "source": "", "endTime": 1742428039125, "message": "I can help with that. Would you like me to transfer you to a representative who can assist you further?", "duration": 5600, "secondsFromStart": 244.9 } { "role": "user", "time": 1742428041235, "endTime": 1742428041555, "message": "Yes.", "duration": 320, "secondsFromStart": 253.31 } { "role": "bot", "time": 1742428043145, "source": "", "endTime": 1742428062105.02, "message": "Thank you for your patience. I'll transfer you to a representative who can help you. Please stay on the line. I'm still here if you need assistance.", "duration": 7440.030029296875, "secondsFromStart": 255.22 } { "role": "user", "time": 1742428064654.98, "endTime": 1742428066015, "message": "You haven't transferred me.", "duration": 1360.02001953125, "secondsFromStart": 276.72998 } { "role": "tool_calls", "time": 1742428066150, "message": "", "toolCalls": [ { "id": "call_87JeIbSjvBzPHxinvlm0wXAb", "type": "function", "function": { "name": "dynamicDestinationTransferCall", "arguments": "{}" } } ], "secondsFromStart": 278.047 } { "role": "bot", "time": 1742428067965, "source": "", "endTime": 1742428069245, "message": "Transferring the call now.", "duration": 1280, "secondsFromStart": 280.04 } { "name": "dynamicDestinationTransferCall", "role": "tool_call_result", "time": 1742428068474, "result": "Success.", "toolCallId": "call_87JeIbSjvBzPHxinvlm0wXAb", "secondsFromStart": 280.371 }
k
@gzqq To help track down this issue, could you share: - The call ID This would really help us figure out what went wrong!
g
Mark as solved, you recommendation worked, I’m capturing the server side event and deciding with results of previous function tools used during the call thru the artifacts. Thanks @Shubham Bajaj anyways in order to get the tools to execute as instructed I had to move from 4o-mini to 4o
But that’s not related to the transfer destination request.
k
Thanks @gzqq for letting me know and correcting me. Now I am marking this ticket as resolved. Let me know if you have more questions or require further help. Feel free to reach out.