Webhook Response not working
# support
d
My webhook isn't giving the response I expect. I made a tool that when a caller asks for the pizza status, the voice agent responds "The pizza guy's number is 234. Do you want cheese or pepperoni?" But it's not working. the voice agent says " I don't have the status of the pizza" I made a webhook post request picture. 1 I made a function to call that webhook. picture 2 When I call the agent it says it doesn't have the info on the pizza. picture 3 But my logs show that the tool is being called with 200 OK. picture 4 https://cdn.discordapp.com/attachments/1377381063541657620/1377381064284311622/image.png?ex=6838c194&is=68377014&hm=055f3859d250d68d392389b44f4aa5a71df9f057c0ac34a0f8803191efcd3d08& https://cdn.discordapp.com/attachments/1377381063541657620/1377381065035087943/image.png?ex=6838c194&is=68377014&hm=c8bb130358d0784ad766b5640aa0e7c9206fe8c95370af7e6a4f4b0e87570692& https://cdn.discordapp.com/attachments/1377381063541657620/1377381065387151400/image.png?ex=6838c194&is=68377014&hm=80b56ba7fad660c562a683c3ee47d701bd040f37f819ee08f592c7c6aabb0aaf& https://cdn.discordapp.com/attachments/1377381063541657620/1377381065681010699/image.png?ex=6838c194&is=68377014&hm=8e661d662ace0541bbdf4d3584026ad97959d6dfae1accab1eacb9868039b396&
v
It looks like your webhook is being called, but the agent isn't using your response. According to the Vapi documentation, your webhook must return a JSON object like:
Copy code
json
{
  "results": [
    {
      "toolCallId": "<the id from the request>",
      "result": "<your message>"
    }
  ]
}
If your response doesn't match this format, the agent won't relay your message. Could you share the exact JSON response your webhook returns to the agent? This will help pinpoint if the response format is the issue. Source: - [Vapi Custom Tools documentation](https://docs.vapi.ai/tools/custom-tools#server-response-format-providing-results-and-context)
It looks like your webhook is being called, but the agent isn't using your response. According to the Vapi documentation, your webhook must return a JSON object like:
Copy code
json
{
  "results": [
    {
      "toolCallId": "<the id from the request>",
      "result": "<your message>"
    }
  ]
}
If your response doesn't match this format, the agent won't relay your message. Could you share the exact JSON response your webhook returns to the agent? This will help pinpoint if the response format is the issue. Source: - [Vapi Custom Tools documentation](https://docs.vapi.ai/tools/custom-tools#server-response-format-providing-results-and-context)
Thanks for sharing the details! To help troubleshoot, can you confirm if your webhook is returning the response as
{ "result": "The pizza guy's number is 234. Do you want cheese or pepperoni?" }
(as required by Vapi), rather than just a plain message or a different JSON structure? Source: - [Vapi Server Events Documentation](https://docs.vapi.ai/server-url/events)
Thanks for sharing the details! To help troubleshoot, can you confirm if your webhook is returning the response as
{ "result": "The pizza guy's number is 234. Do you want cheese or pepperoni?" }
(as required by Vapi), rather than just a plain message or a different JSON structure? Source: - [Vapi Server Events Documentation](https://docs.vapi.ai/server-url/events)
Suggestion: Make sure your webhook returns a JSON response in the format Vapi expects for tool calls. For example:
Copy code
json
{
  "messageResponse": {
    "message": "The pizza guy's number is 234. Do you want cheese or pepperoni?"
  }
}
Update your webhook to return this structure, not just a plain string. This should allow the agent to use your custom message as intended. Source: - [Vapi Webhook Server Message Documentation](https://docs.vapi.ai/api-reference/webhooks/server-message?explorer=true)
Suggestion: Make sure your webhook returns a JSON response in the format Vapi expects for tool calls. For example:
Copy code
json
{
  "messageResponse": {
    "message": "The pizza guy's number is 234. Do you want cheese or pepperoni?"
  }
}
Update your webhook to return this structure, not just a plain string. This should allow the agent to use your custom message as intended. Source: - [Vapi Webhook Server Message Documentation](https://docs.vapi.ai/api-reference/webhooks/server-message?explorer=true)
d
@app.post("/agent/pizza") async def pizza_tool(request: Request) -> dict: body = await request.json() tool_call_id = body.get("toolCallId", "") return { "results": [ { "toolCallId": tool_call_id, "result": "The pizza guy's number is 234. Do you want cheese or pepperoni?" } ] }
v
Your webhook is returning the correct JSON format for Vapi tool calls, and your server logs show the webhook is being called successfully. Since the agent still isn't relaying your custom message, it could be related to how the tool is configured or invoked within your agent's workflow. Double-check that the tool is properly registered and mapped in your agent setup, and that any required parameters are being passed as expected. If everything looks correct, reviewing the agent's configuration for any mismatches or additional settings that might affect tool responses could help pinpoint the issue. Source: - [Vapi Custom Tools documentation](https://docs.vapi.ai/tools/custom-tools#server-response-format-providing-results-and-context)
Your webhook is returning the correct JSON format for Vapi tool calls, and your server logs show the webhook is being called successfully. Since the agent still isn't relaying your custom message, it could be related to how the tool is configured or invoked within your agent's workflow. Double-check that the tool is properly registered and mapped in your agent setup, and that any required parameters are being passed as expected. If everything looks correct, reviewing the agent's configuration for any mismatches or additional settings that might affect tool responses could help pinpoint the issue. Source: - [Vapi Custom Tools documentation](https://docs.vapi.ai/tools/custom-tools#server-response-format-providing-results-and-context)
Your webhook response format is correct. Since your code matches the required structure, the next thing to check is that the tool's name and parameters in your Vapi assistant configuration exactly match what your webhook expects. Action: - Double-check that the tool name ("pizza") and its parameters in the assistant's tool configuration are identical to those handled in your webhook. - Also, ensure the tool is properly linked to the assistant in the Vapi dashboard. If everything matches and the issue persists, try logging the full incoming request body to your webhook to confirm the
toolCallId
and parameters are being received as expected. Source: - [Vapi Custom Tools documentation](https://docs.vapi.ai/tools/custom-tools#server-response-format-providing-results-and-context)
Your webhook response format is correct. Since your code matches the required structure, the next thing to check is that the tool's name and parameters in your Vapi assistant configuration exactly match what your webhook expects. Action: - Double-check that the tool name ("pizza") and its parameters in the assistant's tool configuration are identical to those handled in your webhook. - Also, ensure the tool is properly linked to the assistant in the Vapi dashboard. If everything matches and the issue persists, try logging the full incoming request body to your webhook to confirm the
toolCallId
and parameters are being received as expected. Source: - [Vapi Custom Tools documentation](https://docs.vapi.ai/tools/custom-tools#server-response-format-providing-results-and-context)
Your webhook response format is correct for a Vapi custom tool call. If the agent still isn't using your response, double-check that the tool's parameter schema in your Vapi dashboard matches what the agent is sending (e.g., required parameters, types, and names). Actionable next step: Add a debug print to log the full incoming request body in your webhook, and verify that
toolCallId
is present and matches the tool call in your Vapi logs. This will help ensure the response is correctly mapped to the tool call.
Copy code
python
body = await request.json()
print(body)  # Add this line for debugging
If the
toolCallId
is missing or mismatched, the agent may ignore the response. [See Vapi Custom Tools documentation](https://docs.vapi.ai/tools/custom-tools#server-response-format-providing-results-and-context) Source: - [Vapi Custom Tools documentation](https://docs.vapi.ai/tools/custom-tools#server-response-format-providing-results-and-context)
Your webhook response format is correct for a Vapi custom tool call. If the agent still isn't using your response, double-check that the tool's parameter schema in your Vapi dashboard matches what the agent is sending (e.g., required parameters, types, and names). Actionable next step: Add a debug print to log the full incoming request body in your webhook, and verify that
toolCallId
is present and matches the tool call in your Vapi logs. This will help ensure the response is correctly mapped to the tool call.
Copy code
python
body = await request.json()
print(body)  # Add this line for debugging
If the
toolCallId
is missing or mismatched, the agent may ignore the response. [See Vapi Custom Tools documentation](https://docs.vapi.ai/tools/custom-tools#server-response-format-providing-results-and-context) Source: - [Vapi Custom Tools documentation](https://docs.vapi.ai/tools/custom-tools#server-response-format-providing-results-and-context)
v
Set the "Required" field for your "type" parameter to "true" in your tool configuration. This ensures the assistant always includes the "type" parameter when calling your webhook, preventing issues with missing or unexpected parameters. You can update this in the Vapi dashboard under your tool's parameter settings. For reference, see the [Vapi Custom Tools documentation](https://docs.vapi.ai/tools/custom-tools#server-response-format-providing-results-and-context). Source: - [Vapi Custom Tools documentation](https://docs.vapi.ai/tools/custom-tools#server-response-format-providing-results-and-context)
Set the "Required" field for your "type" parameter to "true" in your tool configuration. This ensures the assistant always includes the "type" parameter when calling your webhook, preventing issues with missing or unexpected parameters. You can update this in the Vapi dashboard under your tool's parameter settings. For reference, see the [Vapi Custom Tools documentation](https://docs.vapi.ai/tools/custom-tools#server-response-format-providing-results-and-context). Source: - [Vapi Custom Tools documentation](https://docs.vapi.ai/tools/custom-tools#server-response-format-providing-results-and-context)
Suggestion: Explicitly set the "Required" flag for your
type
parameter in the Vapi dashboard to ensure the agent always sends it to your webhook. This helps prevent parameter mismatches and ensures your webhook receives the expected data. After updating, test again and log the incoming request to confirm the parameter is present:
Copy code
python
body = await request.json()
print(body)  # Check if 'type' is included
[See Vapi Custom Tools documentation](https://docs.vapi.ai/tools/custom-tools#server-response-format-providing-results-and-context) Source: - [Vapi Custom Tools documentation](https://docs.vapi.ai/tools/custom-tools#server-response-format-providing-results-and-context)
Suggestion: Explicitly set the "Required" flag for your
type
parameter in the Vapi dashboard to ensure the agent always sends it to your webhook. This helps prevent parameter mismatches and ensures your webhook receives the expected data. After updating, test again and log the incoming request to confirm the parameter is present:
Copy code
python
body = await request.json()
print(body)  # Check if 'type' is included
[See Vapi Custom Tools documentation](https://docs.vapi.ai/tools/custom-tools#server-response-format-providing-results-and-context) Source: - [Vapi Custom Tools documentation](https://docs.vapi.ai/tools/custom-tools#server-response-format-providing-results-and-context)
d
okay. that is enough messages for now.
v
Understood! If you need more help in the future, feel free to reach out. Have a great day! Source: - [Vapi Custom Tools documentation](https://docs.vapi.ai/tools/custom-tools#server-response-format-providing-results-and-context)
Understood! If you need more help in the future, feel free to reach out. Have a great day! Source: - [Vapi Custom Tools documentation](https://docs.vapi.ai/tools/custom-tools#server-response-format-providing-results-and-context)
d
can you answer my question above?
@Vapi Support Bot
solved this is my working code.. @app.post("/agent/pizza") async def pizza_tool(request: Request) -> dict: body = await request.json() print(body) # Add this line for debugging # Try to extract toolCallId from multiple possible locations tool_call_id = ( body.get("toolCallId") or body.get("tool_call_id") or (body.get("message", {}).get("toolCalls", [{}])[0].get("id")) ) return { "results": [ { "toolCallId": tool_call_id, "result": "The pizza guy's number is 234. Do you want cheese or pepperoni?" } ] }
c
Awesome.
3 Views