Forwarding to dynamic numbers
# support
a
I have an assistant which sends a tool request to check if agents are available in 2 call centers. Depending on the logic , I want to forward call to a different number. Sometimes its call center 1 , sometimes its call center 2 I am tried giving response like this to tool call >
Copy code
{
>   "results": [
>     {
>       "toolCallId": "call_KKU9ZwnXVWDPdWDXRY5KR2Lj",
>       "result": "We have agents available. transferCall  to  +16022291133"
>     }
>   ]
> }
But its not transfering call to the number i give It just transfers to forwarding number which i set in the UI of assistant .. How can I transfer call based on my serverlogic when a tool call comes in to my server ?
v
@Aby It sounds like you're trying to dynamically route calls based on the availability of agents in different call centers. To achieve this, you'll need to implement logic on your server that can interpret the results of the tool request and then trigger the appropriate
transferCall
function with the correct phone number. When your server receives a tool call and determines which call center to forward the call to, you should not respond with a string message as you've shown. Instead, you should invoke the
transferCall
function programmatically with the appropriate phone number based on your server's logic. Here's what you need to do: 1. Check the availability of agents in both call centers. 2. Based on the availability, decide which call center to forward the call to. 3. Use the
transferCall
function with the chosen phone number. For example, if your server logic determines that the call should be forwarded to call center 1, you would use the
transferCall
function with the phone number for call center 1. If the call should be forwarded to call center 2, you would use the phone number for call center 2. If you can provide me with the condition that determines whether to forward to call center 1 or call center 2 (for example, if X condition is met, forward to call center 1; if Y condition is met, forward to call center 2), I can help you with the exact function call.
You can continue this conversation by mentioning me in the message.
a
@Vapi how can i invoke the transferCall function from my server if its not done via the response of tool call ?
v
@Aby To invoke the
transferCall
function from your server, you would typically need to use the API provided by the voice platform (VAPI) to send a command back to the system that is handling the call. However, since you're working with an assistant that uses tools, you should respond to the tool call with a structured command that the assistant can understand and act upon. Here's a general approach to how you can structure your server's response to trigger a call transfer: 1. Your server logic determines which call center to transfer the call to based on agent availability. 2. Instead of sending a plain text response, your server should send a structured JSON response that includes the action to be taken (e.g.,
transferCall
) and the necessary parameters (e.g., the phone number to transfer the call to). The response from your server might look something like this:
Copy code
json
{
  "action": "transferCall",
  "parameters": {
    "phoneNumber": "+16022291133" // or the number for call center 2
  }
}
3. The assistant receives this response and uses the provided action and parameters to invoke the
transferCall
function. If you're using a specific API or platform, there may be additional steps or a specific format required for the response. Please check the documentation for the voice platform you're using to ensure you format the response correctly. If you need further assistance with the specific syntax or method to use within the context of your voice platform, please provide more details or ask support for more information.
a
@Vapi so make tool response like this ? {"results":[{"toolCallId":"call_mviD2YvtPt9R1id1f5bQTtk6","result":{"action":"transferCall","parameters":{"phoneNumber":"+16022291133"}}}]}
v
@Aby The response format you've provided is not standard for invoking a function like
transferCall
. Typically, the
transferCall
function would be invoked through an API call or a command within the system, not as a JSON response to a tool call. However, if the voice platform you're using expects a JSON response to a tool call that includes instructions for further actions, then you would need to follow the platform's specific protocol for such responses. If the platform's protocol allows for the
transferCall
action to be specified in the JSON response to a tool call, then your response format might be correct. But this is highly dependent on the platform's expected response structure. To clarify, you should consult the documentation of the voice platform (VAPI) you're using to understand the correct way to structure your response for a tool call. If the documentation specifies that you should return a JSON object with an "action" and "parameters" to invoke a
transferCall
, then your response format would be appropriate. If the documentation does not provide clear guidance on this, or if you're unsure about the correct procedure, it would be best to reach out to the platform's support team for further assistance. They can provide you with the exact specifications for how to structure your response to achieve the desired call transfer based on your server logic.
a
@Vapi I am confused. so if transferCall is not sent as response to tool call how exactly can I invoke transferCall function from my server while a call is in progress with the assistant
v
@Aby I apologize for any confusion. To clarify, you cannot directly invoke the
transferCall
function from your server as an independent action. Instead, the
transferCall
function must be invoked by the assistant based on the logic you provide in response to a tool call. Here's how you can structure the process: 1. Your assistant sends a tool request to your server to check if agents are available in the call centers. 2. Your server processes this request and determines which call center to transfer the call to. 3. Your server then sends a structured response back to the assistant with the decision. 4. The assistant, upon receiving this response, will invoke the
transferCall
function with the provided phone number. To make this work, you need to ensure that your assistant is programmed to interpret the server's response and perform the
transferCall
action. This typically involves setting up a custom logic or script within the assistant that can handle the structured response from your server. If your assistant supports dynamic handling of tool responses, you would send back a structured JSON indicating the action to take, like so:
Copy code
json
{
  "action": "transferCall",
  "phoneNumber": "+16022291133"
}
Upon receiving this response, the assistant's logic should be set up to recognize the
action
field and execute the corresponding
transferCall
function with the provided
phoneNumber
. If you're unsure how to set up this logic within your assistant, or if the assistant's capabilities are limited and cannot interpret such responses, you may need to reach out to the support team of the voice platform for more detailed guidance on how to implement this functionality.
a
@Vapi assistant responses normally look like this {"results":[{"toolCallId":"call_mviD2YvtPt9R1id1f5bQTtk6","result":"Yes. Agents are available."}]} where should we add in this { "action": "transferCall", "phoneNumber": "+16022291133" } ?
v
@Aby Based on the structure you've provided, it seems that the assistant expects a JSON response with a
results
array containing objects with
toolCallId
and
result
keys. To include an action for transferring a call, you would typically replace the
result
string with an object that specifies the action and parameters. Here's how you can modify your response to include the
transferCall
action:
Copy code
json
{
  "results": [
    {
      "toolCallId": "call_mviD2YvtPt9R1id1f5bQTtk6",
      "result": {
        "action": "transferCall",
        "parameters": {
          "phoneNumber": "+16022291133"
        }
      }
    }
  ]
}
In this modified response, the
result
is now an object that includes the
action
to be taken (
transferCall
) and the
parameters
for that action (in this case, the
phoneNumber
to which the call should be transferred). Please ensure that your assistant is configured to understand and act upon this structured response. If the assistant is not currently set up to parse and execute actions from such a response, you will need to update its configuration or logic to handle this appropriately. If you're still unsure or if this doesn't work, it's possible that there are platform-specific requirements or configurations that need to be addressed. In that case, please consult the documentation for the voice platform you're using or reach out to their support team for further assistance.
a
I would like to get some help please I want to forward call when a tool call comes in I am not understanding how can I invoke transferCall function
s
@Aby can you send the latest call_id?
3 Views