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">&lt;extension name=&quot;meeting request&quot;&gt;</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">  &lt;condition field=&quot;destination_number&quot; expression=&quot;^meeting_request_(</span><span style="font-family:courier new,monospace">\d+)$&quot;&gt;</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">    &lt;action application=&quot;set&quot; data=&quot;target_user=$1&quot;/&gt;</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">    &lt;action application=&quot;set&quot; data=&quot;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.&quot;/&gt;</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">
    &lt;action application=&quot;answer&quot;/&gt;</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">    &lt;action application=&quot;sleep&quot; data=&quot;1000&quot;/&gt;</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">    &lt;action application=&quot;play_and_get_</span><span style="font-family:courier new,monospace">digits&quot; </span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">      data=&quot;1 1 3 5000 # speak:${text} ivr/ivr-that_was_an_invalid_entry.wav answer \d&quot;/&gt;</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">    &lt;action application=&quot;set&quot; data=&quot;api_hangup_hook=system handler.php ${target_user} ${answer}&quot;/&gt;</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">
    &lt;action application=&quot;log&quot; data=&quot;INFO User ${target_user} responded with ${answer}&quot;/&gt;</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">    &lt;action application=&quot;playback&quot; data=&quot;ivr/ivr-Thank_you.wav&quot;/&gt;</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">    &lt;action application=&quot;hangup&quot;/&gt;</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">
  &lt;/condition&gt;</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">&lt;/extension&gt;</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&#39;t the best choice since there isn&#39;t a &quot;mod_php&quot; like there is a mod_lua or mod_perl. Those modules let you do cool things like &quot;session_in_hangup_hook.&quot; However, what you&#39;re doing doesn&#39;t look like it&#39;s very difficult so the example I&#39;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">&lt;<a href="mailto:shahzad.bhatti@g-r-v.com" target="_blank">shahzad.bhatti@g-r-v.com</a>&gt;</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  = &quot;api originate {origination_uuid=$uuid}user/$user &amp;park()&quot;;</div>
<div> $text = &quot;Hi, we have a meeting on Monday at 9, are you joining us, if yes then press, 1. and if not press, 2.&quot;;</div><div><br></div><div> $e = $esl-&gt;sendRecv($cmd);</div><div> $esl-&gt;execute(&#39;speak&#39;,&quot;(cepstral|callie|$text)&quot;,$uuid);</div>


<div><br></div></div><div><br></div><div><br></div><div>my complete code is </div><div><br></div><div><div><span>&lt;?php</span><br><br><span> require_once(&#39;ESL.php&#39;);</span><br><br>
<span> $host_name      =       &#39;localhost&#39;;</span><br><span> $port           =       &#39;8021&#39;;</span><br><span> $password       =       &#39;ClueCon&#39;;</span><br><br>
<span> $esl           =       new ESLconnection($host_name,$</span><span>port,$password);</span><br><br><span> $e = $esl-&gt;sendRecv(&quot;api create_uuid&quot;);</span><br><span> $uuid = $e-&gt;getBody();</span><br>
<span> $user = &#39;1500&#39;;</span><br><br></div><div> $cmd  = &quot;bgapi originate {origination_uuid=$uuid}user/$user &amp;park()&quot;;</div><div> $text = &quot;Hi, we have a meeting on Monday at 9, are you joining us, if yes then press, 1. and if not press, 2.&quot;;</div>


<div><br></div><div> $e = $esl-&gt;sendRecv($cmd);</div><div> $esl-&gt;execute(&#39;speak&#39;,&quot;(cepstral|callie|$text)&quot;,$uuid);</div><br><span><br></span></div><div><div><span> $e = $esl-&gt;sendRecv(&quot;events plain all&quot;);</span><br>


<span> $e = $esl-&gt;filter(&quot;Unique-ID&quot;,$</span><span>uuid);</span><br><br><span> while ($esl-&gt;connected())</span><br><span> {</span><br><span>   $e = $esl-&gt;recvEvent();</span><br>
<span>   $result = $e-&gt;getType();</span><br><span>       if($result==&#39;CHANNEL_EXECUTE_</span><span>COMPLETE&#39;)</span><br><span>       {</span><br><span>                       //      what i do here...!</span><br>


<span>               $esl-&gt;execute(&quot;&amp;sleep&quot;,10000);</span><br><span>       }</span><br><span>       $digit          = $e-&gt;getHeader(&quot;DTMF-Digit&quot;);</span><br>
<span>       $state_no       = $e-&gt;getHeader(&quot;Channel-State-</span><span>Number&quot;);</span><br><span>       $curr_uuid      = $e-&gt;getHeader(&quot;Channel-Call-</span><span>UUID&quot;);</span><br>
<br><span> /*</span><br><span>       $ans_state      = $e-&gt;getHeader(&quot;Answer-State&quot;);</span><br><span>       $state_no       = $e-&gt;getHeader(&quot;Channel-State-</span><span>Number&quot;);</span><br>
<span>       $core_id        = $e-&gt;getHeader(&quot;Core-UUID&quot;);</span><br><span>*/</span><br><span>       if($curr_uuid==$uuid &amp;&amp; $digit!=NULL)</span><br><span>       {</span><br>
<span>               print &quot;input number is &quot; . $digit . &quot;\n&quot;;</span><br><span>       }</span><br><span>   $state = $e-&gt;getHeader(&quot;Channel-Call-</span><span>State&quot;);</span><br>
<span>   if ($state == &#39;HANGUP&#39;) {</span><br><span>       print &quot;\n\nHangup Cause Number: &quot; . $state_no;</span><br><span>       $esl-&gt;disconnect();</span><br><span>   }</span><br>
<span> }</span><br><br><span>?&gt;</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 &lt;<a href="mailto:peter.olsson@visionutveckling.se" target="_blank">peter.olsson@visionutveckling.se</a>&gt;</span><br>
<span>To: FreeSWITCH Users Help &lt;<a href="mailto:freeswitch-users@lists.freeswitch.org" target="_blank">freeswitch-users@lists.freeswitch.org</a>&gt;</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 &amp;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 &amp;park() instead, the call will be &quot;parked&quot; 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>