<div dir="ltr"><div class="gmail_extra"><div><div class="gmail_signature"><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">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><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><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">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><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>
_________________________________________________________________________<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><br></div></div>