With twilio Api I am trying implement the following:
- Agent Clicks number in a list to dial through twilio javaacript web client
- 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')
]);
<Number>
noun. – Devin Rader