Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twilio TaskRouter JS SDK not working

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
like image 943
SamDev Avatar asked May 17 '18 07:05

SamDev


1 Answers

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.

like image 172
SamDev Avatar answered Nov 18 '22 07:11

SamDev