Shahzad,<br><br>I think you may have taken an unnecessarily complicated approach to this. If I were you I would simply use the play_and_get_digits application which does all the work for you. I would also handle that in the XML dialplan and then use the api_<span style="background-color:rgb(255,255,255)">hangup_ho</span>ok to call your script to process the result. (I.e. did the user press 1 or 2 or something else...)<br>
<br>I recommend you start with something simple like a basic originate command that calls the user and then drops that call to a dialplan extension:<br><br><span style="font-family:courier new,monospace">originate user/1500 meeting_request_1500</span><br style="font-family:courier new,monospace">
<br>Then create that extension:<br>
<br><span style="font-family:courier new,monospace"><extension name="meeting request"></span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> <condition field="destination_number" expression="^meeting_request_(</span><span style="font-family:courier new,monospace">\d+)$"></span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> <action application="set" data="target_user=$1"/></span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> <action application="set" data="text=cepstral|callie|Hi, we have a meeting on Monday at 9, are you joining us, if yes then press, 1. and if not press, 2."/></span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">
<action application="answer"/></span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> <action application="sleep" data="1000"/></span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> <action application="play_and_get_</span><span style="font-family:courier new,monospace">digits" </span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> data="1 1 3 5000 # speak:${text} ivr/ivr-that_was_an_invalid_entry.wav answer \d"/></span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> <action application="set" data="api_hangup_hook=system handler.php ${target_user} ${answer}"/></span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">
<action application="log" data="INFO User ${target_user} responded with ${answer}"/></span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> <action application="playback" data="ivr/ivr-Thank_you.wav"/></span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> <action application="hangup"/></span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">
</condition></span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"></extension></span><br><br>Then you just need to write your handler.php script (or whatever you want to call it) and have it parse the command line args - the first one is the user and the second one is the digit pressed. PHP scripts will work for hangup hooks but they aren't the best choice since there isn't a "mod_php" like there is a mod_lua or mod_perl. Those modules let you do cool things like "session_in_hangup_hook." However, what you're doing doesn't look like it's very difficult so the example I've given should get you going. Please note that I just did this off the top of my head w/o testing it so be sure double-check everything if you run into any unusual or unexpected behavior.<br>
<br>Keep in mind that in this example you will need two different PHP scripts - one that actually initiates the ESL connection and does the originate and one that handles the call results. Instead of one semi-complicated script you will have two very easy scripts.<br>
<br>Hope this helps...<br>-MC<br><br><div class="gmail_quote">On Fri, Mar 2, 2012 at 4:14 AM, Shahzad Bhatti <span dir="ltr"><<a href="mailto:shahzad.bhatti@g-r-v.com" target="_blank">shahzad.bhatti@g-r-v.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><br></div><div>Hi,</div><div><br></div><div>i park the call and then execute the speak command as but execute is not working any idea ?</div>
<div><br></div><div><div> $cmd = "api originate {origination_uuid=$uuid}user/$user &park()";</div>
<div> $text = "Hi, we have a meeting on Monday at 9, are you joining us, if yes then press, 1. and if not press, 2.";</div><div><br></div><div> $e = $esl->sendRecv($cmd);</div><div> $esl->execute('speak',"(cepstral|callie|$text)",$uuid);</div>
<div><br></div></div><div><br></div><div><br></div><div>my complete code is </div><div><br></div><div><div><span><?php</span><br><br><span> require_once('ESL.php');</span><br><br>
<span> $host_name = 'localhost';</span><br><span> $port = '8021';</span><br><span> $password = 'ClueCon';</span><br><br>
<span> $esl = new ESLconnection($host_name,$</span><span>port,$password);</span><br><br><span> $e = $esl->sendRecv("api create_uuid");</span><br><span> $uuid = $e->getBody();</span><br>
<span> $user = '1500';</span><br><br></div><div> $cmd = "bgapi originate {origination_uuid=$uuid}user/$user &park()";</div><div> $text = "Hi, we have a meeting on Monday at 9, are you joining us, if yes then press, 1. and if not press, 2.";</div>
<div><br></div><div> $e = $esl->sendRecv($cmd);</div><div> $esl->execute('speak',"(cepstral|callie|$text)",$uuid);</div><br><span><br></span></div><div><div><span> $e = $esl->sendRecv("events plain all");</span><br>
<span> $e = $esl->filter("Unique-ID",$</span><span>uuid);</span><br><br><span> while ($esl->connected())</span><br><span> {</span><br><span> $e = $esl->recvEvent();</span><br>
<span> $result = $e->getType();</span><br><span> if($result=='CHANNEL_EXECUTE_</span><span>COMPLETE')</span><br><span> {</span><br><span> // what i do here...!</span><br>
<span> $esl->execute("&sleep",10000);</span><br><span> }</span><br><span> $digit = $e->getHeader("DTMF-Digit");</span><br>
<span> $state_no = $e->getHeader("Channel-State-</span><span>Number");</span><br><span> $curr_uuid = $e->getHeader("Channel-Call-</span><span>UUID");</span><br>
<br><span> /*</span><br><span> $ans_state = $e->getHeader("Answer-State");</span><br><span> $state_no = $e->getHeader("Channel-State-</span><span>Number");</span><br>
<span> $core_id = $e->getHeader("Core-UUID");</span><br><span>*/</span><br><span> if($curr_uuid==$uuid && $digit!=NULL)</span><br><span> {</span><br>
<span> print "input number is " . $digit . "\n";</span><br><span> }</span><br><span> $state = $e->getHeader("Channel-Call-</span><span>State");</span><br>
<span> if ($state == 'HANGUP') {</span><br><span> print "\n\nHangup Cause Number: " . $state_no;</span><br><span> $esl->disconnect();</span><br><span> }</span><br>
<span> }</span><br><br><span>?></span>
</div><div><br></div><div><br></div></div><div>Regards</div><span><font color="#888888"><div><br></div><div>Shahzad Bhatti</div></font></span><div><div><div><br></div><div><br></div>
<div><span>---------- Forwarded message ----------</span><br><span>From: Peter Olsson <<a href="mailto:peter.olsson@visionutveckling.se" target="_blank">peter.olsson@visionutveckling.se</a>></span><br>
<span>To: FreeSWITCH Users Help <<a href="mailto:freeswitch-users@lists.freeswitch.org" target="_blank">freeswitch-users@lists.freeswitch.org</a>></span><br><span>Cc: </span><br><span>Date: Fri, 2 Mar 2012 05:31:35 +0000</span><br>
<span>Subject: Re: [Freeswitch-users] Use of ESL and PHP for Call</span><br><span>You should pass the originate command to &park() instead.</span><br><br><span>Right now you originate the call and then execute the application speak. After this (when speak is finished) FS has no more instructions so it will hangup the call.</span><br>
<br><span>If you execute &park() instead, the call will be "parked" and wait for furter instructions. Then you will also need to execute the speak from ESL instead - and afther that you continue to do whatever you want to do with the call.</span><br>
<br><span>/Peter</span>
</div>
</div></div><br>_________________________________________________________________________<br>
Professional FreeSWITCH Consulting Services:<br>
<a href="mailto:consulting@freeswitch.org" target="_blank">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com" target="_blank">http://www.freeswitchsolutions.com</a><br>
<br>
FreeSWITCH-powered IP PBX: The CudaTel Communication Server<br>
<a href="http://www.cudatel.com" target="_blank">http://www.cudatel.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://wiki.freeswitch.org" target="_blank">http://wiki.freeswitch.org</a><br>
<a href="http://www.cluecon.com" target="_blank">http://www.cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br></blockquote></div><br>