2
votes

I have the following code that creates both a JS Twilio Client as well as a JS Twilio Worker using the JS API.

function setup(workerToken, capabilityToken) {
  Twilio.Device.setup(capabilityToken, {debug: true, closeProtection: true});
  const worker = new Twilio.TaskRouter.Worker(workerToken);

  Twilio.Device.incoming(function (conn) {
    conn.accept();
  });

  worker.on('reservation.created', (reservation) => {    
    reservation.dequeue();
  });
}

According to the documentation (https://www.twilio.com/docs/api/taskrouter/worker-js#reservation-dequeue) I should be able to just dequeue the reservation and the contact_uri on Twilio for the worker should be connected to. I was successfully able to connect to another phone number but I'm wondering how to connect to my Twilio Client given my identity is "cool.beans" for example.

1

1 Answers

0
votes

Twilio developer evangelist here.

In order to dequeue to a worker and make a call to the Client JS you need to set the worker's contact_uri to the Twilio Client identity. Twilio Client identities can only contain alphanumeric and underscore characters though, so your example of cool.beans won't work.

In your case you'll need to update the Client identity to something without a ., like cool_beans for example. The contact_uri should then be client:cool_beans.

Let me know if that helps at all.