[Freeswitch-users] Help Needed Debugging Lua Script

Sina Owolabi notify.sina at gmail.com
Wed Jan 7 02:52:33 MSK 2015


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



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