You do realize that you don&#39;t even need Lua to accomplish what you want to do, right? Instead of launching &quot;luarun callback.lua ${caller_id_number}&quot; as your API you can just do an originate:<br><br><span style="font-family: courier new,monospace;">&lt;action application=&quot;set&quot; data=&quot;api_hangup_hook=originate </span><span style="font-family: courier new,monospace;">{ignore_early_media=true} </span><span style="font-family: courier new,monospace;">sofia/gateway/</span><div style="font-family: courier new,monospace;" class="im">
voipms/1${caller_id_number} 12345 XML default&quot;/&gt;<br></div><br>Create an extension 12345 (or pick a different number) and have the dialplan apps in that extension do all the stuff you are trying to do. Example:<br>
<br><span style="font-family: courier new,monospace;">&lt;extension name=&quot;callback_stuff&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;^(12345)$&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;500&quot;/&gt;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">ššš &lt;action application=&quot;set&quot; inline=&quot;true&quot; data=&quot;message_dir=/usr/local/freeswitch/sounds/en/us/callie/custom/callback/&quot;/&gt;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">ššš &lt;!-- Now do whatever you were going to do</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">šššššššš By the looks of your script you want the caller to enter some digits<br>
šššššššš Then you probably wanted to transfer the caller to that destination<br>šššššššš You can use play-and-get-digits for this<br>šššššššš Please see the wiki because I can&#39;t do any more work on this right now-<br>
šššššššššš my 3 year old son just jumped on my lap and is making me break his two<br>šššššššššš Pop Tarts into little pieces and he wants to type and eat...<br style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;">ššš --&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>Remember the golden rule: Use the dialplan wherever possible because it will always be more efficient than a scripting language. (BTW, when the FS book comes out you&#39;ll see more about this topic.)<br>
<br>HTH and happy dialing!<br>-MC<br><br><div class="gmail_quote">2010/6/10 Aloysius Lloyd <span dir="ltr">&lt;<a href="mailto:lloyd.aloysius@sunteltech.ca">lloyd.aloysius@sunteltech.ca</a>&gt;</span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Thanks Vitalli.<br><br>Increase the short delay solve the problem. I increase from 1000 to 2000.<br><br><span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse; color: rgb(80, 0, 80);"></span>But when I answer the phone there is a silent before play the file because of the dealy. <br>


<br>How to improve this? Is there any setting to make the session fast.<div><div></div><div class="h5"><br><br>Thanks<br>Lloyd<br>
<br><br><div class="gmail_quote">2010/6/10 Vitalii Colosov <span dir="ltr">&lt;<a href="mailto:vetali100@gmail.com" target="_blank">vetali100@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">


Try to add short delay - session:sleep:<div><font color="#500050" face="arial, sans-serif"><span style="border-collapse: collapse;"><br></span></font></div><div><font color="#500050" face="arial, sans-serif"><span style="border-collapse: collapse;">...</span></font></div>



<div>session:setAutoHangup(false);</div><div><span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse; color: rgb(80, 0, 80);"><br></span></div><div><span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse; color: rgb(80, 0, 80);">session:sleep(1000);š</span></div>



<div><span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse; color: rgb(80, 0, 80);">...</span></div><div><div><br></div><div>Sometimes I was getting session is not ready, and fixed this by adding short delay.</div>



<div><br></div><div>Maybe you have same problem here.</div><div><br></div><div>Regards,</div><div>Vitalie</div><div><br></div><div><br><br><div class="gmail_quote">10 ΙΐΞΡ 2010 Η. 16:20 ΠΟΜΨΪΟΧΑΤΕΜΨ Aloysius Lloyd <span dir="ltr">&lt;<a href="mailto:lloyd.aloysius@sunteltech.ca" target="_blank">lloyd.aloysius@sunteltech.ca</a>&gt;</span> ΞΑΠΙΣΑΜ:<div>


<div></div><div><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">VItalli,<br><br>I try your suggestion. Now the script look like this<div><br><br>os.execute(&quot;sleep &quot; .. tonumber(10));<br>



<br>pin_number_test=&quot;0511&quot;;<br>out_gateway1=&quot;sofia/gateway/voipms/1&quot;;<br>message_dir=&quot;/usr/local/freeswitch/sounds/en/us/callie/custom/callback/&quot;;<br>

<br>number_to_call= argv[1];<br><br></div>session = freeswitch.Session(&quot;{ignore_early_media=true,originate_timeout=40}&quot;..out_gateway1..number_to_call);<br>session:setAutoHangup(false);<br><div><br>if ( session:ready() ) then<br>





ššššššš session:sleep(1000);<br>šššššššš if (session:answered()) then<br>ššššššššššššššš session:sleep(1000);<br>ššššššššššššššš session:streamFile(message_dir..&quot;enter-dest.wav&quot;);<br>šššššššš end<br>end<br><br>



</div>
===<br>
<br>Also I try 5 test . This time out of 5 test,š wave file play only one time. Other for 4 tests silent.<br><br>Thanks<br>Lloyd<br><br>
<br><br><div class="gmail_quote">2010/6/10 Vitalii Colosov <span dir="ltr">&lt;<a href="mailto:vetali100@gmail.com" target="_blank">vetali100@gmail.com</a>&gt;</span><div><div></div><div><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">





It looks OK what you wrote - we have almost same lua code.<div><br><div>The only thing that I have in addition in my script is &quot;if š(session:answered())&quot; construction.</div><div><br></div><div>Try to write it like this:</div>






<div>...</div><div><br></div><div><span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse;">if ( session:ready() ) then<br>ššššššš session:sleep(1000);šš š š š</span></div>
<div><span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse;">šš š š šif (session:answered()) then</span></div><div><span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse;">šš š š š ššsession:sleep(1000); š š š š</span></div>





<div>
<div><span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse;">šš š š š š session:streamFile(message_dir..&quot;enter-dest.wav&quot;);</span></div><div><span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse;">šš š š šend</span></div>






</div><div><span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse;"><br>end</span></div><div><span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse;">...</span></div>





<div><br></div><div>Not sure why this should work and that does not, but this is how it works for me - worth trying at lest.</div><div><br></div><div><br></div><div>Regards,</div><div>Vitalie</div><div><br><br><div class="gmail_quote">






10 ΙΐΞΡ 2010 Η. 9:07 ΠΟΜΨΪΟΧΑΤΕΜΨ Aloysius Lloyd <span dir="ltr">&lt;<a href="mailto:lloyd.aloysius@sunteltech.ca" target="_blank">lloyd.aloysius@sunteltech.ca</a>&gt;</span> ΞΑΠΙΣΑΜ:<div><div></div><div><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">






<br clear="all">without bypass_media_after_bridge=true same results.<br><br>Lloyd<br><br>
<br><br><div class="gmail_quote">2010/6/10 Aloysius Lloyd <span dir="ltr">&lt;<a href="mailto:lloyd.aloysius@sunteltech.ca" target="_blank">lloyd.aloysius@sunteltech.ca</a>&gt;</span><div><div></div><div><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">








I try the bypass_media_after_bridge=trueš .. same results.<br><br>Thanks<br><font color="#888888">Lloyd</font><div><div></div><div><br><br>
<br><br><div class="gmail_quote">On Thu, Jun 10, 2010 at 2:00 AM, Sergey Scheglov <span dir="ltr">&lt;<a href="mailto:sid@eltc.ru" target="_blank">sid@eltc.ru</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">









χ Thu, 10 Jun 2010 01:26:51 -0400<br>
<div>Aloysius Lloyd &lt;<a href="mailto:lloyd.aloysius@gmail.com" target="_blank">lloyd.aloysius@gmail.com</a>&gt; wrote:<br>
<br>
<br>
</div><div>&gt; session =<br>
&gt; freeswitch.Session(&quot;{bypass_media_after_bridge=true,ignore_early_media=true,originate_timeout=40}&quot;..out_gateway1..number_to_call);<br>
&gt; session:setAutoHangup(false);<br>
&gt;<br>
</div>&gt; Thanks<br>
&gt; Lloyd<br>
<br>
Try without bypass_media_after_bridge=true<br>
<br>
Regard<br>
Sergey Scheglov<br>
<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>
</blockquote></div><br>
</div></div></blockquote></div></div></div><br>
<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></div></div><br></div></div>
<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></div></div><br>
<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></div></div><br></div></div>
<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>
</div></div><br>_______________________________________________<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org">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>