Twilio TaskRouter JS SDK 不工作

Twilio TaskRouter JS SDK not working

根据 Twilio 文档,我正在尝试开发一个呼叫中心应用程序,但 TaskRouter JS

v1.13/taskrouter.min.js Not supporting as twilio explain in document https://www.twilio.com/docs/taskrouter/js-sdk/worker#reservation-created

worker.on("reservation.created", function(reservation) {
    console.log(reservation.task.attributes)      // NOT FOUND
    console.log(reservation.task.priority)        // NOT FOUND
    console.log(reservation.task.age)             // NOT FOUND
    console.log(reservation.task.sid)             // NOT FOUND
    console.log(reservation.sid)                  // RETURNS task sid
});

reservation.sid print task sid & 如果我删除 .task 它returns 与任务相关的相应输出但在这里我期望与预订相关的输出。

以下是我的应用程序中当前使用的 twilio 客户端 SDK。

  1. https://media.twiliocdn.com/sdk/js/sync/releases/0.5.10/twilio-sync.js
  2. https://media.twiliocdn.com/sdk/js/client/releases/1.4.31/twilio.min.js
  3. https://media.twiliocdn.com/taskrouter/js/v1.13/taskrouter.min.js
  4. https://media.twiliocdn.com/taskrouter/js/v1.0/taskrouter.worker.min.js

有两个不同的问题,但它们相互关联。

First I remove

  1. https://media.twiliocdn.com/taskrouter/js/v1.0/taskrouter.worker.min.js

It fixed

worker.on("reservation.created", function(reservation) {
         console.log(reservation.task.attributes)      // FOUND
         console.log(reservation.task.priority)        // FOUND
         console.log(reservation.task.age)             // FOUND
         console.log(reservation.task.sid)             // FOUND
         console.log(reservation.sid)                  // RETURNS reservation sid 
});

BUT After I remove taskrouter.worker.min.js , I faced another issue (i.e worker event stopped working)

worker.on("ready", function(worker) {
});

Because both version use different key to get event value

  1. /v1.13/taskrouter.min.js for example worker.activityName

  2. /v1.0/taskrouter.worker.min.js for example worker.activity_name

Secondly , I need to update all key according to /v1.13/taskrouter.min.js in my client side Js
For example, Replace worker.activity_name with updated key worker.activityName according to v1.13

这解决了我所有的问题。