Skip to content
Merged
Changes from all commits
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
73 changes: 73 additions & 0 deletions fern/tools/custom-tools.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,79 @@ Let's say you want to create a tool that fetches the weather for a given locatio

Simply create additional tool objects within the "tools" array, following the same structure and modifying the details as needed. Each tool can have its own unique configuration and messages.

## Request Format: Understanding the Tool Call Request

When your server receives a tool call request from Vapi, it will be in the following format:

```json
{
"message": {
"timestamp": 1678901234567,
"type": "tool-calls",
"toolCallList": [
{
"id": "toolu_01DTPAzUm5Gk3zxrpJ969oMF",
"name": "get_weather",
"arguments": {
"location": "San Francisco"
}
}
],
"toolWithToolCallList": [
{
"type": "function",
"name": "get_weather",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string"
}
}
},
"description": "Retrieves the current weather for a specified location"
},
"server": {
"url": "https://your-api-server.com/weather"
},
"messages": [],
"toolCall": {
"id": "toolu_01DTPAzUm5Gk3zxrpJ969oMF",
"type": "function",
"function": {
"name": "get_weather",
"parameters": {
"location": "San Francisco"
}
}
}
],
"artifact": {
"messages": []
},
"assistant": {
"name": "Weather Assistant",
"description": "An assistant that provides weather information",
"model":{},
"voice":{},
"artifactPlans":{},
"startSpeakingPlan":{}
},
"call": {
"id": "call-uuid",
"orgId": "org-uuid",
"type": "webCall",
"assistant": {}
}
}
}
```

<Note>
For the complete API reference, see [ServerMessageToolCalls Type Definition](https://github.com/VapiAI/server-sdk-typescript/blob/main/src/api/types/ServerMessageToolCalls.ts#L7).
</Note>


## Server Response Format: Providing Results and Context

When your Vapi assistant calls a tool (via the server URL you configured), your server will receive an HTTP request containing information about the tool call. Upon processing the request and executing the desired function, your server needs to send back a response in the following JSON format:
Expand Down