Skip to content

Commit 476b3b8

Browse files
authored
VAP-9999: add API request tool docs + improve DTMF docs (#517)
* feat: add API Request tool docs * feat: update DTMF docs * wording * advanced example --------- Co-authored-by: stevenbdf <steven@vapi.ai>
1 parent 3a8dce4 commit 476b3b8

File tree

1 file changed

+135
-17
lines changed

1 file changed

+135
-17
lines changed

fern/tools/default-tools.mdx

Lines changed: 135 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
title: Default Tools
3-
subtitle: 'Adding Transfer Call, End Call, and Dial Keypad capabilities to your assistants.'
3+
subtitle: 'Adding Transfer Call, End Call, Dial Keypad, and API Request capabilities to your assistants.'
44
slug: tools/default-tools
55
---
66

7-
Vapi voice assistants are given additional functions: `transferCall`,`endCall`, and `dtmf` (to dial a keypad with [DTMF](https://en.wikipedia.org/wiki/DTMF)). These functions can be used to transfer calls, hang up calls, and enter digits on the keypad.
7+
Vapi voice assistants are given additional functions: `transferCall`, `endCall`, `sms`, `dtmf` (to dial a keypad with [DTMF](https://en.wikipedia.org/wiki/DTMF)), and `apiRequest`. These functions can be used to transfer calls, hang up calls, send SMS messages, enter digits on the keypad, and integrate business logic with your existing APIs.
88

99
<Info>
1010
To add Default Tools to your agent, you need to add them in the `tools` array of your assistant. You can do this in your api request, or by creating a new tool in the dashboard tools page, and assigning it to your assistant.
@@ -94,6 +94,7 @@ This function is provided when `sms` is included in the assistant's list of avai
9494
#### Dial Keypad (DTMF)
9595

9696
This function is provided when `dtmf` is included in the assistant's list of available tools (see configuration options [here](/api-reference/assistants/create#request.body.model.openai.tools.dtmf)). The assistant will be able to enter digits on the keypad.
97+
Useful for IVR navigation or data entry.
9798

9899
```json
99100
{
@@ -122,31 +123,148 @@ There are three methods for sending DTMF in a phone call:
122123
3. **Out-of-band via SIP INFO messages**: tones are sent as separate SIP INFO messages. While this can be more reliable than in-band DTMF, it's not as widely supported as the RFC 2833 method.
123124

124125
<Note>
125-
Vapi's DTMF tool uses in-band method. Please note that this method may not work with certain IVRs. If you are running into this issue, the recommended approach is to have your assistant say the options out loud if available. For example, when an IVR says "Press 1 or say Sales for the Sales department," prefer having the assistant say "Sales."
126+
Vapi's DTMF tool integrates with telephony provider APIs to send DTMF tones using the out-of-band RFC 2833 method. This approach is widely supported and more reliable for transmitting the signals, especially in VoIP environments.
127+
Note, the tool's effectiveness depends on the IVR system's configuration and their capturing method. If you are running into issues, try different telephony providers or have your assistant say the options out loud if available.
126128
</Note>
127129

128-
##### Tool Effectiveness
130+
#### API Request
129131

130-
To evaluate this tool, we set up a Vapi assistant with the DTMF tool enabled and conducted calls to a range of IVR systems, including a Twilio IVR (configured via Studio Flows) and several third-party IVRs such as pharmacies and insurance companies.
132+
This tool allows your assistant to make HTTP requests to any external API endpoint during conversations. This tool fills the gap between Vapi and your existing business logic, bringing your own endpoints into the conversation flow.
133+
See configuration options [here](/api-reference/tools/create).
131134

132-
**Testing Methodology**
135+
##### Dynamic Variables with LiquidJS
133136

134-
We called and navigated through the IVRs using three different strategies:
137+
Use **LiquidJS syntax** to reference conversation variables and user data in your URLs, headers, and request bodies. This allows your API requests to adapt dynamically based on the conversation context.
135138

136-
1. **Direct Dialpad**: calling from a personal phone and dialing options using the dialpad.
137-
2. **Vapi DTMF Tool**: an assistant configured with the DTMF tool.
138-
3. **Manual DTMF Sound**: calling from a personal phone and playing DTMF tones generated by software. _(similar approach as the Vapi DTMF Tool)_
139+
##### Basic Examples
139140

140-
**Key Findings**
141-
142-
- The assistant successfully navigated some of the third-party IVRs.
143-
- The assistant encountered issues with Twilio IVRs, likely due to Twilio's preference for RFC 2833.
144-
- Observed occasional delays in DTMF tone transmission, which may affect effectiveness with IVRs that have short timeouts.
141+
**GET Request Example**
142+
```json
143+
{
144+
"model": {
145+
"provider": "openai",
146+
"model": "gpt-4o",
147+
"messages": [
148+
{
149+
"role": "system",
150+
"content": "You help users check their order status. When they provide an order number, use the checkOrderStatus function."
151+
}
152+
],
153+
"tools": [
154+
{
155+
"type": "apiRequest",
156+
"function": {
157+
"name": "api_request_tool"
158+
},
159+
"name": "checkOrderStatus",
160+
"url": "https://api.yourcompany.com/orders/{{orderNumber}}",
161+
"method": "GET",
162+
"body": {
163+
"type": "object",
164+
"properties": {
165+
"orderNumber": {
166+
"description": "The user's order number",
167+
"type": "string"
168+
}
169+
},
170+
"required": ["orderNumber"]
171+
}
172+
}
173+
]
174+
}
175+
}
176+
```
145177

146-
**Conclusion**
178+
**POST Request Example**
179+
```json
180+
{
181+
"model": {
182+
"provider": "openai",
183+
"model": "gpt-4o",
184+
"messages": [
185+
{
186+
"role": "system",
187+
"content": "You help users book appointments. When they want to schedule, use the bookAppointment function."
188+
}
189+
],
190+
"tools": [
191+
{
192+
"type": "apiRequest",
193+
"function": {
194+
"name": "api_request_tool"
195+
},
196+
"name": "bookAppointment",
197+
"url": "https://api.yourcompany.com/appointments",
198+
"method": "POST",
199+
"headers": {
200+
"type": "object",
201+
"properties": {
202+
"x-api-key": {
203+
"type": "string",
204+
"value": "123456789"
205+
}
206+
}
207+
},
208+
"body": {
209+
"type": "object",
210+
"properties": {
211+
"date": {
212+
"description": "The date of the appointment",
213+
"type": "string"
214+
},
215+
"customerName": {
216+
"description": "The name of the customer",
217+
"type": "string"
218+
},
219+
"customerPhoneNumber": {
220+
"description": "The phone number of the customer",
221+
"type": "string"
222+
}
223+
},
224+
"required": [
225+
"date",
226+
"customerName",
227+
"customerPhoneNumber"
228+
]
229+
}
230+
}
231+
]
232+
}
233+
}
234+
```
147235

148-
The tool's effectiveness depends on the IVR system's configuration and DTMF capturing method. We are working to improve compatibility and reduce transmission delays for broader and more reliable support.
236+
##### Advanced Configuration
149237

238+
**With Retry Logic**
239+
```json
240+
{
241+
"type": "apiRequest",
242+
"function": {
243+
"name": "api_request_tool"
244+
},
245+
"name": "checkOrderStatus",
246+
"url": "https://api.yourcompany.com/orders/{{orderNumber}}",
247+
"method": "GET",
248+
"body": {
249+
"type": "object",
250+
"properties": {
251+
"orderNumber": {
252+
"description": "The user's order number",
253+
"type": "string"
254+
}
255+
},
256+
"required": [
257+
"orderNumber"
258+
]
259+
},
260+
"backoffPlan": {
261+
"type": "exponential",
262+
"maxRetries": 3,
263+
"baseDelaySeconds": 1
264+
},
265+
"timeoutSeconds": 45
266+
}
267+
```
150268

151269
<Accordion title="Custom Functions: Deprecated">
152270
### Custom Functions

0 commit comments

Comments
 (0)