Tools JSON Payload
# support
k
Where can I find an example of the json payload that is sent to my server url when a tool is called during a call?
v
@KH You can find an example of the JSON payload that is sent to your server URL in the documentation provided with the VAPI. It should outline the structure of the payload, including the
type
,
messages
,
function
,
async
, and
server
fields. If you need a specific example tailored to your tool, please let me know the details of the tool you're using, and I can help you construct a sample payload.
You can continue this conversation by mentioning me in the message.
k
I have a tool call with one parameter named server, what would the payload from VAPI look like
@Vapi
v
@KH The JSON payload sent from VAPI to your server when a tool is called with a
server
parameter would typically include the details of the tool invocation along with the
server
parameter you've specified. Here's an example of what the payload might look like:
Copy code
json
{
  "tool_name": "YourToolName",
  "parameters": {
    "server": "https://your-server-url.com"
  },
  "call_id": "unique-call-identifier",
  "timestamp": "2023-04-01T12:34:56Z"
}
In this payload: -
tool_name
would be the name of the tool being called. -
parameters
would contain the
server
parameter with the URL you provided. -
call_id
would be a unique identifier for the call during which the tool is being used. -
timestamp
would be the time at which the tool was called. Please replace
"YourToolName"
and
"https://your-server-url.com"
with the actual name of your tool and the server URL you are using. If you need more specific information or if there are additional parameters, please provide further details.
k
Thank you! And then what does the payload I send back to Vapi with the response have to look like
@Vapi
v
@KH The response payload you send back to VAPI typically includes the result of the tool execution and any relevant data that VAPI or the calling service needs to proceed. Here's a general structure for a response payload:
Copy code
json
{
  "status": "success",
  "message": "Tool execution completed successfully.",
  "data": {
    // ... include any relevant data here ...
  }
}
In this payload: -
status
indicates the outcome of the tool execution, which can be
success
,
error
, or other status codes as defined by your tool's API. -
message
provides a human-readable description of the result. -
data
is an object that contains any additional data you want to return. The structure of this object will depend on what the VAPI expects or what your tool is designed to provide. Make sure to adhere to the expected schema as defined by VAPI for the tool you are implementing. If there are specific fields or formats required by VAPI, you should include those in your response. If you need further clarification on the exact structure required for your specific tool, please refer to the VAPI documentation or ask for more details.
k
@User @User Are the responses from @Vapi correct, or are there any differences in the correct payloads to receive and send?
v
@KH Please ask support for more info on this.
k
@User
Update, I found this link that shows the attribute of the tool server message: https://docs.vapi.ai/api-reference/messages/server-message. I am still looking for n example. I just want to understaand how these attributes are formatted
@User @User @Sahil
s
@KH give me sometime i will check.
k
Thank you very much!
s
check this: https://dump.sahilsuman.me/thisiswhat.txt For more check the respnse type from here: https://api.vapi.ai/api-json# go to components > schemas > serverMessageToolCall
k
Thanks for sharing this, I am still pretty confused on what comes from vapi. Are you able to find me a clear json payload that will send from vapi. I know you guys have examples for function calls, I just can't find one for tool calls
@Shubham Bajaj
Or if you knwo what the server url is that I should send my json response back to is, that would also be realy helpful.
s
@KH these steps will give you example of json payload vapi sends to your server url for tool call, and same canbe used for other server url messages. 1. check https://ngrok.com/ 2. start a local server 3. give that server url to tool 4. select the server message tool call only 5. go to http://localhost:4040 and watch for logs 6. go to assistant and make a call 7. go back to http://localhost:4040 and check logs for tool call Note: if you select tool call server event your supposed to return a response from same server url. I hope this gives youn an example.
31 Views