Forwarding twilio to unanswered voicemail

I would like advice on twilio setup for the problem I'm trying to solve.

Overview:

Each user in our system is provided with a twilio phone number, which they can transfer to someone to contact them.

If personA contacts the user on our system (userB) using the provided twilio phone number, we would like to associate them with userB, if available. If userB is not available, we would like to direct personA to voicemail. In other words, we want to make sure that we have control over voicemail and voicemail itself so that we can store it on our system, instead of leaving voicemail on userB.

Current solution:

  • An incoming PersonA call is added to the queue. At the same time, the system is gaining userB.
  • UserB will ask you to press 1 to accept the call. The reason for explicitly writing from UserB is to determine if UserB is available to answer the call. (For example, if a UserB call goes to their personal voicemail, an explicit record of the numbers will not occur, telling us that they are not available for answering.)
  • If UserB does not enter 1 for a certain period of time, PersonA is sent to voicemail.
  • If UserB presses 1, the UserB call is changed (via twilio rest api) to dial the queue with which PersonA is connected to connect UserB and PersonA.

Problem with current solution:

In this solution, the control of when to redirect the user's call to voicemail is controlled by the result of the UserB call, which seems suboptimal. For example, we cannot call UserB at all. In this case, personA will remain in the queue indefinitely.

What I would like to do in this case is to interrogate the identity of the person in the queue to check the time in the queue, and forward the call to voicemail if the time in the queue is greater than the threshold. However, it seems impossible to know exactly how long the call has been disconnected in the queue because:

  • The status of the call in the queue is in-progress , even if the caller listens to music on hold. This is the same status as PersonA's answer.

  • If the UserB dials the number in the queue, the call is canceled only when the bridge sides are disconnected, without changing the call state of the PersonA call, to indicate that they were connected to the UserB.

Questions

  • I understand why I can’t interrogate the call queue in order to properly forward calls to voicemail?
  • Should I instead of calling PersonA to the conference, and if UserB is available, linking him / her to the conference that PersonA is in?
  • If I use conference setup, what is an easy way to determine how long PersonA expects at a conference to forward a PersonA call to voicemail when UserB never joins the conference?
+8
twilio
source share
1 answer

Twilio evangelist developer is here.

I think you might have too complicated things in line. In fact, you can provide a message and get together as part of the initial call without having to dial and ultimately connect the two calls.

Here's how:

Your incoming TwiML call should look like this:

 <Response> <Dial action="/call_complete" timeout="30"> <Number url="/whisper"> ONWARD DIAL NUMBER </Number> </Dial> </Response> 

Providing the noun <Number> URL will play the TwiML content of that URL before the two calls are connected. You can use <Gather> here to make sure the user answers the call, and not to their voicemail system:

 /whisper <Response> <Gather numDigits="1" timeout="10" action="/gather_result"> <Say voice="alice">You are receiving a call, press any key to accept</Say> </Gather> <Hangup/> </Response> 

/gather_result needs to determine if the key is pressed or not. If it was pressed, we proceed to the call, which we can make with an empty answer, since this returns control to the original <Dial> . If the number has not been pressed, we end this end, which forces the original <Dial> to complete and direct it to the action attribute. (I'm not sure what language you work in, but here's some Rubyish pseudo code)

 /gather_result <Response> if params["Digits"] and params["Digits"].empty? <Hangup/> end </Response> 

/call_complete then called after the completion of the <Dial> action. If the call status at this point is “completed” or “answered”, the user picked up the call and answered the whisper correctly, and we can hang up. If this is something else, we will redirect our call to our answering machine.

 /call_complete <Response> if params["DialCallStatus"] == "completed" or params["DialCallStatus"] == "answered" <Hangup/> else <Say voice="alice">The call could not be answered this time, please leave a message</Say> <Record action="/record_complete" /> end </Response> 

Then finally your action /record_complete can do everything you need with the record url and hang up the call.

 /record_complete <Response> <Hangup/> </Response> 

This can be achieved using Twimlets, as described in this blog post . Let me know if that helps at all.

+11
source share

All Articles