Reputation: 307
My use case is as follows: allow a user to enter multiple points of contact. Try the first point of contact, if that the user does not answer, try the second, etc.
The issue I am running into is that Twilio does not seem to have a reliable way to determine if a human answered the phone. I have tried three different things:
IfMachine - this works fairly reliably, but I have tested on phones that cause it to think it is a human. I really need 100% accuracy here.
StatusCallbackEvents - I have Status events being posted to a public end point. I was hoping that there would be some information here that is helpful, but it does not seem so.
Manual Determination - I thought some combination of the status/duration would work, but the duration seems to be the same in some situations where the human or voice mail answers. My guess is a voice mail is answering, but Twilio thinks it is a person, so it plays the message and gets the same duration as if a human had answered.
"Call Screening" AKA Reverse IfMachine - I have this working, where the user is asked to press a key and after pressing the key gets another message. But, the fact that the user pressed the key is not logged anywhere. Not in the response object or in the StatusCallbackEvents.
My highest hope at the moment is that the Call Screening holds the data (the fact that the user pressed the key) somewhere that I can access.
Upvotes: 1
Views: 590
Reputation: 73027
Twilio developer evangelist here.
Thanks to Simon for the answer. I just wanted to provide a bit more detail.
To use <Gather>
and get the digits that the user entered you do indeed need to set an action
attribute to a URL that your app can respond to.
<Response>
<Gather action="/is_human" numDigits="1">
<Say>This is a call for a human! If you are a human, press 1.</Say>
<Gather>
<Say>Did not receive input</Say>
<Hangup/>
</Response>
Then, your action will receive an HTTP request like other webhooks in a phone conversation, but including one more parameter, Digits
which will include the digits the user pressed.
Let me know if this helps at all.
Upvotes: 1
Reputation: 2423
If you do not want to rely on the Twilio machine|human detection, I believe the dial-a-number is the best approach.
If you are using TwiML, you can set a callback on the <gather>
tag.
https://www.twilio.com/docs/api/twiml/gather
The <Gather> verb collects digits that a caller enters into his or her telephone keypad. When the caller is done entering data, Twilio submits that data to the provided 'action' URL
Upvotes: 2