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:
{
"results": [
{
"toolCallId": "X",
"result": "Y"
}
]
}
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:
{
"results": [
{
"toolCallId": "call_VaJOd8ZeZgWCEHDYomyCPfwN",
"result": "San Francisco's weather today is 62°C, partly cloudy."
}
]
}