[Freeswitch-users] Use of ESL and PHP for Call

Shahzad Bhatti shahzad.bhatti at g-r-v.com
Thu Mar 1 22:10:00 MSK 2012


Hi,

I am a new user and want to create an application to play a message using
mod_tts (cepstral) like we have a meeting on Monday at 9 are you available,
if yes press 1 and no then press 2 then record the key pressed in a
variable or store it in the database.

but when i originate call the call hangup after speak, but i need to make
call continue so the caller press the key and then call hangup.
now what i do, can i make it simple or make an IVR for it. i searched alot
but not manage to get the solution.

so far i get the digit pressed using $digit = getHeader("DTMF-Digit"); but
i need to control the call to park it after playing the message till called
press the digit.

my code is as:

<?php

 require_once('ESL.php');

 $host_name      =       'localhost';
 $port           =       '8021';
 $password       =       'ClueCon';

 $esl           =       new ESLconnection($host_name,$port,$password);

 $e = $esl->sendRecv("api create_uuid");
 $uuid = $e->getBody();
 $user = '1500';

 $cmd1 = "bgapi originate {origination_uuid=$uuid}user/$user
&speak('cepstral|william|Hi, we have a meeting on Monday at nine, are you
joining us, if yes then press one and if not press two')";

 $e = $esl->sendRecv($cmd1);

 $e = $esl->sendRecv("events plain all");
 $e = $esl->filter("Unique-ID",$uuid);

  while ($esl->connected())
 {
    $e = $esl->recvEvent();
    $result = $e->getType();
        if($result=='CHANNEL_EXECUTE_COMPLETE')
        {
                        //      what i do here...!
                $esl->execute("&sleep",10000);
        }
        $digit          = $e->getHeader("DTMF-Digit");
        $state_no       = $e->getHeader("Channel-State-Number");
        $curr_uuid      = $e->getHeader("Channel-Call-UUID");

 /*
        $ans_state      = $e->getHeader("Answer-State");
        $state_no       = $e->getHeader("Channel-State-Number");
        $core_id        = $e->getHeader("Core-UUID");
*/
        if($curr_uuid==$uuid && $digit!=NULL)
        {
                print "input number is " . $digit . "\n";
        }
    $state = $e->getHeader("Channel-Call-State");
    if ($state == 'HANGUP') {
        print "\n\nHangup Cause Number: " . $state_no;
        $esl->disconnect();
    }
 }

?>


please help me to solve the problem


Regards

Shahzad Bhatti
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20120302/074d9797/attachment-0001.html 


Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users mailing list