问题
Currently using Twilio TaskRouter to build a telephony call center to route the calls.
My target was:
- When a task kept pending for a certain time(i.e: no workers are available for reservation), redirect it to voicemail
- When a task is reserved but the the worker didn't response to it, redirect it to voicemail
My Current Implementation was:
- Specify both task timeout and reservation timeout
- When task timeout / reservation timeout callback is triggered, query the Redirect Instruction reservation api to redirect it to a TwiML of recording voicemail.
But the problem was:
- When a task is in
pending
status, no reservation was created so that I could not access the reservation to perform a redirect - When a reservation is timed out, trying to perform a redirect would receive an execption from Twilio saying that the reservation was nolonger available for redirecting
回答1:
Twilio developer evangelist here.
There's two issues here, as you've said at the end. You're either trying to move a reservation that doesn't exist or redirecting a reservation that isn't available to redirect.
I think you can achieve your goals by using the workflow instead.
First up, consider the task side of things. You give a task a timeout. When it does timeout the normal behaviour for a task is to move to the next queue that it matches in the workflow.
I'd suggest setting up a final queue that has one permanently available worker object (but not real person) in it. When you get an assignment callback for a reservation for a task in that queue then you can use the redirect assignment to send the call to some TwiML that returns a <Record>
to take a message. Your TwiML application can also call the REST API to accept the reservation.
That works for tasks that are never assigned from the initial queue to a worker. For the reservation timeout side of things, consider this.
When a reservation times out, the task goes back into its original queue for assignment again. The task remains under the same original timeout that we defined for it above, so will eventually move to our voicemail queue when the task itself times out. This has the same effect for the caller, as they never know when a reservation is assigned as they'll just be experiencing the wait music in the queue they are in.
Does that make sense at all?
来源:https://stackoverflow.com/questions/45386440/redirecting-a-twilio-task-to-a-new-twiml-after-task-reservation-timeout