Вопрос

I am writing a node.js application to make a call or send sms to users.

However, after making a call or sending SMS, I wish to know its status.

client.makeCall({
    to:'+358xxxxxxxxx', 
    from: '+15005550006', 
    url: "https://demo.twilio.com/welcome/voice/",
}, function(err, responseData) {
}

I know on responseData, but its status indicates 'Queued' I wish to know the real call status after the actual call takes place. Is there anyway to do so?

Это было полезно?

Решение

I haven't used twilio node.js client, but here's some that might help you -

You are not getting the call status because the voice call or SMS wont complete immediately when the API call is returned. You need to make subsequent requests again until the status is complete (polling) or configure twilio/pass parameters so that twilio will notify you when the call is actually complete (push).

To let twilio push the status to your server, pass application_sid or status_callback field while making the call request as explained in the API doc http://www.twilio.com/docs/api/rest/making-calls.

To manually request the call status, do the get request from the client after few seconds (or whatever time you think call takes to complete) perhaps using a timer until you get the status you want. http://www.twilio.com/docs/api/rest/call

Something like below: (Note: I have not tested or verified this)

client.calls(<sid>).get(function(err, call) {
    console.log(call.status);
});
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top