0
votes

I use Twilio to make phone calls during which the user can reply by pressing key. My problem is that I want to manage 4 cases:

1) the user answer and press 1

2) the user answer and press another key than 1

3) the user answer and press no key

4) the user don't answer

For cases 1, 2 and 3, everything is OK: I have a "Gather" in my XML, with an "action" URL, a time-out and a actionOnEmptyResult="true"

For managing case 4, I use a statusCallback url, with 'statusCallbackEvent' => ['answered','completed']

What I notice in my Log is that I receive exactly the same data in case 3 (user answer but press nothing) and in case 4 (user don't answer the call). Maybe this came from the fact after a few "rings" the call fall in voice-box, fooling Twilio which believe it's an "answer" event.

In my LOG I see (case 3 or 4) this 3 events:

  • Call to my statusCallback with CallStatus = in-progress

  • Call to my return hook with msg = Gather End and Digits = ""

  • Call to my statusCallback with CallStatus = completed

So my question is: how can I know the difference between "answer the call and press nothing" and "don't answer the call" ?

Edit: if I refuse the call, result is the same. So I get the same "hook" and statusCallback call, with same data if the user pick-up and give no reply, if he doesn't pick up or if he refuses the call...

1

1 Answers

0
votes

Twilio developer evangelist here.

You may want to handle the "doesn't answer the call" slightly differently. If the user doesn't answer, your action URL is still called but the parameter CallStatus sent to the webhook will be no-answer. In this case you can <Hangup/> the call and mark it as not answered.

There is one other issue. If the call is answered by a voicemail then your call will attempt to continue as normal. You can put this down as a call that was answered but didn't enter anything, or you can try using Twilio's answer machine detection to detect whether a human or machine answered the call. If it's a human you continue as usual, but if a machine answers you can also mark it as not answered and <Hangup/> the call.

Let me know if this helps at all.