<p dir="ltr">Don't loose your time, contact me offline</p>
<div class="gmail_quote">On Jan 15, 2015 5:49 PM, "Sina Owolabi" <<a href="mailto:notify.sina@gmail.com">notify.sina@gmail.com</a>> 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's number in case the call doesn'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'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 = "{origination_caller_id_name="..caller_id..",origination_caller_id_number="..caller_id.."}sofia/gateway/sipgw/"..number_to_call.."";</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("bgapi originate", "session1");</div><div> session1:sleep(3000);</div><div> session1:streamFile('/tmp/stop_calling_me_stalker.wav');</div><div> session1:hangup("NORMAL_CLEARING");</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 <<a href="mailto:avi@avimarcus.net" target="_blank">avi@avimarcus.net</a>> 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'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't think you're managing your hangup/callback originate properly.</div><div>I don't think you want to use bgapi... or maybe you just need a destination. It's "<a href="http://wiki.freeswitch.org/wiki/Mod_commands#originate" target="_blank">originate</a> sofia/A endpoint" -- you need to specify where it goes to, the lua script can't "receive" the call. You can have it received by e.g: &lua(pickup.lua)</div><div><br></div><div>api = freeswitch.API()</div><div>api:execute("originate", DialString.." &lua(pickup.lua)");</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"><action application="lua" data="callback.lua </span><span style="font-size:12.8000001907349px">${effective_caller_id_number} ${destination_number}"/></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"><action application="</span>set<span style="font-size:12.8000001907349px">" data="</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}"/></span></div><div><span style="font-size:12.8000001907349px"><action application="</span>hangup<span style="font-size:12.8000001907349px">" data="</span>486<span style="font-size:12.8000001907349px">"/></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"><<a href="mailto:notify.sina@gmail.com" target="_blank">notify.sina@gmail.com</a>></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'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'm passing a modified $effective_caller_id_number and<br>
$destination_number to the lua script:<br>
<br>
<extension name="callyouback"><br>
<condition field="${caller_id_number}"<br>
expression="^1(\d{10})$"require-nested="false"><br>
<action application="set" data="effective_caller_id_number=+234${1}"/><br>
<action application="set" data="effective_caller_id_name=+234${1}"/><br>
</condition><br>
<condition field="destination_number" expression="^012345(6)(7)$"><br>
<action application="set" data="destination_number=+12312345${1}${2}" /><br>
<action application="lua" data="callback.lua<br>
${effective_caller_id_number} ${destination_number}"/><br>
<action application="gentones" data="%(3000,0,430,450,550)"/><br>
<action application="hangup" data="NORMAL_CLEARING"/><br>
</condition><br>
<br>
<br>
The script itself:<br>
<br>
api = freeswitch.API();<br>
call_string = "bagpi originate<br>
{origination_caller_id_name="..caller_id_name..",origination_caller_id_number="..caller_id_number.."}sofia/gateway/mysipgate/"..number_to_call..""<br>
<br>
freeswitch.msleep(5000);<br>
if (session:ready()) then<br>
caller_id_number = session:getVariable("destination_number");<br>
caller_id_name = session:getVariable("destination_number");<br>
number_to_call = session:getVariable("effective_caller_id_number");<br>
<br>
api:executeString(call_string);<br>
freeswitch.msleep(2000);<br>
session:streamFile("/tmp/get_off_my_lawn.wav");<br>
session:hangup("NORMAL_CLEARING");<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>