Custom Tools
Learn how to create and configure Custom Tools for use by your Vapi assistants.
This guide shows you how to create custom tools for your Vapi assistants. We recommend using the Vapi dashboard’s dedicated Tools section, which provides a visual interface for creating and managing tools that can be reused across multiple assistants. For advanced users, API configuration is also available.
Creating Tools in the Dashboard (Recommended)
Step 1: Navigate to the Tools Section
- Open your Vapi Dashboard
- Click Tools in the left sidebar
- Click Create Tool to start building your custom tool
Step 2: Configure Your Tool
The dashboard provides a user-friendly interface to configure your tool:
- Tool Type: Select “Function” for custom API integrations
- Tool Name: Give your tool a descriptive name (e.g., “Weather Lookup”)
- Description: Explain what your tool does
- Tool Configuration:
- Tool Name: The identifier for your function (e.g.,
get_weather
) - Parameters: Define the input parameters your function expects
- Server URL: The endpoint where your function is hosted
- Tool Name: The identifier for your function (e.g.,
Step 3: Configure Messages
Set up the messages your assistant will speak during tool execution. For example, if you want custom messages you can add something like this:
- Request Start: “Checking the weather forecast. Please wait…”
- Request Complete: “The weather information has been retrieved.”
- Request Failed: “I couldn’t get the weather information right now.”
- Request Delayed: “There’s a slight delay with the weather service.”
Step 4: Advanced Settings
Configure additional options:
- Async Mode: Enable if the tool should run asynchronously
- Timeout Settings: Set how long to wait for responses
- Error Handling: Define fallback behaviors
Example: Creating a Weather Tool
Let’s walk through creating a weather lookup tool:
Dashboard Configuration
- Tool Name: “Weather Lookup”
- Description: “Retrieves current weather information for any location”
- Function Name:
get_weather
- Parameters:
location
(string, required): “The city or location to get weather for”
- Server URL:
https://api.openweathermap.org/data/2.5/weather
This example uses OpenWeatherMap’s free API. You’ll need to sign up at openweathermap.org to get a free API key and add it as a query parameter: ?appid=YOUR_API_KEY&q={location}
Messages Configuration
- Request Start: “Let me check the current weather for you…”
- Request Complete: “Here’s the weather information you requested.”
- Request Failed: “I’m having trouble accessing weather data right now.”
Using Tools in Assistants
Once created, your tools can be easily added to any assistant:
In the Dashboard
- Go to Assistants → Select your assistant
- Navigate to the Tools tab
- Click Add Tool and select your custom tool from the dropdown
- Save your assistant configuration
In Workflows
Tools created in the Tools section are automatically available in the workflow builder:
- Add a Tool Node to your workflow
- Select your custom tool from the Tool dropdown
- Configure any node-specific settings
Alternative: API Configuration
For advanced users who prefer programmatic control, you can also create and manage tools via the Vapi API:
Creating Tools via API
Adding Tools to Assistants via API
Request Format: Understanding the Tool Call Request
When your server receives a tool call request from Vapi, it will be in the following format:
For the complete API reference, see ServerMessageToolCalls Type Definition.
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:
Breaking down the components:
- toolCallId (X): This is a unique identifier included in the initial request from Vapi. It allows the assistant to match the response with the corresponding tool call, ensuring accurate processing and context preservation.
- result (Y): This field holds the actual output or result of your tool’s execution. The format and content of “result” will vary depending on the specific function of your tool. It could be a string, a number, an object, an array, or any other data structure that is relevant to the tool’s purpose.
Example:
Let’s revisit the weather tool example from before. If the tool successfully retrieves the weather for a given location, the server response might look like this:
Some Key Points:
- Pay attention to the required parameters and response format of your functions.
- Ensure your server is accessible and can handle the incoming requests from Vapi.
- Make sure to add “Tools Calls” in both the Server and Client messages and remove the function calling from it.
By following these guidelines and adapting the sample payload, you can easily configure a variety of tools to expand your Vapi assistant’s capabilities and provide a richer, more interactive user experience.
Video Tutorial: