Hello, I am writing a Lua script that will get the callerId info. I need 1 to be able to get the callerID and also to print any messages to the FS_CLI for debugging purpose. By itself the session:execute does transfer to the correct conference, but it does not work with the callerID. And the consoleLog doesnt work it give me an error on the screen. #!/usr/bin/lua session:answer(); callerID = session:getVariable("caller_id_number"); freeswitch.consoleLog("Hello World"); --session:execute("conference","4567"); --while (session:ready() == true) do --session:setAutoHangup(false); if (callerID == 1234567890) then session:execute("conference","4567"); --else -- session:execute("transfer","7890"); end -- end
getVariable("caller_id_number") will return you a string, not an integer and in Lua type matters. So you will be more happy if you use the following: if (callerID == "1234567890") then On consoleLog, you are missing the loglevel, see the documentation: http://wiki.freeswitch.org/wiki/Mod_lua#freeswitch.consoleLog Hope this helps! On Tue, Dec 10, 2013 at 5:14 PM, Joli Martinez <mrjoli021@gmail.com> wrote:
Hello,
I am writing a Lua script that will get the callerId info. I need 1 to be able to get the callerID and also to print any messages to the FS_CLI for debugging purpose. By itself the session:execute does transfer to the correct conference, but it does not work with the callerID. And the consoleLog doesnt work it give me an error on the screen.
#!/usr/bin/lua
session:answer();
callerID = session:getVariable("caller_id_number");
freeswitch.consoleLog("Hello World"); --session:execute("conference","4567"); --while (session:ready() == true) do --session:setAutoHangup(false);
if (callerID == 1234567890) then session:execute("conference","4567"); --else -- session:execute("transfer","7890"); end -- end
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Kind regards, /Areski ---- Arezqui Belaid, <areski@gmail.com> Founder at Star2Billing (www.star2billing.com) Tel: +34650784355 Twitter: http://twitter.com/areskib LinkedIn: http://www.linkedin.com/in/areski
1) console: Wiki says you need two args -- freeswitch.consoleLog("info", "lua rocks\n"); 2) lua does typing, and the callerID will be a string. So you want to do: if (callerID == "1234567890") then -Avi On Tue, Dec 10, 2013 at 6:14 PM, Joli Martinez <mrjoli021@gmail.com> wrote:
Hello,
I am writing a Lua script that will get the callerId info. I need 1 to be able to get the callerID and also to print any messages to the FS_CLI for debugging purpose. By itself the session:execute does transfer to the correct conference, but it does not work with the callerID. And the consoleLog doesnt work it give me an error on the screen.
#!/usr/bin/lua
session:answer();
callerID = session:getVariable("caller_id_number");
freeswitch.consoleLog("Hello World"); --session:execute("conference","4567"); --while (session:ready() == true) do --session:setAutoHangup(false);
if (callerID == 1234567890) then session:execute("conference","4567"); --else -- session:execute("transfer","7890"); end -- end
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
1) console: Wiki says you need two args -- freeswitch.consoleLog("info", "lua rocks\n"); 2) lua does typing, and the callerID will be a string. So you want to do: if (callerID == "1234567890") then -Avi On Tue, Dec 10, 2013 at 6:14 PM, Joli Martinez <mrjoli021@gmail.com> wrote:
Hello,
I am writing a Lua script that will get the callerId info. I need 1 to be able to get the callerID and also to print any messages to the FS_CLI for debugging purpose. By itself the session:execute does transfer to the correct conference, but it does not work with the callerID. And the consoleLog doesnt work it give me an error on the screen.
#!/usr/bin/lua
session:answer();
callerID = session:getVariable("caller_id_number");
freeswitch.consoleLog("Hello World"); --session:execute("conference","4567"); --while (session:ready() == true) do --session:setAutoHangup(false);
if (callerID == 1234567890) then session:execute("conference","4567"); --else -- session:execute("transfer","7890"); end -- end
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
Hi Joli The answer are already in your hands... in: https://wiki.freeswitch.org/wiki/Mod_lua http://phrogz.net/lua/LearningLua_FromJS.html http://www.lua.org/ With "freeswitch.consoleLog" you get info in the console. You should change your code to: freeswitch.consoleLog("info", "Got -------------------------------> caller_id_number: " .. callerID .. "\n"); Also, try: if (callerID == "1234567890") On 12/10/2013 11:44 AM, Joli Martinez wrote:
Hello,
I am writing a Lua script that will get the callerId info. I need 1 to be able to get the callerID and also to print any messages to the FS_CLI for debugging purpose. By itself the session:execute does transfer to the correct conference, but it does not work with the callerID. And the consoleLog doesnt work it give me an error on the screen.
#!/usr/bin/lua
session:answer();
callerID = session:getVariable("caller_id_number");
freeswitch.consoleLog("Hello World"); --session:execute("conference","4567"); --while (session:ready() == true) do --session:setAutoHangup(false);
if (callerID == 1234567890) then session:execute("conference","4567"); --else -- session:execute("transfer","7890"); end -- end
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Atentamente, *Dario García* Consultor. CCCT, Nivel C2, Sector Yarey, Mz, Ofc. MZ03a. Caracas-Venezuela. Teléfono: +58 212 9081842 Cel: +58 412 2221515 dgarcia@anew.com.ve http://www.anew.com.ve
got it working thanks, but now I need to have my script read the info from a mysql db. When I run the script manually my script works, but when I run it from FS I get the error message below: [ERR] mod_lua.cpp:199 /usr/local/freeswitch/scripts/callerID.lua:6: module 'luasql.mysql' not found: no field package.preload['luasql.mysql'] no file './luasql/mysql.lua' no file '/usr/local/share/lua/5.1/luasql/mysql.lua' no file '/usr/local/share/lua/5.1/luasql/mysql/init.lua' no file '/usr/local/lib/lua/5.1/luasql/mysql.lua' no file '/usr/local/lib/lua/5.1/luasql/mysql/init.lua' no file './luasql/mysql.so' no file './libluasql/mysql51.so' no file '/usr/local/lib/lua/5.1/luasql/mysql.so' no file '/usr/local/lib/lua/5.1/libluasql/mysql51.so' no file '/usr/local/lib/lua/5.1/loadall.so' no file './luasql.so' no file './libluasql51.so' no file '/usr/local/lib/lua/5.1/luasql.so' no file '/usr/local/lib/lua/5.1/libluasql51.so' no file '/usr/local/lib/lua/5.1/loadall.so' stack traceback: [C]: in function 'require' /usr/local/freeswitch/scripts/callerID.lua:6: in main chunk On Dec 10, 2013, at 12:44 PM, Saugort Dario Garcia Tovar <dgarcia@anew.com.ve> wrote:
Hi Joli
The answer are already in your hands... in: https://wiki.freeswitch.org/wiki/Mod_lua http://phrogz.net/lua/LearningLua_FromJS.html http://www.lua.org/
With "freeswitch.consoleLog" you get info in the console. You should change your code to:
freeswitch.consoleLog("info", "Got -------------------------------> caller_id_number: " .. callerID .. "\n");
Also, try:
if (callerID == "1234567890")
On 12/10/2013 11:44 AM, Joli Martinez wrote:
Hello,
I am writing a Lua script that will get the callerId info. I need 1 to be able to get the callerID and also to print any messages to the FS_CLI for debugging purpose. By itself the session:execute does transfer to the correct conference, but it does not work with the callerID. And the consoleLog doesnt work it give me an error on the screen.
#!/usr/bin/lua
session:answer();
callerID = session:getVariable("caller_id_number");
freeswitch.consoleLog("Hello World"); --session:execute("conference","4567"); --while (session:ready() == true) do --session:setAutoHangup(false);
if (callerID == 1234567890) then session:execute("conference","4567"); --else -- session:execute("transfer","7890"); end -- end
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Atentamente, Dario García Consultor.
CCCT, Nivel C2, Sector Yarey, Mz, Ofc. MZ03a. Caracas-Venezuela. Teléfono: +58 212 9081842 Cel: +58 412 2221515 dgarcia@anew.com.ve http://www.anew.com.ve _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
1) console: Wiki says you need two args -- freeswitch.consoleLog("info", "lua rocks\n"); 2) lua does typing, and the callerID will be a string. So you want to do: if (callerID == "1234567890") then -Avi On Tue, Dec 10, 2013 at 6:14 PM, Joli Martinez <mrjoli021@gmail.com> wrote:
Hello,
I am writing a Lua script that will get the callerId info. I need 1 to be able to get the callerID and also to print any messages to the FS_CLI for debugging purpose. By itself the session:execute does transfer to the correct conference, but it does not work with the callerID. And the consoleLog doesnt work it give me an error on the screen.
#!/usr/bin/lua
session:answer();
callerID = session:getVariable("caller_id_number");
freeswitch.consoleLog("Hello World"); --session:execute("conference","4567"); --while (session:ready() == true) do --session:setAutoHangup(false);
if (callerID == 1234567890) then session:execute("conference","4567"); --else -- session:execute("transfer","7890"); end -- end
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
1) console: Wiki says you need two args -- freeswitch.consoleLog("info", "lua rocks\n"); 2) lua does typing, and the callerID will be a string. So you want to do: if (callerID == "1234567890") then -Avi On Tue, Dec 10, 2013 at 6:14 PM, Joli Martinez <mrjoli021@gmail.com> wrote:
Hello,
I am writing a Lua script that will get the callerId info. I need 1 to be able to get the callerID and also to print any messages to the FS_CLI for debugging purpose. By itself the session:execute does transfer to the correct conference, but it does not work with the callerID. And the consoleLog doesnt work it give me an error on the screen.
#!/usr/bin/lua
session:answer();
callerID = session:getVariable("caller_id_number");
freeswitch.consoleLog("Hello World"); --session:execute("conference","4567"); --while (session:ready() == true) do --session:setAutoHangup(false);
if (callerID == 1234567890) then session:execute("conference","4567"); --else -- session:execute("transfer","7890"); end -- end
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
participants (4)
-
Areski
-
Avi Marcus
-
Joli Martinez
-
Saugort Dario Garcia Tovar