0
votes

I was setting up Status Callbacks for calls in nodeJS. I've set the 'CALL STATUS CHANGES' in phone number configuration to do a POST request to my node. But twilio seems to be sending call status completed for all calls no matter is the answer was 'busy', 'unanswered' or 'completed'.

Here's my node code for displaying call status sent by Twilio:

app.post("/status", (req, res) => {
  res.sendStatus(200);
  console.log(req.body);
});

Output for a busy call:

{
   ApiVersion: '2010-04-01',
   Called: '',
   CallStatus: 'completed',
   Duration: '15',
   From: 'client:AbrasiveHannahLiberty',
   CallDuration: '15',
   Direction: 'inbound',
   Timestamp: 'Fri, 20 Mar 2020 05:43:09 +0000',
   AccountSid: 'ACxxxxxxxx',
   CallbackSource: 'call-progress-events',
   ApplicationSid: 'APxxxxxxxx',
   Caller: 'client:AbrasiveHannahLiberty',
   SequenceNumber: '0',
   To: '',
   CallSid: 'CAxxxxxxxx'
 }

1

1 Answers

1
votes

Twilio client calls have two call legs. When the Twilio client places an outbound call, that is the parent leg. Twilio automatically answers that call leg, so the TwiML associated with your Voice Request URL can be accessed, all calls will result in completed calls.

Once the client call is placed, the TwiML Application you defined (and convey to your Twilio Client via the Access Token) has a Request URL which is used to obtain TwiML, so Twilio knows what to do with the call and for example, places an outbound call to the public switched telephone network (PSTN), the child leg.

It is the TwiML in that Request URL that should use a Dial verb with Number noun and the statusCallback URL to get the status you are looking for.

TwiML™ Voice: Number