twilio / twilio-taskrouter.js

JS SDK v2 for Twilio's TaskRouter skills based routing system.

Home Page:https://www.twilio.com/docs/taskrouter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using with React.js?

stuyy opened this issue · comments

commented

Hi. I'm trying to experiment with this package in React.js. Following the docs from https://www.twilio.com/docs/taskrouter/js-sdk/workspace/worker#how-does-it-work I am successful in generating a capability token and then using it as the WORKER_TOKEN variable that is passed in as an argument to TaskRouter.Worker's constructor. In a vanilla HTML/JS file, I imported the url-hosted package for taskrouter from here: https://sdk.twilio.com/js/taskrouter/v1.21/taskrouter.min.js. I can connect to the WebSocket server successfully and receive a ready event when connected.

However, when trying to use twilio-taskrouter package installed via npm on a React project, I am not able to connect to the WebSocket server successfully despite generating the access token the same way it was instructed in the code here: https://www.twilio.com/docs/taskrouter/js-sdk/workspace/worker?code-sample=code-creating-a-taskrouter-worker-capability-token&code-language=Node.js&code-sdk-version=3.x

image

This leads me to wonder a few things:

  1. Are these two packages entirely different and have no overlap in terms of connecting to the WebSocket server?
  2. Does the new package have an entirely new way of authenticating the client to connect to the WebSocket server? On TaskRouter.js docs, it mentions to create a capability token, which you can do on a Web Server and request it from the client via HTTP and use it to connect to the WebSocket server. In this new package, it mentions a few additional parameters, such as a signingKeySid and signingKeySecret which is very ambiguous and I was not able to find anything regarding these two terms in the docs or on Twilio Console.
  3. If this library currently does not support React, will it in the future? If it does, is there a sample recipe we can use for reference that can be later added to TaskRouter's docs?

Hey @stuyy , thanks for your question. Just to close on this old issue:

  1. Yes, these are two different packages, one is v1 and this one is v2
  2. Yes, authentification methods are different
  3. This library does support React and we'll update docs for v2 very soon.