1

Im creating an andoid app with twilio calling capability. I have a python backend to handle incoming and outgoing requests. I've created a Twiml app to handle outgoing calls, including the call status.

enter image description here

Also I've configured the phone numbers to handle incoming calls including call status as below: enter image description here

So the way it works is:

outgoing: Android app call -> twilio -> python backend -> twilio -> callee

inbound: caller -> twilio -> python backend -> twilio -> android app

On android, I'm using the following method to initiate the voice call:

params.put("to", dialledNumber);
ConnectOptions connectOptions = new ConnectOptions.Builder(callingLCNToken).params(params).build();
activeCall = Voice.connect(VoiceActivity.this, connectOptions, callListener);

On the python side, I have the following sample code to handle outgoing calls:

resp = VoiceResponse()
_to = request.values.get("to")
_from = request.values['From'].split(":")[1]
resp.dial(callerId=_from).number(_to)
return str(resp)

But I can't still capture the statuses: busy, no-answer, cancelled, failed as mentioned in this doc: https://support.twilio.com/hc/en-us/articles/223132547-What-are-the-Possible-Call-Statuses-and-What-do-They-Mean-

Also I want to get the during of call in-progress. But with the current status callback, it seems i'm getting the total time from call initialisation and completion.

I tried using StatusCallbackEvent and the callback URL there, but it didn't work either.

What should I do to get the correct call statuses and the call in-progress duration?

KTB
  • 1,499
  • 6
  • 27
  • 43

1 Answers1

1

Twilio developer evangelist here.

I think the status callback URL you set up in the number admin is for inbound calls. You should set status callback URLs for outbound calls on the <Number> TwiML like this:

resp = VoiceResponse()
_to = request.values.get("to")
_from = request.values['From'].split(":")[1]
dial = resp.dial(callerId=_from)
dial.number(
  _to,
  status_callback_event='initiated ringing answered completed',
  status_callback='https://example.com/callStatus'
)
return str(resp)
philnash
  • 70,667
  • 10
  • 60
  • 88