SMS - app.lua:48 attempt to call a nil value

Status
Not open for further replies.

nickbh

Member
Sep 26, 2019
40
3
8
58
I am trying to send an outbound sms message and I get the above error.

I followed the below link and fixed the chatplan that was default.xml by copying the one mentioned in that below thread.

1. Looking in the freeswitch.log

2021-12-05 16:29:32.210611 [INFO] mod_sms.c:368 Processing text message 1111->XXXXXX4110 in context public
Chatplan: XXXXXX4110 parsing [public->ten-digit] continue=false
Chatplan: XXXXXX4110@xxx.com Regex (PASS) [ten-digit] to(XXXXXXX4110@xxx.com) =~ /^(\d{10}.*)$/ break=on-false
Chatplan: XXXXXX4110@xxx.com Action set(final_delivery=true)
Chatplan: XXXXXX4110@xxx.com Action lua(app.lua sms outbound)
2021-12-05 16:29:32.210611 [ERR] mod_lua.cpp:202 /usr/share/freeswitch/scripts/app.lua:48: attempt to call a nil value
stack traceback:
/usr/share/freeswitch/scripts/app.lua:48: in main chunk


2. Browsing the app.lua, at line 48 -
--route the request to the application
--freeswitch.consoleLog("notice", "["..app_name.."]".. scripts_dir .. "/app/" .. app_name .. "/index.lua\n");
loadfile(scripts_dir .. "/app/" .. app_name .. "/index.lua")(argv);

3. based on error, i am trying to execute app.lua without proper parameters (argv), but the call from chatplan/default.xml provides :

<action application="set" data="final_delivery=true"/>
<action application="lua" data="app.lua sms outbound"/>
4. within the scripts_dir, there exists app/sms/index.lua
/usr/share/freeswitch/scripts/app/sms/index.lua


5. just a note, since bandwidth is using apiv2, had to add application id in a curl call.

I would appreciate any help.

Thanks.
 

nickbh

Member
Sep 26, 2019
40
3
8
58
This is fixed. It was my fault - after writing what I had done, it seems that the addition of applicationID was breaking the index.lua in the sms. Leasson learned and thank you.

Here is the line that needs to be added for someone else using Bandwidth sms apiv2.

Original:
-- cmd="curl -v -X POST " .. api_url .." -u " .. access_key .. ":" .. secret_key .. " -H \"Content-type: application/json\" -d '{\"from\": \"+" .. outbound_caller_id_number .. "\", \"to\": \"+" .. to .."\", \"text\": \"" .. body .."\"}'"

Updateded.
cmd="curl -v -X POST " .. api_url .." -u " .. access_key .. ":" .. secret_key .. " -H \"Content-type: application/json\" -d '{\"from\": \"+" .. outbound_caller_id_number .. "\", \"to\": \"+" .. to .."\", \"text\": \"" .. body .."\", \"applicationId\": \"" .. application_id .. "\"}'"

Added to above file:
if (settings['sms'][carrier..'_application_id'] ~= nil) then
if (settings['sms'][carrier..'_application_id']['text'] ~= nil) then
application_id = settings['sms'][carrier..'_application_id']['text']
end
end
 

Attachments

  • bandwidth.jpg
    bandwidth.jpg
    67.7 KB · Views: 37

falk

Member
Feb 2, 2019
76
5
8
54
Hi i have the same problem , i didn't understand where to change the original with the Updateded
 
Jan 9, 2018
152
16
18
54
changes I made were in the /usr/share/freeswitch/scripts/app.lua
I suspect you mean in /usr/share/freeswitch/scripts/app/sms/index.lua.

And thanks for the info on v2 compatibility. I originally wrote the Telnyx add-on under v1, and never bothered to go back and update to v2.

FYI, on the inbound side, I believe someone mentioned that there may also be breaking changes related to MMS attachments under v2, so you may want to verify that.
 
Status
Not open for further replies.