function called but "unexpected error"
# support
I have defined a very basic function: - launch-rocket: This function launches a rocket. Call it to launch a rocket. I'm building in-browser with the web SDK. I intercept the function call with
vapi.on('message', ...)
so I haven't added an url or any properties to the function. When I ask, "please launch a rocket", the function is called successfully but so far 100% of the time it is followed by "An unexpected error occurred." making the voice agent assume something went wrong (even tho the function was called fine). Example transcript:
Copy code
Hi. I'm a voice agent. How can I help?
Please launch a rocket
---> launch-rocket is called
"An unexpected error occurred."
Hold on a sec. It seems there was an error with launching the rocket. Is there anything else I can assist you with?
I can't figure out how to debug this, can someone point me in the right direction?
Hi @stijn, I'm an AI assistant for Vapi. I'll analyze available sources and get back to you shortly.
----------------------------- **While I generate an answer, here are some sources that might be helpful**: * [Vapi iOS SDK]() * [Vapi Web SDK]() * [Web SDK]() * [Call Ended Reason]() -----------------------------
### Answer When encountering "An unexpected error occurred." in response to a function call using Vapi's Web SDK, it's essential to ensure that the function is correctly implemented and that any server-side handling (if applicable) is appropriately configured to respond to the function call. However, without a specific server URL or properties defined for your function as you mentioned, it's challenging to pinpoint the exact cause directly from the information provided. Given the nature of your issue, it might be related to how Vapi interprets the successful execution of the function or potentially an issue with how the response from the function call is handled or expected by Vapi. Unfortunately, the provided documentation sources don't directly address handling or debugging specific errors like "An unexpected error occurred." following a function call in the context you've described. A general approach to debugging this issue includes: 1. Ensuring that the function call (
in your case) is correctly recognized and processed by Vapi. The use of
vapi.on('message', ...)
for intercepting function calls is correct as per the documentation for handling message events in the Vapi Web SDK [(1)]() . 2. Verifying any server-side application logic associated with the function call, if applicable. Although you haven't added a URL or properties to the function, ensuring that the expected response to Vapi (if any) is correctly structured might be relevant in different scenarios. 3. Reviewing Vapi's documentation for any related guidance on function call handling, error debugging, or specific configuration requirements that might impact the execution of function calls. As the specific error handling and debugging guidance for "An unexpected error occurred." isn't directly covered in the available documentation
, further exploration of Vapi's documentation or reaching out to Vapi's developer support might provide more targeted insights for resolving this issue.
Got it. Tagging @User for additional help.
call id?
Glad I could be helpful. Feel free to create a new thread with any new questions you may have.