Skip to content

Commit 24d6701

Browse files
committed
feat: add API Request tool docs
1 parent 3a8dce4 commit 24d6701

File tree

1 file changed

+141
-2
lines changed

1 file changed

+141
-2
lines changed

fern/tools/default-tools.mdx

Lines changed: 141 additions & 2 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`, `dtmf` (to dial a keypad with [DTMF](https://en.wikipedia.org/wiki/DTMF)), and `apiRequest` (to make HTTP requests to your existing APIs). These functions can be used to transfer calls, hang up calls, enter digits on the keypad, and integrate with your existing business systems.
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.
@@ -147,6 +147,145 @@ We called and navigated through the IVRs using three different strategies:
147147

148148
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.
149149

150+
#### API Request
151+
152+
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.
153+
See configuration options [here](/api-reference/tools/create).
154+
155+
##### Dynamic Variables with LiquidJS
156+
157+
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.
158+
159+
##### Basic Examples
160+
161+
**GET Request Example**
162+
```json
163+
{
164+
"model": {
165+
"provider": "openai",
166+
"model": "gpt-4o",
167+
"messages": [
168+
{
169+
"role": "system",
170+
"content": "You help users check their order status. When they provide an order number, use the checkOrderStatus function."
171+
}
172+
],
173+
"tools": [
174+
{
175+
"type": "apiRequest",
176+
"function": {
177+
"name": "api_request_tool"
178+
},
179+
"name": "checkOrderStatus",
180+
"url": "https://api.yourcompany.com/orders/{{orderNumber}}",
181+
"method": "GET",
182+
"body": {
183+
"type": "object",
184+
"properties": {
185+
"orderNumber": {
186+
"description": "The user's order number",
187+
"type": "string"
188+
}
189+
},
190+
"required": ["orderNumber"]
191+
}
192+
}
193+
]
194+
}
195+
}
196+
```
197+
198+
**POST Request Example**
199+
```json
200+
{
201+
"model": {
202+
"provider": "openai",
203+
"model": "gpt-4o",
204+
"messages": [
205+
{
206+
"role": "system",
207+
"content": "You help users book appointments. When they want to schedule, use the bookAppointment function."
208+
}
209+
],
210+
"tools": [
211+
{
212+
"type": "apiRequest",
213+
"function": {
214+
"name": "api_request_tool"
215+
},
216+
"name": "bookAppointment",
217+
"url": "https://api.yourcompany.com/appointments",
218+
"method": "POST",
219+
"headers": {
220+
"type": "object",
221+
"properties": {
222+
"x-api-key": {
223+
"type": "string",
224+
"value": "123456789"
225+
}
226+
}
227+
},
228+
"body": {
229+
"type": "object",
230+
"properties": {
231+
"date": {
232+
"description": "The date of the appointment",
233+
"type": "string"
234+
},
235+
"customerName": {
236+
"description": "The name of the customer",
237+
"type": "string"
238+
},
239+
"customerPhoneNumber": {
240+
"description": "The phone number of the customer",
241+
"type": "string"
242+
}
243+
},
244+
"required": [
245+
"date",
246+
"customerName",
247+
"customerPhoneNumber"
248+
]
249+
}
250+
}
251+
]
252+
}
253+
}
254+
```
255+
256+
##### Advanced Configuration
257+
258+
**With Retry Logic**
259+
```json
260+
{
261+
"type": "apiRequest",
262+
"function": {
263+
"name": "api_request_tool"
264+
},
265+
"name": "checkOrderStatus",
266+
"url": "https://api.yourcompany.com/orders/{{orderNumber}}",
267+
"method": "GET",
268+
"body": {
269+
"type": "object",
270+
"properties": {
271+
"orderNumber": {
272+
"description": "The user's order number",
273+
"type": "string"
274+
}
275+
},
276+
"required": [
277+
"orderNumber"
278+
]
279+
},
280+
"backoffPlan": {
281+
"initialDelayMs": 1000,
282+
"maxDelayMs": 10000,
283+
"backoffMultiplier": 2.0,
284+
"maxRetries": 3
285+
},
286+
"timeoutSeconds": 45
287+
}
288+
```
150289

151290
<Accordion title="Custom Functions: Deprecated">
152291
### Custom Functions

0 commit comments

Comments
 (0)