Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 33 additions & 14 deletions fern/assistants/function-calling.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ subtitle: 'Additional Capabilities for Your Assistants '
slug: assistants/function-calling
---

Vapi voice assistants are given three additional functions: `transferCall`,`endCall`, and `dialKeypad`. These functions can be used to transfer calls, hang up calls, and enter digits on the keypad.
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.

<Note>You **do not** need to add these functions to your model's `functions` array.</Note>
<Note>You **need** to add these tools to your model's `tools` array.</Note>

#### Transfer Call

When a `forwardingPhoneNumber` is present on an assistant, the assistant will be given a `transferCall` function. This function can be used to transfer the call to the `forwardingPhoneNumber`.
This function is provided when `transferCall` is included in the assistant's list of available tools (see configuration options [here](/api-reference/assistants/create#request.body.model.openai.tools.transferCall)). This function can be used to transfer the call to any of the `destinations` defined in the tool configuration (see details on destination options [here](/api-reference/assistants/create#request.body.model.openai.tools.transferCall.destinations)).

```json
{
Expand All @@ -22,15 +22,25 @@ When a `forwardingPhoneNumber` is present on an assistant, the assistant will be
"role": "system",
"content": "You are an assistant at a law firm. When the user asks to be transferred, use the transferCall function."
}
],
"tools": [
{
"type": "transferCall".
"destinations" : {
{
"type": "number",
"number": "+16054440129"
}
}
}
]
},
"forwardingPhoneNumber": "+16054440129"
}
}
```

#### End Call

This function is provided when `endCallFunctionEnabled` is enabled on the assistant. The assistant can use this function to end the call.
This function is provided when `endCall` is included in the assistant's list of available tools (see configuration options [here](/api-reference/assistants/create#request.body.model.openai.tools.endCall)). The assistant can use this function to end the call.

```json
{
Expand All @@ -42,15 +52,19 @@ This function is provided when `endCallFunctionEnabled` is enabled on the assist
"role": "system",
"content": "You are an assistant at a law firm. If the user is being mean, use the endCall function."
}
],
"tools": [
{
"type": "endCall"
}
]
},
"endCallFunctionEnabled": true
}
}
```

#### Dial Keypad
#### Dial Keypad (DTMF)

This function is provided when `dialKeypadFunctionEnabled` is enabled on the assistant. The assistant will be able to enter digits on the keypad.
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.

```json
{
Expand All @@ -60,14 +74,18 @@ This function is provided when `dialKeypadFunctionEnabled` is enabled on the ass
"messages": [
{
"role": "system",
"content": "You are an assistant at a law firm. When you hit a menu, use the dialKeypad function to enter the digits."
"content": "You are an assistant at a law firm. When you hit a menu, use the dtmf function to enter the digits."
}
],
"tools": [
{
"type": "dtmf"
}
]
},
"dialKeypadFunctionEnabled": true
}
}
```

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

<Warning>The **Custom Functions** feature is being deprecated in favor of [Tools](/tools-calling). Please refer to the **Tools** section instead. We're working on a solution to migrate your existing functions over to make this a seamless transtion.</Warning>
Expand Down Expand Up @@ -111,3 +129,4 @@ At the assistant level, the `serverUrl` can be specified in the assistant config
If the `serverUrl` is not defined either at the account level or the assistant level, the function call will simply be added to the chat history. This can be particularly useful when you want a function call to trigger an action on the frontend.

For instance, the frontend can listen for specific function calls in the chat history and respond by updating the user interface or performing other actions. This allows for a dynamic and interactive user experience, where the frontend can react to changes in the conversation in real time.
</Accordion>
Loading