How can I handle reaching voicemail using Twilio's <dial> verb

試著忘記壹切 提交于 2019-12-13 19:00:55

问题


I know that on making a call Twilio can detect an answering machine, and react differently.

However if I use the <dial> verb, there's no obvious place to add this feature, even though it's essentially the same thing.

My intended flow is:

  • Customer enters their phone number
  • Twilio calls Customer and plays a voice message
  • Twilio dials an agent number, likely a mobile
  • If the Agent picks up, connect the customer to the agent
  • If the Agent busies the call or does not answer, call will likely go to Agent's voicemail.
    • Terminate call to Agent
    • Record voicemail from Customer
    • Email voicemail to Agent

回答1:


From the official docs on the <Dial> verb (emphasis mine):

This is the simplest case for Dial. Twilio will dial 415-123-4567. If someone answers, Twilio will connect the caller to the called party. If the caller hangs up, the Twilio session ends. If the line is busy, if there is no answer, or if the called party hangs up, <Dial> exits and the <Say> verb is executed for the caller before the call flow ends.

<?xml version="1.0" encoding="UTF-8"?>
<!-- page located at http://example.com/simple_dial.xml -->
<Response>
    <Dial>415-123-4567</Dial>
    <Say>Goodbye</Say>
</Response>

Placing a <Record> verb after the <Say> verb sounds like what you are looking for. You can change the timeout from the default value of 30s like this:

<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Dial timeout="9001">415-123-4567</Dial>
    <Say>Please leave a message</Say>
    <Record action="/process_new_voicemail" />
</Response>



回答2:


I am sure this is late, but hopefully it helps some one out. It sounds like you may just need to screen the call. Basically, you can ask the "agent" that you dialed to accept the call and hang up if you do not receive input.

I am not sure what language you are using, but here is a great php/Laravel tutorial to explain: https://www.twilio.com/docs/tutorials/walkthrough/ivr-screening/php/laravel

The key part is here:

$dialCommand = $response->dial(
    ['action' => route('agent-voicemail', ['agent' => $agent->id], false),
     'method' => 'POST']
);
$dialCommand->number(
    $numberToDial,
    ['url' => route('screen-call', [], false)]
);

Notice that the dial command uses the 'action' to specify a location that is sent a POST request should the call end i.e POST to /agent-voicemail.

Then, the number is dialed along with a 'url' parameter this is the location that will be requested after the agent has picked up but before connecting the two parties.

The /screen-call route then asks the agent to accept the call, if no input is received it hangs up and will make a POST request to the initial setup /agent-voicemail route.

This method will handle your scenario because if it goes to voicemail no input will be received and the call will end.



来源:https://stackoverflow.com/questions/33921659/how-can-i-handle-reaching-voicemail-using-twilios-dial-verb

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