How to dynamically transfer calls (without paramet...
# support
j
As I understand, a dynamic transfer call tool won't work if we pass in parameters and we're expected to choose a destination based on message history. This goes against our original plan that I chatted to someone about in office hours, where we want to reuse the same tool. Is there another way to achieve this tool reuse? and not create a new tool per phone number
v
You can achieve tool reuse for dynamic call transfers by creating a single transfer tool with an empty destinations array and handling the routing in your webhook. Here’s a simple example in Node.js (Express):
Copy code
js
app.post('/webhook', (req, res) => {
  const { messageHistory } = req.body;
  let destination;
  // Analyze messageHistory to pick the right number
  if (messageHistory.includes('sales')) {
    destination = { type: "number", number: "+1234567890" };
  } else {
    destination = { type: "number", number: "+0987654321" };
  }
  res.json({ destination });
});
This lets you reuse the same tool and dynamically select the destination based on conversation context, without static parameters or multiple tools. For more details, see the [Vapi dynamic transfer docs](https://docs.vapi.ai/calls/call-dynamic-transfers). Source: - [Dynamic call transfers](https://docs.vapi.ai/calls/call-dynamic-transfers)
v
Hey! I can help you make the dynamic transfer work without creating a new tool for every number. You can actually reuse the same tool by handling the destination logic inside it based on the message context. Can you share how you’re currently setting up or triggering the transfer? @Jessica
c
Hi Jessica, To set up dynamic call transfers with Vapi, follow these key steps: 1. **Create a Dynamic Transfer Tool**: - Navigate to the Tools section in your Vapi dashboard. - Click on Create Tool, and select Transfer Call as the tool type. - Ensure the destinations array is empty to allow for dynamic routing. - Specify the function name (e.g.,
dynamicTransfer
) and define any parameters like
reason
and
urgency
. 2. **Webhook Handling**: - Set up a server or cloud function to handle the
transfer-destination-request
webhook. This webhook helps determine the destination based on call context and external data. - Incorporate logic to choose the destination based on the input data. For instance, route critical issues to an emergency number. 3. **Configure an Assistant**: - Create or edit an assistant in the Vapi dashboard. - Add your dynamic transfer tool to this assistant. - Enable the transfer-destination-request server event, and set your server URL to handle incoming webhooks. 4. **Testing**: - Assign a phone number to your assistant and test various transfer scenarios to ensure dynamic routing functions properly. - Monitor logs to verify correct routing decisions. For detailed implementation steps, refer to the [dynamic call transfers documentation](https://docs.vapi.ai/calls/call-dynamic-transfers).
j
I have a different dynamic use case. I don't want to set phone number based on the message context. Instead, I have multiple phone numbers to route to based on different forks in the conversation (i.e. if we can identify this number, route to A vs B). what's the best way to do this? i'm exploring 1 transfer call tool (not dynamic) with different destinations and getting the LLM to figure out which label
@Vercel have you done this too
v
Got it, that makes sense. You can definitely do that with one transfer tool , you just need to let the model decide which route to take using predefined labels or a simple mapping logic. I’ve set this up before by building a small routing layer that automatically picks the right number based on the conversation flow. I can walk you through how to structure it so it stays flexible and easy to manage. Would you want me to help you directly? @Jessica
j
yeah i'd love to learn how you do it
c
Please do let us know how we can help further
v
Awesome, glad to hear that! It’ll be easier to go over the setup in detail so I can show you exactly how to make it work smoothly. Let’s chat privately? @Jessica
c
Don’t hesitate to reach out if you need any further assistance.
3 Views