I am using Twilio Node.js SDK and Nest.js to develop my application. Currently facing an issue that Twilio programmable voice status callback is firing a wrong status. I need to handle an answered
(in-progress
) event but it is firing immediately after ringing
event even if the call is not answered. I am receiving calls on third-party application, so I think this can caused by the third-party application called Hushed.
Twilio call initializer
async init(to: string, from: string): Promise<string> {
const call = await this.twilio.api.v2010.accounts(<ACCOUNT_SID>).calls.create({
url: `${API_URL}/api/twilio/stream`,
statusCallback: `${API_URL}/api/twilio/statusCallback`,
statusCallbackMethod: 'POST',
statusCallbackEvent: ['initiated', 'ringing', 'answered', 'completed'],
to,
from,
method: 'POST',
record: true,
});
// Rest of my code
return call.sid;
}
TwilioController.ts
@Controller('twilio')
export class TwilioController {
@Post('statusCallback')
statusCallBack(@Req() request: Request): void {
console.log(request.body.CallStatus);
}
}
Log result
initiated
ringing
in-progress # at the same time as "ringing"
completed
According to the documentation it should not work like this.
Twilio Support Engineer here. Most likely what is happening is that the ringback tone coming from the callee side is being played after call answer. This is common when calling PBX systems or telephony systems. One way to confirm this is to call the number from your cell phone. If you see from your cell phone that the number has answered but you are hearing a ringback tone, the same will happen with your status callbacks.