serverfaces
serverfaces

Reputation: 1175

Twilio Call Status

How do I know whether or not a call is answered?

For StatusCallback, I can set the following values:

When Twilio sends me statuses, I don't see a value for "answered" what I see are the following:

I'm wondering why there is no status returned for:

though I'm setting "answered" as one of the values for StatusCallback.

What confuses me is that Twilio sends "Completed" irrespective of whether or not the call was answered or not.

I need a definite status for the call being answered. If the call is not answered then I need to retry again later or build a business logic around it.

When the call is not answered, then I get "not-answered".

When the call is answered, then I get "completed", but "completed" does not necessarily mean the call was actually answered assuming that the call went to the voicemail box or something.

On a side note, I am also setting the "IfMachine" parameter in the call request. Though I know that it is an experimental feature, I get the call status as "completed" as in this case, my expectation is "not-answered".

How do I know if the call was actually answered?

Upvotes: 3

Views: 1932

Answers (1)

Megan Speir
Megan Speir

Reputation: 3811

Megan, also from Twilio!

Just wanted to clear a few things up here. You mention using StatusCallback which expects a URL. The answered value is actually set using StatusCallbackEvent as you can see here in the docs.

I don't know what language you're using but an example in Python (you can find other languages on that docs page):

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "YOUR_ACCOUNT_SID"
auth_token  = "YOUR_AUTH_TOKEN"
client = TwilioRestClient(account_sid, auth_token)

call = client.calls.create(
    url="http://demo.twilio.com/docs/voice.xml",
    to="+14155551212",
    from_="+18668675309",
    method="GET",
    status_callback="https://www.myapp.com/events",
    status_callback_method="POST",
    status_events=["initiated", "ringing", "answered", "completed"],
)
print call.sid

And a final note about using IfMachine. For the time being, we actually recommend that you use Twilio's <Gather> verb to detect if a human picks up as explained in this question here.

Hope this helps!

Upvotes: -1

Related Questions