Hi All, I am trying to write a LUA script which will slot into a chatplan whose goal is to simple take a simple text message (SIMPLE MESSAGE) and then distribute it to multiple recipients. I wrote a script which takes some arguments (sender, recipieant list and the body) then would generate new SIP Messages to be sent to each of the recipient. The code I use to generate the message (which is more or less the example given in mod_sms for sending an SMS, not exactly what I want to do): local event = freeswitch.Event("CUSTOM", "SMS::SEND_MESSAGE"); event:addHeader("proto", "global"); event:addHeader("dest_proto", "sip"); event:addHeader("from", source); event:addHeader("to", domain.."/"..recipient); event:addHeader("type", "text/plain"); event:addHeader("skip_global_process", "true"); event:addBody( body ); event:fire(); This gives the error: [WARNING] sofia_presence.c:221 Not sending to local box for XXXX@10.11.12.13 [ERR] sofia_presence.c:272 Chat proto [sip] from [<sip:YYYY@10.11.12.13>;tag=uUQudJKEl1SKjq8wdjqwi68768] to [XXXX@10.11.12.13] Some message text Nobody to send to: Profile internal But the message actually arrives successfully. This is fine but I would prefer not to have lots of error messages. So I tried to find a more correct way to do this. I tried the following (based on what I could find in freeswitch 1.6.20 source code): local event = freeswitch.Event("SWITCH_EVENT_SEND_MESSAGE"); event:addHeader("user", recipient ); event:addHeader("host", domain ); event:addHeader("profile", domain ); event:addHeader("subject", "SIMPLE MESSAGE"); event:addHeader("content-type", "text/plain"); event:addHeader("from", source); event:addBody( body ); event:fire(); But this gives the same error. How can I send a simple SIP Message with LUA to a locally registered user? Many thanks, Aaron
i had the same problem.. i solve it setting a sip uri in "to" where the user is registered... i'm doing it on fs master, not sure if it will work on 1.6 example: event:addHeader("to", "sip:200@192.168.10.2:38592"); To get the uri in lua: contact = api:execute("sofia_contact", "user/200@lab.local"); profile = contact:match("sofia/(.*)/") or ""; to = contact:match("sofia/.*/(.*)") or ""; Probably there is a easier way... On 03/13/2018 04:03 PM, Ronnie Beck wrote:
Hi All,
I am trying to write a LUA script which will slot into a chatplan whose goal is to simple take a simple text message (SIMPLE MESSAGE) and then distribute it to multiple recipients. I wrote a script which takes some arguments (sender, recipieant list and the body) then would generate new SIP Messages to be sent to each of the recipient. The code I use to generate the message (which is more or less the example given in mod_sms for sending an SMS, not exactly what I want to do):
local event = freeswitch.Event("CUSTOM", "SMS::SEND_MESSAGE"); event:addHeader("proto", "global"); event:addHeader("dest_proto", "sip"); event:addHeader("from", source); event:addHeader("to", domain.."/"..recipient); event:addHeader("type", "text/plain"); event:addHeader("skip_global_process", "true"); event:addBody( body ); event:fire();
This gives the error:
[WARNING] sofia_presence.c:221 Not sending to local box for XXXX@10.11.12.13 <#NOP> [ERR] sofia_presence.c:272 Chat proto [sip] from [<sip:YYYY@10.11.12.13>;tag=uUQudJKEl1SKjq8wdjqwi68768] to [XXXX@10.11.12.13] Some message text Nobody to send to: Profile internal
But the message actually arrives successfully. This is fine but I would prefer not to have lots of error messages. So I tried to find a more correct way to do this. I tried the following (based on what I could find in freeswitch 1.6.20 source code):
local event = freeswitch.Event("SWITCH_EVENT_SEND_MESSAGE"); event:addHeader("user", recipient ); event:addHeader("host", domain ); event:addHeader("profile", domain ); event:addHeader("subject", "SIMPLE MESSAGE"); event:addHeader("content-type", "text/plain"); event:addHeader("from", source); event:addBody( body ); event:fire();
But this gives the same error.
How can I send a simple SIP Message with LUA to a locally registered user?
Many thanks,
Aaron
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@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@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Saludos / Regards / Cumprimentos Anónio Silva
participants (2)
-
antonio
-
Ronnie Beck