get callid from call-ended event from webSDK
# support
j
is it possible to get data like call-id when events like 'call-ended' get triggered?
v
Hi @jnetic_, 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]() * [Web SDK]() * [Get Call]() * [Vapi Web SDK]() -----------------------------
### Answer Yes, it is possible to get the call ID and other related data when an event like 'call-ended' is triggered in the Vapi Web SDK. You can listen for the
call-end
event on the Vapi instance, and within the event handler, you can access details about the call. Here is an example of how you could set up an event listener to capture and log the call ID when a call ends:
Copy code
javascript
vapi.on("call-end", () => {
    console.log("Call has ended.");
    // Access the call ID here if available in the event object
    // Example: console.log(event.callId);
});
[(1)]() , [(2)]() This code snippet sets up an event listener for the
call-end
event, and you would replace the commented section with the actual method to access the call ID, assuming it is part of the event object provided by Vapi during the event.
Got it. Tagging @User for additional help.
s
Just store the variable of vapi.start you will get the call_id just use it.
j
can you provide a snippet or example?
vapiInstance = window.vapiSDK.run doesnt return any details of the call?
I'm using web snippet actually right now
s
vapi.start(“assistant-id”) return that
use web sdk
j
is it possible to get call metadata via a function call using websnippet?
any ideas?
s
you can get all the meta data through the call_id
j
I need to get callid directly from the webpage snippet is embedded into when call is started. Im working now on overriding the script to use vapiInstance.start from the webpage directly which returns callid
s
Awesome do lmk of the result
j
I did end up doing this successfully. I had to rebuild the UI states on the button (loading state, assistant volume..etc) but used vapi.start directly from my webpage that has the external js file loaded. I wish the websnippet just provided me the call object but this was faster than using web sdk from scratch!
8 Views