<p dir="ltr">Don&#39;t loose your time, contact me offline</p>
<div class="gmail_quote">On Jan 15, 2015 5:49 PM, &quot;Sina Owolabi&quot; &lt;<a href="mailto:notify.sina@gmail.com">notify.sina@gmail.com</a>&gt; wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi List,<br><br><div>I think I have finally come up with something that works, the script captures the details correctly, but I wonder if there is a better way to write it? I am trying to get it to call the dialer back and play a message, which it does correctly.</div><div>Please what can I do to make it to retry the dialler&#39;s number in case the call doesn&#39;t go through the first (say) two times, just in case the dialler cut it off mistakenly, or the telco plays a repeated message after freeswitch hung up, preventing the callback from coming through? (I&#39;ve seen this happen a few times with a local telco). Thanks!</div><div><br></div><div><div>number_to_call = argv[1];</div><div>caller_id = argv[2];</div><div><span style="line-height:1.5">api = freeswitch.API();</span><br></div><div><span style="line-height:1.5">dialString = &quot;{origination_caller_id_name=&quot;..caller_id..&quot;,origination_caller_id_number=&quot;..caller_id..&quot;}sofia/gateway/sipgw/&quot;..number_to_call..&quot;&quot;;</span><br></div><div>session1 = freeswitch.Session(dialString);</div><div>session1:sleep(5000);</div><div><br></div><div>if (session1:ready()) then</div><div>        session1:sleep(35000);</div><div>        api:execute(&quot;bgapi originate&quot;, &quot;session1&quot;);</div><div>        session1:sleep(3000);</div><div>        session1:streamFile(&#39;/tmp/stop_calling_me_stalker.wav&#39;);</div><div>        session1:hangup(&quot;NORMAL_CLEARING&quot;);</div><div>end</div></div><div><br></div><br><div class="gmail_quote">On Wed Jan 07 2015 at 2:45:04 PM Avi Marcus &lt;<a href="mailto:avi@avimarcus.net" target="_blank">avi@avimarcus.net</a>&gt; wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div><div><div>Two things:</div><div>1) You aren&#39;t grabbing the arg, but the channel variable.. try this in your script:</div><div><div><span style="font-size:12.8000001907349px">caller_id_number</span> = argv[1]</div><div><span style="font-size:12.8000001907349px">number_to_call</span> = argv[2]</div><div><br></div><div>2) I don&#39;t think you&#39;re managing your hangup/callback originate properly.</div><div>I don&#39;t think you want to use bgapi... or maybe you just need a destination. It&#39;s &quot;<a href="http://wiki.freeswitch.org/wiki/Mod_commands#originate" target="_blank">originate</a> sofia/A endpoint&quot; -- you need to specify where it goes to, the lua script can&#39;t &quot;receive&quot; the call. You can have it received by e.g: &amp;lua(pickup.lua)</div><div><br></div><div>api = freeswitch.API()</div><div>api:execute(&quot;originate&quot;, DialString..&quot; &amp;lua(pickup.lua)&quot;);</div></div><div><br></div><div>Also:</div><div>Maybe you want to use it as a hangup hook. Instead of:</div></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div><div><div><span style="font-size:12.8000001907349px">&lt;action application=&quot;lua&quot; data=&quot;callback.lua </span><span style="font-size:12.8000001907349px">${effective_caller_id_number} ${destination_number}&quot;/&gt;</span><br></div></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div><div><div><span style="font-size:12.8000001907349px">Do:</span></div><div><span style="font-size:12.8000001907349px">&lt;action application=&quot;</span>set<span style="font-size:12.8000001907349px">&quot; data=&quot;</span>api_hangup_hook=lua <span style="font-size:12.8000001907349px">callback.lua </span><span style="font-size:12.8000001907349px">${effective_caller_id_number} ${destination_number}&quot;/&gt;</span></div><div><span style="font-size:12.8000001907349px">&lt;action application=&quot;</span>hangup<span style="font-size:12.8000001907349px">&quot; data=&quot;</span>486<span style="font-size:12.8000001907349px">&quot;/&gt;</span></div><div dir="ltr"><br></div><div>-Avi </div></div></div>
<br><div class="gmail_quote"></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Jan 7, 2015 at 1:52 AM, Sina Owolabi <span dir="ltr">&lt;<a href="mailto:notify.sina@gmail.com" target="_blank">notify.sina@gmail.com</a>&gt;</span> wrote:<br></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi List,<br>
<br>
FreeSWITCH newbie here again.<br>
I am trying to cobble togther a lua callback script, my first attempt<br>
was successful, but I am trying to make it slightly more elegant.<br>
I don&#39;t see any errors when I try to run this but the callback isnt happening.<br>
This is my very second attempt trying to write in lua, so I would be<br>
very grateful for any help.<br>
<br>
The user is expected to dial in, have the call hangup and FreeSWITCH call back.<br>
<br>
I&#39;m passing a modified $effective_caller_id_number and<br>
$destination_number to the lua script:<br>
<br>
&lt;extension name=&quot;callyouback&quot;&gt;<br>
    &lt;condition field=&quot;${caller_id_number}&quot;<br>
expression=&quot;^1(\d{10})$&quot;require-nested=&quot;false&quot;&gt;<br>
       &lt;action application=&quot;set&quot; data=&quot;effective_caller_id_number=+234${1}&quot;/&gt;<br>
       &lt;action application=&quot;set&quot; data=&quot;effective_caller_id_name=+234${1}&quot;/&gt;<br>
    &lt;/condition&gt;<br>
    &lt;condition field=&quot;destination_number&quot; expression=&quot;^012345(6)(7)$&quot;&gt;<br>
      &lt;action application=&quot;set&quot; data=&quot;destination_number=+12312345${1}${2}&quot; /&gt;<br>
      &lt;action application=&quot;lua&quot; data=&quot;callback.lua<br>
${effective_caller_id_number} ${destination_number}&quot;/&gt;<br>
      &lt;action application=&quot;gentones&quot; data=&quot;%(3000,0,430,450,550)&quot;/&gt;<br>
      &lt;action application=&quot;hangup&quot; data=&quot;NORMAL_CLEARING&quot;/&gt;<br>
     &lt;/condition&gt;<br>
<br>
<br>
The script itself:<br>
<br>
api = freeswitch.API();<br>
call_string = &quot;bagpi originate<br>
{origination_caller_id_name=&quot;..caller_id_name..&quot;,origination_caller_id_number=&quot;..caller_id_number..&quot;}sofia/gateway/mysipgate/&quot;..number_to_call..&quot;&quot;<br>
<br>
freeswitch.msleep(5000);<br>
if (session:ready()) then<br>
        caller_id_number = session:getVariable(&quot;destination_number&quot;);<br>
        caller_id_name = session:getVariable(&quot;destination_number&quot;);<br>
        number_to_call = session:getVariable(&quot;effective_caller_id_number&quot;);<br>
<br>
        api:executeString(call_string);<br>
        freeswitch.msleep(2000);<br>
        session:streamFile(&quot;/tmp/get_off_my_lawn.wav&quot;);<br>
        session:hangup(&quot;NORMAL_CLEARING&quot;);<br>
end<br>
<br></blockquote></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
_________________________________________________________________________<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>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://confluence.freeswitch.org" target="_blank">http://confluence.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>
</blockquote></div><br></div></div>
______________________________<u></u>______________________________<u></u>_____________<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.<u></u>freeswitchsolutions.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://confluence.freeswitch.org" target="_blank">http://confluence.freeswitch.<u></u>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.<u></u>freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/<u></u>mailman/listinfo/freeswitch-<u></u>users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.<u></u>freeswitch.org/mailman/<u></u>options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a></blockquote></div>
<br>_________________________________________________________________________<br>
Professional FreeSWITCH Consulting Services:<br>
<a href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com" target="_blank">http://www.freeswitchsolutions.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://confluence.freeswitch.org" target="_blank">http://confluence.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">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>