diff --git a/fern/tools/custom-tools.mdx b/fern/tools/custom-tools.mdx index 414fa235e..f0d4b73c9 100644 --- a/fern/tools/custom-tools.mdx +++ b/fern/tools/custom-tools.mdx @@ -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": {} + } + } +} +``` + + +For the complete API reference, see [ServerMessageToolCalls Type Definition](https://github.com/VapiAI/server-sdk-typescript/blob/main/src/api/types/ServerMessageToolCalls.ts#L7). + + + ## 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: