[BUG] In my application using Twilio Voice JavaScript SDK 2.6.0, when the receiver ends a call, the dialer does not receive the disconnect event. Although the dialer hears the 'call ended' voice notification, the UI does not update to reflect the call's end." #234
In my application using Twilio Voice JavaScript SDK 2.6.0, when the receiver ends a call, the dialer does not receive the disconnect event. Although the dialer hears the 'call ended' voice notification, the UI does not update to reflect the call's end."
this is twillio web hooks
async incomingCall(siteOrigin: string, data: any, direction: string) {
data.Direction = direction;
await this.saveCallLog(data, 'incoming', siteOrigin);
// Check if the call was never answered (missed call)
if (this._callStatus === 'incoming') {
console.log('Missed call');
// Handle the missed call scenario
}
// Update and emit call status
this._callStatus = 'ended';
this._call = null;
this.currentCallNext('', '', this._call);
});
}
diconect event not working
In my application using Twilio Voice JavaScript SDK 2.6.0, when the receiver ends a call, the dialer does not receive the disconnect event. Although the dialer hears the 'call ended' voice notification, the UI does not update to reflect the call's end." this is twillio web hooks async incomingCall(siteOrigin: string, data: any, direction: string) { data.Direction = direction; await this.saveCallLog(data, 'incoming', siteOrigin);
const clientDetails = await this.clientService.getClientIdsByPhonenumber( siteOrigin, data.To, ); const userIds = clientDetails.map((client) => client.userId) || []; const twiml = new twilio.twiml.VoiceResponse(); //https://${origin}:3000 const dial = twiml.dial({ record: 'record-from-ringing', action:
https://url/atmos-api/v1/voicemail-twiml-voice/${data.To}
, method: 'POST', });userIds.forEach((userId: string) => { const client = dial.client({ statusCallbackEvent: ['initiated', 'ringing', 'answered', 'completed'], }); const entryData = {};
client.identity(
user${userId}
); client.parameter({ name: 'entry_data', value: JSON.stringify(entryData), }); });data.user_id = userIds.join(','); // Update call log this.updateCallLog(siteOrigin, data); return twiml.toString(); } dial action end point function call async generateVoicemailTwiML(phoneNumber: string, req: any) { console.log("Request body:", req.body); const voiceResponse = new twilio.twiml.VoiceResponse(); const phoneSetting = await this.twilioPhoneNumberModel .findOne({ phoneNumber: phoneNumber }) .exec();
if (!phoneSetting) { console.log("Phone settings not found for number:", phoneNumber); return; }
console.log("Dial Call Status:", req.body.DialCallStatus); if (req.body.DialCallStatus === 'completed') { console.log("Call is completed, hanging up."); voiceResponse.hangup(); } else { if (phoneSetting.voicemailEnabled) { if (phoneSetting.voicemailType === 'recording') { console.log("Playing voicemail recording."); voiceResponse.play(phoneSetting.voicemailGreetingMessage.voiceFilePath); } else { console.log("Saying voicemail message."); voiceResponse.say(phoneSetting.voicemailGreetingMessage.text);
} voiceResponse.hangup(); } const twimlString = voiceResponse.toString(); console.log("Generated TwiML:", twimlString); return twimlString; } Angular frontened // Method to handle incoming call events handleIncomingCall(call: any): void { this._call = call;
this._callStatus = 'incoming'; this.currentCallNext(call.parameters['To'], call.parameters['From'], call);
call.on('accept', (call: Call) => { console.log('Call accepted'); this._call = call;
// Update and emit call status this._callStatus = 'active'; this.currentCallNext(call.parameters['To'], call.parameters['From'], call); });
call.on('reject', () => { console.log('Call rejected'); this._callStatus = 'rejected'; this.currentCallNext('', '', null); });
call.on('disconnect', () => { console.log('Call ended');
// Check if the call was never answered (missed call) if (this._callStatus === 'incoming') { console.log('Missed call'); // Handle the missed call scenario }
// Update and emit call status this._callStatus = 'ended'; this._call = null; this.currentCallNext('', '', this._call); }); } diconect event not working
Originally posted by @afnanjanjua in https://github.com/twilio/twilio-voice.js/issues/109#issuecomment-1854367365