WebSDK Widget to access Call
# support
b
Is there a way to access the current Call Id via the widget https://docs.vapi.ai/examples/voice-widget ? I've tried accessing vapiInstance.call (which is private) but it seems to always be undefined.
v
@Ben Yes, you can access the current Call ID in the VAPI Voice Widget, but it's not directly available through
vapiInstance.call
as that is a private member. Instead, you should use the appropriate event listeners provided by the VAPI Voice Widget to get the Call ID. When a call is connected, the Voice Widget emits an event that includes the Call ID. You can listen for this event and then retrieve the Call ID from the event object. Here's an example of how you can set up an event listener for the
callConnected
event:
Copy code
javascript
vapiInstance.on('callConnected', function(event) {
  var callId = event.callId;
  console.log('Connected call with ID:', callId);
});
Make sure to add this event listener after initializing your VAPI Voice Widget instance and before the call is connected to ensure you capture the event. If you're still having trouble accessing the Call ID, please ask support for more info on this.
You can continue this conversation by mentioning me in the message.
b
Copy code
type VapiEventListeners = {
    'call-end': () => void;
    'call-start': () => void;
    'volume-level': (volume: number) => void;
    'speech-start': () => void;
    'speech-end': () => void;
    video: (track: MediaStreamTrack) => void;
    message: (message: any) => void;
    error: (error: any) => void;
};
I think the event handler and suggestion you have provided is a hallucination - thhere is no such callConnected event handler with callId provided
@User
s
On call-start event you can get the call id using
window.vapiSDK.vapi.call._meetingSessionSummary.id
.
3 Views