Redirect Twilio call to voicemail if all Workers explicitly rejected the reservation

那年仲夏 提交于 2019-12-11 07:07:21

问题


I'm using Twilio Task Routing to route calls to available Workers with a custom app UI built using TaskRouting.js.

Let's say I have 2 Idle Workers and a call comes in.

  1. UI shows a screen Accept or Reject on both workers' screens
  2. Worker 1 hits reject
  3. Worker 2 hits reject
  4. At this point, the task apparently goes back into the task routing queue and steps 2 and 3 are repeated.

After all workers rejected a call, how do I redirect it to voicemail instead?


回答1:


Twilio developer evangelist here.

I would achieve this by adding a new array attribute to your Task to record the SIDs of the workers that rejected the task. Then, when a worker rejects the reservation, adding to that attribute on the task.

Then you can add to your target expression:

worker.sid NOT IN task.rejected_workers

Once the task fails that expression, move it to a new queue that has one idle worker that rather than accepting reservations, just redirects the call off to some TwiML to <Record> the voicemail.

Let me know if that helps at all.

Edit

Turned out that wasn't exactly the right way to achieve this as, even if the target worker expression doesn't match any workers the Task will wait until there's a timeout at the filter level they have got to. The way I've described is really useful if you want to ensure that the call isn't directed to the same worker twice.

So, instead I recommend you still keep the list of workers that have rejected the task and each time there is another rejection, evaluate the workers in the queue and whether your Task's attribute now covers all the workers, ie it has been rejected by everyone. If so, set another attribute, something like "totallyRejected": true. Then, add to your original filter expression:

totallyRejected == false

Then, when a task has been totally rejected it will fail the expression and go on to the next filter.



来源:https://stackoverflow.com/questions/46044542/redirect-twilio-call-to-voicemail-if-all-workers-explicitly-rejected-the-reserva

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!