simon84734
03/25/2025, 6:02 AMVapi Support Bot
03/25/2025, 6:03 AMtransferCall
function**: Within your Vapi assistant, use the [transferCall
function](https://docs.vapi.ai/call-forwarding) to forward the call to a human agent. This function requires the forwardingPhoneNumber
parameter to specify where to transfer the call.
javascript
// Example of using transferCall function
transferCall({
forwardingPhoneNumber: "+15558675309" // Must be in E.164 format
})
When implementing this, keep in mind:
- The forwardingPhoneNumber
must be in E.164 format (e.g., +15558675309)
- You can use a variable like {forwarding_number}
to [dynamically set the forwarding number](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1336742506230054953) for specific calls
Is there anything specific about the call transfer process you'd like me to explain further?
Sources:
- [Discord conversation about DTMF tones](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1342504647520157788)
- [Vapi call forwarding documentation](https://docs.vapi.ai/call-forwarding)Vapi Support Bot
03/25/2025, 6:03 AMsimon84734
03/25/2025, 4:13 PMsimon84734
03/25/2025, 8:46 PMShubham Bajaj
03/26/2025, 2:03 PMjavascript
// When creating your assistant
const assistant = await client.assistants.create({
name: "Your Assistant Name",
model: {
provider: "openai",
model: "gpt-4o",
messages: [
{
role: "system",
content: YOUR_SYSTEM_PROMPT // We'll modify this in step 3
}
]
},
keypadInputPlan: {
enabled: true,
timeoutSeconds: 1, // Process digit after 1 second pause
delimiters: ["#"] // Optional - use if you want to process input when # is pressed
},
// Other assistant configuration...
});
## Step 2: Add the transferCall Tool to Your Assistant
Add a transferCall tool to your assistant with the human agent's phone number as the destination:
javascript
const assistant = await client.assistants.create({
// Other configuration from step 1...
model: {
// Previous model configuration...
tools: [
{
type: "transferCall",
destinations: [
{
type: "number",
number: "YOUR_HUMAN_AGENT_PHONE_NUMBER" // Replace with your support team's number
}
],
messages: [
{
type: "request-start",
content: "I'll transfer you to a human agent right away. Please hold while I connect you."
}
]
}
]
}
});
## Step 3: Update Your System Prompt to Handle the "0" Key Press
Add instructions in your system prompt to listen for the "0" key press and transfer to a human agent when detected:
[System Prompt Content]
... Your existing prompt content ...
[DTMF Handling]
- Listen for keypad input from the user throughout the conversation
- If the user presses "0" at any point during the conversation, immediately inform them that you will transfer them to a human agent and then use the transferCall tool to transfer them
- Example response: "I understand you'd like to speak with a human agent. I'll transfer you right away. Please hold while I connect you."
[Other Instructions]
... Rest of your prompt ...
Shubham Bajaj
03/26/2025, 2:03 PMjavascript
const assistant = await client.assistants.create({
name: "Customer Support Assistant",
model: {
provider: "openai",
model: "gpt-4o",
messages: [
{
role: "system",
content: `
You are a helpful customer support assistant for ACME Corporation.
[Identity]
- You are friendly, efficient, and knowledgeable
- You help customers with product information, order status, and basic troubleshooting
[Task]
- Answer customer questions about ACME products and services
- Help with order status inquiries
- Assist with basic troubleshooting
[DTMF Handling]
- Monitor for keypad inputs throughout the conversation
- If the user presses "0" at any point:
1. Immediately acknowledge their request to speak with a human agent
2. Inform them that you will transfer them to a support representative
3. Use the transferCall tool to connect them with a human agent
- Do not ask for confirmation before transferring when "0" is pressed - this is an immediate transfer request
[Important]
- When a user's keypad input is detected, it will appear in the conversation as: "User's Keypad Entry: X" where X is the digit pressed
- Any time you see "User's Keypad Entry: 0", treat this as a request to be transferred to a human agent immediately
`
}
],
tools: [
{
type: "transferCall",
destinations: [
{
type: "number",
number: "YOUR_HUMAN_AGENT_PHONE_NUMBER" // Replace with your support team's number
}
],
messages: [
{
type: "request-start",
content: "I'll transfer you to a human agent right away. Please hold while I connect you."
}
]
}
]
},
keypadInputPlan: {
enabled: true,
timeoutSeconds: 1,
delimiters: []
},
voice: {
provider: "openai",
voiceId: "alloy" // Choose your preferred voice
},
firstMessageMode: "assistant-speaks-first-with-model-generated-message"
});
## Testing Your Implementation
When a user presses "0" during a call, the system will:
1. Detect the DTMF tone
2. Add "User's Keypad Entry: 0" to the conversation history
3. The assistant will recognize this as a request for human transfer based on your system prompt
4. The assistant will inform the user about the transfer
5. The transferCall tool will be invoked to transfer the call to the human agent's number