Not Getting Tool-Call-Result ON FrontEnd
# support
d
I’m reaching out regarding an issue I’m experiencing with the VAPI Web SDK (using the Web Snippet in raw HTML). While I’m successfully receiving most message types in the vapi.on('message', ...) callback, I’m not seeing tool-call-result messages, even though my tools are executing correctly. I’ve verified that tool-call-result is included in the clientMessages list in my assistant configuration, alongside other message types like transcript and tool-call, which I am receiving as expected. The tools themselves are functioning—server responses are processed successfully—but the tool-call-result messages are not appearing in the client callback. Below is a snippet of my frontend code for reference: vapi.on('message', (msg) => { console.log('Message type:', msg.type, 'Full message:', msg); if (msg.type === 'transcript') { console.log('Transcript:', msg.value); } else if (msg.type === 'tool-call') { console.log('Tool call:', msg.toolCall.name, msg.toolCall.parameters); } else if (msg.type === 'tool-call-result') { console.log('Tool result:', msg.result); // This should appear if result is sent } }); In this setup, I see logs for transcript and tool-call messages, but nothing for tool-call-result. Could you please help me understand why these messages might not be reaching the client? For context, my assistant ID is 34c9c7d0-feb4-46d9-8951-c6e47508d729
v
Hi there! 👋 I see you're having trouble receiving
tool-call-result
messages in your VAPI Web SDK implementation. I'm unable to provide specific information about your assistant ID, but I can definitely help troubleshoot why you're not receiving
tool-call-result
messages despite your tools executing correctly. Based on the information I found, here are several potential causes and solutions: ### 1. Check Your Tool Response Format The most common issue is incorrect formatting of the tool response. The server must respond with a specific JSON format:
Copy code
json
{
  "results": [
    {
      "toolCallId": "<your-tool-call-id>",
      "result": "Success" // Or any success message
    }
  ]
}
According to [documentation](https://docs.vapi.ai/tools-calling), the
result
field must be a single-line string without any line breaks. If you're returning JSON data, it needs to be stringified. ### 2. Verify the toolCallId Match Make sure the
toolCallId
in your response exactly matches the one sent by VAPI in the initial request. A common mistake is using the tool ID instead of the tool call ID, which prevents VAPI from associating the response with the correct tool call. ### 3. Check Tool Configuration (Synchronous vs. Asynchronous) Ensure your tool is set to
synchronous
instead of
async
. According to [troubleshooting information](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1342315282198298729), if the tool call is set to asynchronous, the client might not receive the expected
tool-call-result
messages. ### 4. Content Type Headers Verify that the content-type of your server response is set to
application/json
. ### 5. Server-Side Errors Check your server logs for any errors that might be preventing the response from being sent back to VAPI. Status code 400 errors can prevent tool call results from being sent to the client. ### 6. Network Issues
Ensure there are no network connectivity problems or firewall configurations that might be interfering with the messages. Your code snippet for handling the messages looks correct. The issue is likely with how the tool responses are being processed or formatted before they reach your client. Would you like me to help you troubleshoot any specific aspect of this issue in more detail? Sources: - [Troubleshooting issues with VAPI Web SDK not receiving tool-call-result messages](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1325000684231196775) - [VAPI Web SDK clientMessages configuration for tool-call-result messages](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1328825176783065128) - [How VAPI Web SDK handles tool execution and result processing for tool-call-result messages](https://docs.vapi.ai/tools-calling) - [Best practices for implementing VAPI Web SDK message callback to receive tool-call-result messages](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1342176467714572400) - [Common issues and solutions for VAPI Web SDK not receiving tool-call-result messages](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1342315282198298729)
d
Please note, when I ask the bot on what the result of the server was, it is able to understand, meaning the tool-call result response from my server is okay. The issue is on the client web sdk, the onMessage does not log the one for message.type of too-call-result, but other messages are logged as per my shared example
@Shubham Bajaj any response on this support item
k
looking into it.
Hey Jay, apologies for the delay. I know it's a bad experience when you can't receive tool call result client messages. Allow me some time to get a POC done and then get back to you. This PoC will help me understand your current state. Reproduce the error and find out where it's happening. Then I can push this to the team to get it fixed.
d
Thanks for the attention on this @Shubham Bajaj . For context, kindly note that am using the web-snippet code in a raw HTML. See sample code for reference. the other message types are being output, but the tool-calls-result is not, despite a valid response being returned vapiInstance.on('message', (message) => { console.log(message); if (message.type === "tool-calls-result") { alert("Results HEre"); } if (message.type === "tool-calls" && message.toolCalls) { message.toolCalls.forEach(toolCall => { if (toolCall.function.name === "json_blob_add_to_cart") { const { id, name, quantity, price } = toolCall.function.arguments; addItemToCart(id, name, quantity, price); } if (toolCall.function.name === "json_blob_checkout") { window.location.href = 'checkout.html'; } if (toolCall.function.name === "mood_remove_from_cart") { const { id, name, quantity } = toolCall.function.arguments; removeItemFromCart(id, quantity, name); } }); } });
k
Hey buddy, now the team's aware of this. It might be on the server or our VAPI Web SDK, so they'll look into and fix it. Thanks for reporting it!
Hey buddy, now the team's aware of this. It might be on the server side logic or our VAPI Web SDK, so they'll look into and fix it. Thanks for reporting it!
Hey, could you share the call ID?
d
Hello
Here is a call ID for your review : d9724b30-c99c-4c26-87d8-1e968794cabd the tool-call processed successfully but the web SDK did not get the tool-results on the on message callback
@Shubham Bajaj any indication of where the issue on this might be coming from.
k
Can you share the message callback from the web SDK?
7 Views