16
votes

According to Twilio Docs I'm trying develop a Call-center Application But The 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 & If I remove .task It returns respective output related to task But here I expect reservation related output.

Below are twilio client SDK are currently used in my application.

  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
1
The code you've shared is exactly as it appears in your application?thanksd
@thanksd yes, this event trigger at the time taskrouter create reservation but reservation.task.attributes, ... values are not found & reservation.sid providing task.sid value!!!.SamDev
This is very unusual that how a cloud messaging provider don't support it's won technical documentation & also I'm going to create the technical support ticket - Twilio.SamDev
Can you share the link for your support ticket?thanksd
@thanksd According to Twilio ticket response "As per discussion with engineering, the issue is that you are including media.twiliocdn.com/taskrouter/js/v1.0/taskrouter.worker.min.js in your application. If you remove that, everything is expected to work as documented. It looks to be an old version of the SDK, and it initially returned a task object instead of a reservation for the method mentioned. Because both the old and the current are included, the old is overwriting some of the functions used by the current SDK."SamDev

1 Answers

1
votes

There was two different issue but It related to each other.

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

This resolve all of my issue.