检索的Answered_By响应为null [英] Retrieved Answered_By response as null
问题描述
我正在跟踪Twilio今年最近在API中引入的答录机检测Beta功能.我将MachineDetection字段设置为 Enable
并将MachineDetectionTimeout设置为5秒.当我使用Node.JS中的 request-promise
包发出请求时,以下输出作为JSON主体对象返回:
I'm following the Answering Machine Detection Beta feature Twilio recently introduced to the API this year. I set the MachineDetection field to Enable
and set the MachineDetectionTimeout to 5 seconds. When I make the request using the request-promise
package in Node.JS, the following output is returned as a JSON body object:
{"sid": "MYSID",
"to": "+1845555555",
"to_formatted": "(845) 555-5555",
"from": "+18569972628", "from_formatted": "(856) 997-2628",
"phone_number_sid": null,
"status": "queued"
"start_time": null,
"end_time": null,
"duration": null,
"price": null,
"price_unit": "USD",
"direction": "outbound-api",
"answered_by": null,
"api_version": "2010-04-01",
"annotation": null,
"forwarded_from": null,
"group_sid": null, "caller_name": null,
"uri": "/2010-04-01/Accounts/mySIDaccount/Calls/C
A303d158baf885d4480284d4529ce49a8.json",
"subresource_uris":
{"notifications": "/2010-04\
01/Accounts/myaccount/Calls/\
CA303d158baf885d448028\
4d4529ce49a8/Notifications.json",
"recordings": "/2010-04 \
01/Accounts/myaccount/Calls/\
CA303d158baf885d4480284d4529ce49a8/Recordings.json"}
}
answered_by
的值为 null
,而不是指定为从请求(Twilio-API文档):
The answered_by
value is null
instead` of one of the 4 values specified to return back from the request (Twilio-API documentation):
- machine_start
- 人类
- 传真
- 未知
我做错什么了吗?我的申请路线如下图所示:
Am I doing something wrong? My application route is as shown below:
var request = require('request-promise');
request.post({url: 'https://api.twilio.com/2010-04-01/Accounts/'+
config.accountSid+"/Calls.json",
form: {To: phoneNumber,
From: config.twilioNumber,
MachineDetection: 'Enable',
MachineDetectionTimout: 5,
Url: url},
auth: {user: config.accountSid,
pass: config.authToken
},
timeout: 10000
}).then(function(parsedBody){
console.log('\n\n\n\n'+parsedBody+'\n\n\n\n');
response.send({message: 'Transferring...'});
}).catch(function(parsedBody){
console.log(parsedBody);
response.status(500).send(parsedBody);
});
});
我什至尝试了bash上的卷曲路线,并得出了完全相同的结果.
I even tried the curl route on my bash and came up with the exact same results.
推荐答案
此处是Twilio开发人员的福音.
Twilio developer evangelist here.
按您的方式发出请求开始通话时,在此示例中,API将成功响应以告知您调用已开始.在此阶段,呼叫甚至可能没有振铃,因此您还不知道应答机检测的结果.
When you make the request to start a call, as you are doing in this example, the API will respond successfully to let you know that the call has been started. At this stage the call may not even be ringing, so you can't know the result of the answer machine detection yet.
相反,当呼叫连接并且Twilio(如果是计算机)或其他计算机已经解决,或者应答机检测超时时,您将得到 AnsweredBy
的结果.您将获得 AnsweredBy 代码>会导致Twilio通过您在请求中设置的URL发送到您的应用程序的Webhook
.在这个阶段,您可以决定如何处理呼叫.
Instead, you will get the result of AnsweredBy
when the call connects and Twilio has either worked out if it is a machine or otherwise, or the answering machine detection times out. You will get the AnsweredBy
result in the webhook that Twilio sends to your application at the URL you set in the request. It is at that stage that you can decide what to do with the call.
让我知道这是否有帮助.
Let me know if that helps at all.
这篇关于检索的Answered_By响应为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!