简体   繁体   中英

How to connect the incoming call after accepting a reservation through Twilio Task Router?

I'm able to follow Twilio TaskRouter example to accept reservations:

import { Worker } from 'twilio-taskrouter'


const worker = new Worker(token);

worker.on("reservationCreated", async function (reservation) {
  console.log('reserved', reservation)
  await reservation.dequeue()
});

The incoming call reservation comes through and reaches the agent properly. But I'm not clear how to actually answer the incoming call after this. The documentation says calling dequeue() will perform telephony but seems like there are more needs to be done to actually answer the call?

I also tried to create a Twilio Device. But based on my understanding, that requires a TwiML app, but I'm also not sure how to hook up the TwiML with the TaskRouter; nor I'm not sure I'm in the right path.

I actually figured it out by trying many diff SDK and code examples as the docs's not super clear.

Apparently we'd need to create a Device with its access token having the identity of the worker's contact_uri's client id.

"contact_uri":"client:a_worker_user_name"

When creating device access token:

const token = new AccessToken(
  twilioAccountSid,
  twilioApiKey,
  twilioApiSecret,
  { identity: "a_worker_user_name" }
);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM