我正在使用Taskrouter js 库,更具体地说是worker.js。
this.worker.on("reservation.created", (reservation) => {
reservation.accept()
});
但是,我收到一条错误消息
accept() is not a function
根据此处的文档:https://www.twilio.com/docs/api/taskrouter/worker-js
This will accept the reservation for the worker.
Note: This will NOT perform any telephony. If the task was enqueued using the Enqueue TwiML verb, utilize reservation.dequeue(#reservation-dequeue) to perform telephony and dequeue the call.
reservation.accept(
function(error, reservation) {
if(error) {
console.log(error.code);
console.log(error.message);
return;
}
console.log("reservation accepted");
for (var property in reservation) {
console.log(property+" : "+reservation[property]);
}
}
);
所以我们很困惑,因为预订没有函数accept(),但根据文档它确实如此......那么我如何接受来自js的预订?
最佳答案
为什么你有this.worker.on
?
https://www.twilio.com/docs/api/taskrouter/worker-js#example_6
worker.on("reservation.created", function(reservation) {
console.log(reservation.task.attributes) // {foo: 'bar', baz: 'bang' }
console.log(reservation.task.priority) // 1
console.log(reservation.task.age) // 300
console.log(reservation.task.sid) // WTxxx
console.log(reservation.sid) // WRxxx
});
关于javascript - Twilio TaskRouter - 接受 JS 客户端的预订,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41023103/