Skip to content

Commit 08431af

Browse files
committed
updated the call forwarding doc
Signed-off-by: Sahil Suman <sahilsuman933@gmail.com>
1 parent d1bc90c commit 08431af

File tree

1 file changed

+142
-29
lines changed

1 file changed

+142
-29
lines changed

call-forwarding.mdx

Lines changed: 142 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,159 @@ title: "Call Forwarding"
33
sidebarTitle: "Call Forwarding"
44
---
55

6-
Vapi offers call forwarding functionality through its `forwardingPhoneNumbers` and `forwardingPhoneNumber` attributes. While seemingly straightforward, the implementation involves specific considerations depending on your call setup. Here's a breakdown:
6+
Vapi's call forwarding functionality allows you to redirect calls to different phone numbers based on specific conditions using tools. This guide explains how to set up and use the `transferCall` function for call forwarding.
77

8-
**Key Concepts:**
8+
## Key Concepts
99

10-
* **forwardingPhoneNumbers:** This attribute allows you to define an array of phone numbers for call forwarding. It's ideal for scenarios where you want to direct calls to different departments or individuals based on the conversation context.
11-
* **forwardingPhoneNumber:** This attribute accepts a single phone number for forwarding all calls. Use this if you have a general fallback number for all situations.
12-
* **sipUri:** Within the `forwardingPhoneNumbers` array, you can specify a SIP URI instead of a regular phone number. This is crucial when dealing with calls originating from SIP, as Vapi currently only supports SIP REFER for such transfers.
10+
### Call Forwarding Tools
1311

14-
**Setting Up Call Forwarding:**
12+
- **`transferCall` Tool**: This tool enables call forwarding to predefined phone numbers with specific messages based on the destination.
1513

16-
1. **API:**
17-
* **API:** When using the Create Assistant API, the `forwardingPhoneNumber` attribute might cause errors if not handled properly. Consider omitting it or setting it to `null` or an empty string (`''`) to avoid issues.
14+
### Parameters and Messages
1815

19-
2. **Choosing the Right Attribute:**
20-
* **Multiple Forwarding Options:** If you need to route calls to different destinations based on user requests or other criteria, use the `forwardingPhoneNumbers` array.
21-
* **Single Forwarding Number:** For a simple, catch-all forwarding solution, the `forwardingPhoneNumber` attribute is sufficient.
16+
- **Destinations**: A list of phone numbers where the call can be forwarded.
17+
- **Messages**: Custom messages that inform the caller about the call being forwarded.
2218

23-
3. **Handling SIP Calls:**
24-
* **SIP Origination:** If calls originate from SIP, ensure you use the `sipUri` attribute within the `forwardingPhoneNumbers` array to specify the destination SIP address.
25-
* **SIP REFER:** Vapi utilizes SIP REFER to transfer SIP calls. Make sure your receiving system is configured to handle SIP REFER messages.
19+
## Setting Up Call Forwarding
2620

27-
**Instructing the Assistant:**
21+
### 1. Defining Destinations and Messages
2822

29-
* **System Prompt:** Use the system prompt to guide the assistant on when to utilize each forwarding number. For example, include instructions like:
30-
* "If the user asks for sales, call the `transferCall` function with `+1123123123`."
31-
* "If the user requests technical support, use the `sipUri` `sip:support@example.com`."
23+
The `transferCall` tool includes a list of destinations and corresponding messages to notify the caller:
3224

33-
**Prompting Style**
34-
```jsx
35-
When X condition is met, use the transferCall function with this phone number: +1123123123.
36-
When Y condition is met, use the transferCall function with this phone number: +1123123141.
25+
```json
26+
{
27+
"tools": [
28+
{
29+
"type": "transferCall",
30+
"destinations": [
31+
{
32+
"type": "phoneNumber",
33+
"number": "+1234567890",
34+
"message": "I am forwarding your call to Department A. Please stay on the line."
35+
},
36+
{
37+
"type": "phoneNumber",
38+
"number": "+0987654321",
39+
"message": "I am forwarding your call to Department B. Please stay on the line."
40+
},
41+
{
42+
"type": "phoneNumber",
43+
"number": "+1122334455",
44+
"message": "I am forwarding your call to Department C. Please stay on the line."
45+
}
46+
],
47+
"function": {
48+
"name": "transferCall",
49+
"description": "Use this function to transfer the call. Only use it when following instructions that explicitly ask you to use the transferCall function. DO NOT call this function unless you are instructed to do so.",
50+
"parameters": {
51+
"type": "object",
52+
"properties": {
53+
"destination": {
54+
"type": "string",
55+
"enum": [
56+
"+1234567890",
57+
"+0987654321",
58+
"+1122334455"
59+
],
60+
"description": "The destination to transfer the call to."
61+
}
62+
},
63+
"required": [
64+
"destination"
65+
]
66+
}
67+
},
68+
"messages": [
69+
{
70+
"type": "request-start",
71+
"content": "I am forwarding your call to Department A. Please stay on the line.",
72+
"conditions": [
73+
{
74+
"param": "destination",
75+
"operator": "eq",
76+
"value": "+1234567890"
77+
}
78+
]
79+
},
80+
{
81+
"type": "request-start",
82+
"content": "I am forwarding your call to Department B. Please stay on the line.",
83+
"conditions": [
84+
{
85+
"param": "destination",
86+
"operator": "eq",
87+
"value": "+0987654321"
88+
}
89+
]
90+
},
91+
{
92+
"type": "request-start",
93+
"content": "I am forwarding your call to Department C. Please stay on the line.",
94+
"conditions": [
95+
{
96+
"param": "destination",
97+
"operator": "eq",
98+
"value": "+1122334455"
99+
}
100+
]
101+
}
102+
]
103+
}
104+
]
105+
}
37106
```
38107

39-
**Additional Notes:**
40-
* Pay attention to the format of phone numbers (E.164) when using the API.
41-
* Test your call forwarding setup thoroughly to ensure it functions as expected.
108+
### 2. Using the `transferCall` Function
42109

43-
**Troubleshooting:**
110+
When the assistant needs to forward a call, it uses the `transferCall` function with the appropriate destination:
44111

45-
* If calls are not being transferred despite the transcript indicating "forwarded," check the logs for error messages and ensure your Vici system can handle SIP REFER messages if applicable.
46-
* If you encounter issues with the `forwardingPhoneNumber` attribute in the API, try omitting it or setting it to `null` or an empty string.
112+
```json
113+
{
114+
"function": {
115+
"name": "transferCall",
116+
"parameters": {
117+
"destination": "+1234567890"
118+
}
119+
}
120+
}
47121

48-
By following these guidelines and understanding the nuances of Vapi's call forwarding functionality, you can effectively manage call routing and ensure a seamless experience for your users.
122+
```
123+
124+
### 3. Customizing Messages
125+
126+
Customize the messages for each destination to provide clear information to the caller:
127+
128+
```json
129+
{
130+
"messages": [
131+
{
132+
"type": "request-start",
133+
"content": "I am forwarding your call to Department A. Please stay on the line.",
134+
"conditions": [
135+
{
136+
"param": "destination",
137+
"operator": "eq",
138+
"value": "+1234567890"
139+
}
140+
]
141+
}
142+
]
143+
}
144+
145+
```
146+
147+
## Instructing the Assistant
148+
149+
Use the system prompt to guide the assistant on when to utilize each forwarding number. For example:
150+
151+
- "If the user asks for sales, call the `transferCall` function with `+1234567890`."
152+
- "If the user requests technical support, use the `transferCall` function with `+0987654321`."
153+
154+
## Troubleshooting
155+
156+
- If calls are not being transferred, check the logs for errors.
157+
- Ensure that the correct destination numbers are used.
158+
- Ensure you have written the function description properly to indicate where you want to forward the call
159+
- Test the call forwarding setup thoroughly to confirm its functionality.
160+
161+
By following these guidelines and utilizing the `transferCall` tool, you can effectively manage call routing and provide a seamless experience for your users.

0 commit comments

Comments
 (0)