我正在关注今年最近向API推出的应答机检测测试版功能Twilio。我将MachineDetection字段设置为Enable
并将MachineDetectionTimeout设置为5秒。当我使用Node.JS中的request-promise
包发出请求时,以下输出作为JSON正文对象返回:
{"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 documentation)返回的4个值中的一个:
我做错了吗?我的申请路线如下所示:
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上尝试了卷曲路线,并得出了完全相同的结果。
答案 0 :(得分:0)
Twilio开发者传道者在这里。
当您在此示例中执行request to start a call时,API将成功响应以通知您已启动该呼叫。在这个阶段,呼叫可能甚至不响,因此您无法知道答案机检测的结果。
相反,当呼叫连接时,您将获得AnsweredBy
的结果,如果Twilio是机器或其他方式,或者应答机检测超时,则会得到结果。您将获得Twilio通过您在请求中设置的URL发送到您的应用程序的AnsweredBy
result in the webhook。在这个阶段,您可以决定如何处理呼叫。
让我知道这是否有帮助。