krthkntrjn
12/09/2024, 3:09 PMVapi
12/09/2024, 3:12 PMjavascript
vapiInstance = window.vapiSDK.run({
apiKey: apiKey,
assistant: assistant,
config: buttonConfig,
maxDurationSeconds: maxDurationSeconds
});
// Listen for the 'callStarted' event or similar
vapiInstance.on('callStarted', function(eventData) {
// Access the call ID from the event data
var callId = eventData.callId;
console.log('Call ID:', callId);
// You can now use the callId for your purposes
});
Please replace 'callStarted' and eventData.callId with the actual event name and property provided by the VAPI SDK documentation for obtaining the call ID.
If you're unsure about the exact event name or property, please refer to the VAPI SDK documentation or ask support for more info on this.Vapi
12/09/2024, 3:12 PMkrthkntrjn
12/09/2024, 3:39 PMShubham Bajaj
12/11/2024, 7:50 PMts
const toggleCall = () => {
buttonStateHandler(button, "loading");
if (isActiveCall) {
vapi.stop();
isActiveCall = false;
} else {
if(assistant || assistantOverrides) {
vapi.start(assistant, assistantOverrides);
} else {
console.log('squad ,', squad, assistant, assistantOverrides)
vapi.start(undefined, undefined, squad)
}
isActiveCall = true;
}
};
ts
const call = vapi.start(assistant, assistantOverrides);Shubham Bajaj
12/11/2024, 7:50 PM