php - twilio play hold music and redirecting to dial -


aim: want when call created should play music instead of ringing , noone available pick call . after playing music should it. after should redirect feedback page

now: call created , mp3 played when pick call , feedback page running when dialling call

so want solution handle this

<?php   if (($nowtime >= $start_time) && ($nowtime <= $end_time)){       $the_mnum = $con ->load_field($the_id, 'the_mnum');       //$m= $the_mnum;       //echo $the_mnum; ?>     <say voice="woman">          directing call therapist.       </say>   <?php       $check_therapist = true;       $_session["the_mnum"] = $the_mnum;       break;     }   }    if ($check_therapist){       $version = '';   $sid = '';   $token = '';   $client = new services_twilio($sid, $token, $version);    $call = $client->account->calls->create("+1", $the_mnum, "wekaw1.mp3", array()); echo $call->sid;      ?>  <redirect>feedback.php</redirect>     <?php } else {?>     <say voice="woman">        no listener available right now.        give call shortly when have available listener.      </say> <?php } ?> </response> 

in order play hold music instead of rings before 2 numbers connected need use <enqueue> , <queue> combined , initiate call via our rest api.

the following example implementation in php.

you need assign file below phone number. code <enqueue> call , initiate call forwarding number. initiate request second file need create (modify_leg.php).

in file first.php:

$name = $_post['callsid'];  echo '<response><enqueue>'.$name.'</enqueue></response>';  // make sure include php-helper library require('../services/twilio.php'); // loads library $account_sid = 'acxxxxxxxxxxxxxxxxx'; $auth_token = 'aaxxxxxxxxxxx'; $from_number = '+1xxxxxx'; $to_number = '+1xxxxxxxx'; $client = new services_twilio($account_sid, $auth_token); $message = $client->account->calls->create($from_number, $to_number, 'http://your-fqdn/modify_leg.php?callsid='.$name); 

now in (modify_leg.php) pass $_get[callsid] connect both calls once answer phone , caller listen music until pick call.

<?php  $who = $_get['callsid'];  ?> <response> <dial><queue><?php echo $who ?></queue></dial> </response> 

Comments