Newbie to Twilio here. I'm calling a user via calls.create:
client.calls.create(options)
.then((call) => {
console.log('Call ID='+call.sid);
response.send('Dialing User at '+userPhone);
})
and then calling a second person and connecting the calls together via dial.number:
app.post('/outbound/:calleeNumber', function(request, response) {
const calleeNumber = request.params.calleeNumber;
const twimlResponse = new VoiceResponse();
twimlResponse.say('Thank you for calling. Please hold while we connect you.',
{ voice: 'woman' });
const dial = twimlResponse.dial({action:'http://' + request.headers.host + '/calleeendscall'});
dial.number({url:'http://' + request.headers.host + '/screencall'}, calleeNumber);
response.send(twimlResponse.toString());
});
If the second callee hangs up first, I can play a message to the first from within the url specified by the "action" parameter of .dial. However, if the FIRST callee hangs up first, the call is ended immediately. Is there any way I can catch the second callee before the call is disconnected and play a "they hung up, thanks for calling" message?