[Freeswitch-users] Help Needed Debugging Lua Script

Sina Owolabi notify.sina at gmail.com
Fri Jan 16 17:36:36 MSK 2015


But how will I learn?
On Fri, 16 Jan 2015 at 01:17, Luis Daniel Lucio Quiroz <
luis.daniel.lucio at gmail.com> wrote:

> Don't loose your time, contact me offline
> On Jan 15, 2015 5:49 PM, "Sina Owolabi" <notify.sina at gmail.com> wrote:
>
>> Hi List,
>>
>> 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.
>> 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!
>>
>> number_to_call = argv[1];
>> caller_id = argv[2];
>> api = freeswitch.API();
>> dialString =
>> "{origination_caller_id_name="..caller_id..",origination_caller_id_number="..caller_id.."}sofia/gateway/sipgw/"..number_to_call.."";
>> session1 = freeswitch.Session(dialString);
>> session1:sleep(5000);
>>
>> if (session1:ready()) then
>>         session1:sleep(35000);
>>         api:execute("bgapi originate", "session1");
>>         session1:sleep(3000);
>>         session1:streamFile('/tmp/stop_calling_me_stalker.wav');
>>         session1:hangup("NORMAL_CLEARING");
>> end
>>
>>
>> On Wed Jan 07 2015 at 2:45:04 PM Avi Marcus <avi at avimarcus.net> wrote:
>>
>>> Two things:
>>> 1) You aren't grabbing the arg, but the channel variable.. try this in
>>> your script:
>>> caller_id_number = argv[1]
>>> number_to_call = argv[2]
>>>
>>> 2) I don't think you're managing your hangup/callback originate properly.
>>> I don't think you want to use bgapi... or maybe you just need a
>>> destination. It's "originate
>>> <http://wiki.freeswitch.org/wiki/Mod_commands#originate> 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)
>>>
>>> api = freeswitch.API()
>>> api:execute("originate", DialString.." &lua(pickup.lua)");
>>>
>>> Also:
>>> Maybe you want to use it as a hangup hook. Instead of:
>>> <action application="lua" data="callback.lua ${effective_caller_id_number}
>>> ${destination_number}"/>
>>> Do:
>>> <action application="set" data="api_hangup_hook=lua callback.lua ${effective_caller_id_number}
>>> ${destination_number}"/>
>>> <action application="hangup" data="486"/>
>>>
>>> -Avi
>>>
>>> On Wed, Jan 7, 2015 at 1:52 AM, Sina Owolabi <notify.sina at gmail.com>
>>> wrote:
>>>
>>>> Hi List,
>>>>
>>>> FreeSWITCH newbie here again.
>>>> I am trying to cobble togther a lua callback script, my first attempt
>>>> was successful, but I am trying to make it slightly more elegant.
>>>> I don't see any errors when I try to run this but the callback isnt
>>>> happening.
>>>> This is my very second attempt trying to write in lua, so I would be
>>>> very grateful for any help.
>>>>
>>>> The user is expected to dial in, have the call hangup and FreeSWITCH
>>>> call back.
>>>>
>>>> I'm passing a modified $effective_caller_id_number and
>>>> $destination_number to the lua script:
>>>>
>>>> <extension name="callyouback">
>>>>     <condition field="${caller_id_number}"
>>>> expression="^1(\d{10})$"require-nested="false">
>>>>        <action application="set"
>>>> data="effective_caller_id_number=+234${1}"/>
>>>>        <action application="set"
>>>> data="effective_caller_id_name=+234${1}"/>
>>>>     </condition>
>>>>     <condition field="destination_number" expression="^012345(6)(7)$">
>>>>       <action application="set"
>>>> data="destination_number=+12312345${1}${2}" />
>>>>       <action application="lua" data="callback.lua
>>>> ${effective_caller_id_number} ${destination_number}"/>
>>>>       <action application="gentones" data="%(3000,0,430,450,550)"/>
>>>>       <action application="hangup" data="NORMAL_CLEARING"/>
>>>>      </condition>
>>>>
>>>>
>>>> The script itself:
>>>>
>>>> api = freeswitch.API();
>>>> call_string = "bagpi originate
>>>>
>>>> {origination_caller_id_name="..caller_id_name..",origination_caller_id_number="..caller_id_number.."}sofia/gateway/mysipgate/"..number_to_call..""
>>>>
>>>> freeswitch.msleep(5000);
>>>> if (session:ready()) then
>>>>         caller_id_number = session:getVariable("destination_number");
>>>>         caller_id_name = session:getVariable("destination_number");
>>>>         number_to_call =
>>>> session:getVariable("effective_caller_id_number");
>>>>
>>>>         api:executeString(call_string);
>>>>         freeswitch.msleep(2000);
>>>>         session:streamFile("/tmp/get_off_my_lawn.wav");
>>>>         session:hangup("NORMAL_CLEARING");
>>>> end
>>>>
>>>>
>>>> _________________________________________________________________________
>>>> Professional FreeSWITCH Consulting Services:
>>>> consulting at freeswitch.org
>>>> http://www.freeswitchsolutions.com
>>>>
>>>> Official FreeSWITCH Sites
>>>> http://www.freeswitch.org
>>>> http://confluence.freeswitch.org
>>>> http://www.cluecon.com
>>>>
>>>> FreeSWITCH-users mailing list
>>>> FreeSWITCH-users at lists.freeswitch.org
>>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>>> UNSUBSCRIBE:
>>>> http://lists.freeswitch.org/mailman/options/freeswitch-users
>>>> http://www.freeswitch.org
>>>>
>>>
>>> ____________________________________________________________
>>> _____________
>>> Professional FreeSWITCH Consulting Services:
>>> consulting at freeswitch.org
>>> http://www.freeswitchsolutions.com
>>>
>>> Official FreeSWITCH Sites
>>> http://www.freeswitch.org
>>> http://confluence.freeswitch.org
>>> http://www.cluecon.com
>>>
>>> FreeSWITCH-users mailing list
>>> FreeSWITCH-users at lists.freeswitch.org
>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>>> http://www.freeswitch.org
>>
>>
>> _________________________________________________________________________
>> Professional FreeSWITCH Consulting Services:
>> consulting at freeswitch.org
>> http://www.freeswitchsolutions.com
>>
>> Official FreeSWITCH Sites
>> http://www.freeswitch.org
>> http://confluence.freeswitch.org
>> http://www.cluecon.com
>>
>> FreeSWITCH-users mailing list
>> FreeSWITCH-users at lists.freeswitch.org
>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>> http://www.freeswitch.org
>>
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
>
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://confluence.freeswitch.org
> http://www.cluecon.com
>
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20150116/6587fefa/attachment.html 


Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users mailing list