0
votes

With twilio Api I am trying implement the following:

  1. Agent Clicks number in a list to dial through twilio javaacript web client
  2. If receiver is not available and his answering machine responds back then agent have an option to click button on my website to play prerecorded audio that will be left on his machine

But I am not able to transfer a call to prerecorded audio. What i tried so far is updating in progress call to page which outputs twiml play verb as below:

<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Play>https://mywebsite.com/audio.mp3</Play>
</Response>

But as soon as call is redirected to above twiml, reciever phone seems to be disconnected and no prerecorded audio is left to his voicemail, instead audio is played back to agent(caller).

I tried updating both parent call and child call(obtained from parentsid and child sid) , But it doesn't seem to work.

My php code for updating call:

$client->calls($callSid)->update([
      'url' => route('twilio.play-vm'),
      'StatusCallback' => route('twillo.call-complete')
 ]);

//Trying with child call
$childCall = $client->calls->read(['parentCallSid' => $callSid])[0];
$childCall->update([
          'record' => true,
          'url' => route('twilio.play-vm'),
          'StatusCallback' => route('twillo.call-complete')
]);  
1
from the way you are describing it , it sounds like you are not actually updating the child sid or you are updating it with the wrong valueA-Developer-Has-No-Name
How are you getting the child callsid? The Twiml looks correct the PHP for modifying the call looks right, so I'd agree w/ @A-Developer-Has-No-Name that it seems like maybe the wrong callsid is getting update. You should be able to get the child callsid from the statusCallback webhook of the <Number> noun.Devin Rader

1 Answers

0
votes

Twilio developer evangelist here.

Have you thought about using Answering Machine Detection (AMD)?

In your scenario I can see you a couple different ways.

  1. Have the agents button click tell your application to use the REST API to initiate an outbound call to your customer with AMD enabled. If the AMD webhook tells you a human has answered return a <Dial> back to Twilio that tells use to call the agent and connect them to the customer. Otherwise return the <Play> to Twilio.

  2. Have the agents button click tell your application start a call from their app, but when Twilio answers <Dial> the agent into an conference call. At the same time you have your app use the REST API to initiate an outbound call to the customer using AMD. In the AMD webhook, if a human is detected <Dial> that call into the existing conference with the agent. Otherwise <Play> your audio file.

Hope that helps.