harsh-harlequin
harsh-harlequin2h ago

How to dynamically transfer calls (without parameters)

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
1 Reply
Vapi
Vapi2h ago
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):
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 });
});
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. Source: - Dynamic call transfers
⤵️ Mention @Vapi Support Bot for follow-ups 🐥

Did you find this page helpful?