Dynamic call transfers

Route calls to different destinations based on real-time conversation context and external data.

Overview

Dynamic call transfers enable intelligent routing by determining transfer destinations in real-time based on conversation context, customer data, or external system information. Unlike static transfers with predefined destinations, dynamic transfers make routing decisions on-the-fly during the call.

Key capabilities:

  • Real-time destination selection based on conversation analysis
  • Integration with CRM systems, databases, and external APIs
  • Conditional routing logic for departments, specialists, or geographic regions
  • Context-aware transfers with conversation summaries
  • Fallback handling for unavailable destinations

Prerequisites

  • A Vapi account
  • A server or cloud function that can receive webhooks from Vapi
  • (Optional) CRM system or customer database for enhanced routing logic

How It Works

Dynamic transfers operate by leaving the destination unspecified initially, then using webhooks to determine the appropriate destination when needed.

Transfer flow:

  1. Trigger - Voice agent determines a transfer is needed based on conversation
  2. Webhook - Vapi sends transfer-destination-request to your server with call context
  3. Decision - Your server analyzes context and external data to determine routing
  4. Response - Server returns destination details and transfer configuration
  5. Transfer - Vapi executes the transfer to the determined destination

Available context: Your webhook receives conversation transcript, extracted variables, customer information, function parameters, and call metadata.


Quick Implementation Guide

1

Create a dynamic transfer tool

  • Navigate to Tools in your dashboard
  • Click Create Tool
  • Select Transfer Call as the tool type
  • Important: Leave the destinations array empty - this creates a dynamic transfer tool
  • Set function name: dynamicTransfer
  • Add description explaining when this tool should be used
2

Create an assistant with the transfer tool

  • Navigate to Assistants
  • Create a new assistant or edit an existing one
  • Add your dynamic transfer tool to the assistant
  • Enable the transfer-destination-request server event
  • Set your server URL to handle the webhook
3

Build your webhook server

1import express from 'express';
2import crypto from 'crypto';
3
4const app = express();
5app.use(express.json());
6
7function verifyWebhookSignature(payload: string, signature: string) {
8 const expectedSignature = crypto
9 .createHmac('sha256', process.env.WEBHOOK_SECRET!)
10 .update(payload)
11 .digest('hex');
12 return crypto.timingSafeEqual(
13 Buffer.from(signature),
14 Buffer.from(expectedSignature)
15 );
16}
17
18app.post('/webhook', (req, res) => {
19 try {
20 const signature = req.headers['x-vapi-signature'] as string;
21 const payload = JSON.stringify(req.body);
22
23 if (!verifyWebhookSignature(payload, signature)) {
24 return res.status(401).json({ error: 'Invalid signature' });
25 }
26
27 const request = req.body;
28
29 if (request.type !== 'transfer-destination-request') {
30 return res.status(200).json({ received: true });
31 }
32
33 // Simple routing logic - customize for your needs
34 const { functionCall, customer } = request;
35 const urgency = functionCall.parameters?.urgency || 'medium';
36
37 let destination;
38 if (urgency === 'critical') {
39 destination = {
40 type: "number",
41 number: "+1-555-EMERGENCY",
42 message: "Connecting you to our emergency team."
43 };
44 } else {
45 destination = {
46 type: "number",
47 number: "+1-555-SUPPORT",
48 message: "Transferring you to our support team."
49 };
50 }
51
52 res.json({ destination });
53 } catch (error) {
54 console.error('Webhook error:', error);
55 res.status(500).json({
56 error: 'Transfer routing failed. Please try again.'
57 });
58 }
59});
60
61app.listen(3000, () => {
62 console.log('Webhook server running on port 3000');
63});
4

Test your dynamic transfer system

  • Create a phone number and assign your assistant
  • Call the number and test different transfer scenarios
  • Monitor your webhook server logs to see the routing decisions
  • Verify transfers are working to the correct destinations

Implementation Approaches

Assistant-based implementation uses transfer-type tools with conditions interpreted by the assistant through system prompts. The assistant determines when and where to route calls based on clearly defined tool purposes and routing logic in the prompt. Best for quick setup and simpler routing scenarios.

Workflow-based implementation uses conditional logic based on outputs from any workflow node - tools, API requests, conversation variables, or other data sources. Conditions evaluate node outputs to determine routing paths within visual workflows. Best for complex business logic, structured decision trees, and team-friendly configuration.

Routing Patterns

Common Use Cases

  • Customer support routing - Route based on issue type, customer tier, agent availability, and interaction history. Enterprise customers and critical issues get priority routing to specialized teams.

  • Geographic routing - Direct calls to regional offices based on customer location and business hours. Automatically handle time zone differences and language preferences.

  • Load balancing - Distribute calls across available agents to optimize wait times and agent utilization. Route to the least busy qualified agent.

  • Escalation management - Implement intelligent escalation based on conversation tone, issue complexity, and customer history. Automatically route urgent issues to senior agents.

Transfer Configuration

  1. Warm transfers provide context to receiving agents with AI-generated conversation summaries, ensuring smooth handoffs with full context.

  2. Cold transfers route calls immediately with predefined context messages, useful for simple departmental routing.

  3. Conditional transfers apply different transfer modes based on routing decisions, such as priority handling for enterprise customers.

  4. Destination types include phone numbers for human agents, SIP endpoints for VoIP systems, and Vapi assistants for specialized AI agents.

Security considerations: Always verify webhook signatures to ensure requests come from Vapi. Never log sensitive customer data, implement proper access controls, and follow privacy regulations like GDPR and CCPA when handling customer information in routing decisions.

  • Call Forwarding - Static transfer options and transfer plans
  • Webhooks - Webhook security and event handling patterns
  • Custom Tools - Build custom tools for advanced routing logic