Currently, I am in the process of utilizing the Twilio Programmable Voice JavaScript SDK to initiate an outbound call with a statusCallback and statusCallbackEvent in order to update another system once the call is finished.
Below is the snippet of my code.
async function makeOutgoingCall() {
const params = {
// fetching the phone number to dial from the DOM
To: phoneNumberInput.value,
CallerId: myCallerId,
statusCallback: OutBoundCallbackURL,
statusCallbackEvent: 'completed'
};
console.log(params);
if (device) {
log(`Attempting to call ${params.To} from caller id: ${params.CallerId} ...`);
// Twilio.Device.connect() yields a Call object
const call = await device.connect({ params });
dtmf_1.onclick = function(){call.sendDigits('1')};
dtmf_2.onclick = function(){call.sendDigits('2')};
dtmf_3.onclick = function(){call.sendDigits('3')};
dtmf_4.onclick = function(){call.sendDigits('4')};
dtmf_5.onclick = function(){call.sendDigits('5')};
dtmf_6.onclick = function(){call.sendDigits('6')};
dtmf_7.onclick = function(){call.sendDigits('7')};
dtmf_8.onclick = function(){call.sendDigits('8')};
dtmf_9.onclick = function(){call.sendDigits('9')};
dtmf_0.onclick = function(){call.sendDigits('0')};
dtmf_s.onclick = function(){call.sendDigits('*')};
dtmf_h.onclick = function(){call.sendDigits('#')};
/*
* append listeners to the Call
* "accepted" indicates the call has been successfully connected and the state is now "open"
*/
call.on('accept', updateUIAcceptedOutgoingCall);
call.on('disconnect', updateUIDisconnectedOutgoingCall);
call.on('cancel', updateUIDisconnectedOutgoingCall);
call.on('reject', updateUIDisconnectedOutgoingCall);
outgoingCallHangupButton.onclick = () => {
log('Hanging up ...');
call.disconnect();
};
} else {
log('Unable to initiate call.');
}
}
I am aiming for it to return TwiML in the following format:
<Response>
<Dial answerOnBridge="true" callerId="+19876543210">
<Number
statusCallbackEvent="completed"
statusCallback="https://myapp.com/calls/events"
statusCallbackMethod="POST">
+12349013030
</Number>
</Dial>
</Response>
Unfortunately, it is instead returning the following:
<Response>
<Dial answerOnBridge="true" callerId="+19876543210">
<Number>+1123456789</Number>
</Dial>
</Response>
I have been unable to locate a comprehensive list of potential parameters for device.connect(). I am unsure if that's the aspect I need to modify.
Could someone provide assistance with this issue?