[Freeswitch-users] Sending SIP Messages from LUA

Ronnie Beck ronybeck at themenz.biz
Tue Mar 13 15:03:39 UTC 2018


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 at 10.11.12.13
[ERR] sofia_presence.c:272 Chat proto [sip]
from [<sip:YYYY at 10.11.12.13>;tag=uUQudJKEl1SKjq8wdjqwi68768]
to [XXXX at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20180313/ebb179aa/attachment.html>


More information about the FreeSWITCH-users mailing list