Using with React.js?
stuyy opened this issue · comments
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
This leads me to wonder a few things:
- Are these two packages entirely different and have no overlap in terms of connecting to the WebSocket server?
- 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
andsigningKeySecret
which is very ambiguous and I was not able to find anything regarding these two terms in the docs or on Twilio Console. - 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?