Petran
Petran

Reputation: 8057

How can I answer a call on the browser with twilio javascript jdk

I am trying to answer a call that is routed through taskRouter through a worker with no luck.

I call the dequeue of reservation resource on the client, if I use a phone number to the To param works

reservation.dequeue(
    null
    null
    null
    null
    null
    null
    "+1205...."
    (error, r) =>
      if error
        console.log(error)
      else
        console.log(r)
  )

But when I am trying to route to web browser it doesn't work, both of the followings don't work

reservation.dequeue(
    null
    null
    null
    null
    null
    null
    "client:WK6dabefad96...."
    (error, r) =>
      if error
        console.log('error')
        console.log(error)
      else
        console.log('R')
        console.log(r)
  )

 reservation.dequeue(
    null
    null
    null
    null
    null
    null
    null
    (error, r) =>
      if error
        console.log('error')
        console.log(error)
      else
        console.log('R')
        console.log(r)
  )

enter image description here

Upvotes: 0

Views: 46

Answers (1)

Bilal Mehrban
Bilal Mehrban

Reputation: 637

If you are going to send those calls to browser than you need to setup a Twilio Client, you must also set up the devices. You can find more information on Twilio Client documentation.

When generating the client access token while initializing the UI client (the softphone), that the identity value matches the client name in the contact_uri of the worker attribute. e.g. identity = 'WK*****' , when creating the access token and "contact_uri":"client:WK*****" in the worker attribute. I would suggest to use a name in the contact_uri like "contact_uri":"client:bilal".

Upvotes: 1

Related Questions