[Freeswitch-users] routing incoming SMS?
Giovanni Maruzzelli
gmaruzz at gmail.com
Thu Feb 13 12:58:59 MSK 2014
Hello,
in past times, just for fun, I had a chatbot via sms (Italian language, but
you can easily modify it).
Relevant files from a standard FS install:
=======
/usr/local/freeswitch/conf/chatplan/default.xml
<?xml version="1.0" encoding="utf-8"?>
<include>
<context name="default">
<extension name="demo">
<condition field="to" expression="^(.*)$">
<action application="send"/>
<action application="lua" data="chat.lua"/>
</condition>
</extension>
</context>
</include>
=======
/usr/local/freeswitch/scripts/chat.lua
freeswitch.consoleLog("info", "BEGIN\n\n");
--freeswitch.consoleLog("info", message:getHeader("from") .. "\n");
--freeswitch.consoleLog("info", message:getHeader("to") .. "\n");
--freeswitch.consoleLog("info", message:serialize() .. "\n");
freeswitch.consoleLog("info", message:getBody() .. "\n");
local o, h , m , n
n = message:getBody();
n = string.gsub(n, "'", " ");
n = string.gsub(n, " ", " ");
freeswitch.consoleLog("info", n .. "\n");
m = "/usr/local/bin/chatta.sh '" .. n .. "'";
h = assert(io.popen(m,"r"))
o = h:read("*all")
h:close()
message:chat_execute("reply", o);
freeswitch.consoleLog("info", "END\n\n");
========
/usr/local/bin/chatta.sh
#!/bin/sh
value="$(perl -MURI::Escape -e 'print uri_escape($ARGV[0]);' "$@")"
curl -s http://tobbychatbot.altervista.org/noscript.php -d
"messaggio==${value}" | grep -A 1 "<b>Tobby</b>:<br>" | grep -v
"<b>Tobby</b>:<br>" | sed -e "s/<br>//"
echo "message==${value}" >> /tmp/giova1
========
Hope this helps, or at least will be fun
On Mon, Feb 10, 2014 at 5:29 PM, Russell Treleaven
<rtreleaven at bunnykick.ca>wrote:
> Hi Donny,
>
> I am experimenting with sip simple messaging at the moment.
>
> I am guessing that you need to use the send method instead of the fire
> method.
>
> <include>
> <context name="public">
> <extension name="test">
> <condition>
> <action
> application="set"
> data="to=sip:invisibleMan at bogusDomain.com"
> ></action>
> <action application="info"></action>
> <action application="send"></action>
> </condition>
> </extension>
> </context>
> </include>
>
> I can send a message to the freeswitch server via simple and see that it
> it sent to the new recipient.
> The info method will tell you that the extension is actually being hit in
> the chatplan.
> It will also tell you the all the details of the message.
> The send method actually sends the message.
>
> Its not the whole solution but hopefully it helps you get to the solution.
>
> Sincerely,
>
> Russell Treleaven
>
>
>
> On Mon, Feb 10, 2014 at 11:15 AM, Peter Villeneuve <petervnv1 at gmail.com>wrote:
>
>> Hi Donny,
>>
>> Unfortunately I can't think of anything else.
>>
>> It would be great if someone that has experience with mod_sms and the
>> chatplan would help out or provide a link to a working lua script.
>> Unfortunately it seems no one knowledgeable has taken an interest in this
>> thread..... at least not yet.
>>
>>
>> On Mon, Feb 10, 2014 at 11:17 AM, Donny Hardyanto <
>> hardyanto.donny at gmail.com> wrote:
>>
>>> Hi Peter,
>>>
>>> I tried that and still no change.
>>>
>>>
>>> Donny
>>>
>>>
>>>
>>> On Sat, Feb 8, 2014 at 7:03 PM, Peter Villeneuve <petervnv1 at gmail.com>wrote:
>>>
>>>> Not sure what the problem is, perhaps you need to add
>>>> event:addHeader("proto", "sip"); like in the example here?
>>>> http://wiki.freeswitch.org/wiki/Mod_sms#Args
>>>>
>>>>
>>>> On Thu, Feb 6, 2014 at 3:45 PM, Donny Hardyanto <
>>>> hardyanto.donny at gmail.com> wrote:
>>>>
>>>>> Hi Privus,
>>>>>
>>>>> This is the script for receiving SMS from gateway, and forward to
>>>>> clients (SIP profile 'clients'). The clients already registered in the FS
>>>>> and can make calls. I can confirm that this scripts is executed, but the
>>>>> last event.fire() is look like dont do anything. I checked on the siptrace
>>>>> on.
>>>>>
>>>>>
>>>>> var message_from_user=message.getHeader("from_user");
>>>>> var message_to_user=message.getHeader("to_user");
>>>>> var message_body=message.getBody();
>>>>>
>>>>> console_log("INFO", "[receive_inbound_sms]\n");
>>>>> console_log("INFO", message.serialize()+"\n");
>>>>> console_log("INFO", "message.from_user:"+message_from_user+"\n");
>>>>> console_log("INFO", "message.to_user:"+message_to_user+"\n");
>>>>> console_log("INFO", "message.body:\n"+message_body+"\n");
>>>>>
>>>>> var event = new Event("CUSTOM", "SMS:SEND_MESSAGE");
>>>>> event.addHeader("from", message.getHeader("from"));
>>>>> event.addHeader("to", message_to_user);
>>>>> event.addHeader("dest_proto","sip");
>>>>> event.addHeader("sip_profile","clients");
>>>>> event.addBody(message.getBody());
>>>>> console_log("INFO", "Relay:\n"+event.serialize()+"\n");
>>>>> event.fire();
>>>>>
>>>>> Regards,
>>>>>
>>>>> Donny
>>>>>
>>>>>
>>>>>
>>>>> On Thu, Feb 6, 2014 at 7:58 PM, Privus P <privus007 at gmail.com> wrote:
>>>>>
>>>>>> Hi Donny,
>>>>>>
>>>>>> Perhaps you could share your javascript and lua script so that we
>>>>>> could try to figure out together what isn't working.
>>>>>> Judging by the apparent lack of response to this thread, it seems to
>>>>>> be the best way forward to try and resolve this.
>>>>>>
>>>>>>
>>>>>> On Thu, Feb 6, 2014 at 6:50 AM, Donny Hardyanto <
>>>>>> hardyanto.donny at gmail.com> wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> I have similar problem. I use gateway to GSM provider that support
>>>>>>> SIP simple . So far i can send sms from fs to gateway and receive sms in fs
>>>>>>> from gateway. But I was lost how to send the incoming sms from gateway to
>>>>>>> client.
>>>>>>>
>>>>>>> Also my client support sip simple also. When the sms from client
>>>>>>> arrive at fs, i dont know how to forward them to gateway.
>>>>>>>
>>>>>>> I use Javascript heavily and tried to produce the same thing as lua
>>>>>>> script in javascript but it always fail. The event fire command does not
>>>>>>> produce any thing.
>>>>>>>
>>>>>>> Can any one show us or point us how to forward sms?
>>>>>>>
>>>>>>> Dinny
>>>>>>> On Feb 4, 2014 8:06 PM, "Peter Villeneuve" <petervnv1 at gmail.com>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> Thanks for helping out. Indeed I would love to try out a lua script
>>>>>>>> to handle SMS.
>>>>>>>> Can anyone point to a sample script that I can study and play with?
>>>>>>>>
>>>>>>>> Any help is much appreciated. I'm still stuck with SMS hitting FS
>>>>>>>> but not being forwarded to the peer....
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> Peter
>>>>>>>>
>>>>>>>>
>>>>>>>> On Sun, Feb 2, 2014 at 5:46 PM, Privus P <privus007 at gmail.com>wrote:
>>>>>>>>
>>>>>>>>> Hi Peter,
>>>>>>>>>
>>>>>>>>> I'm not really sure why your SMS isn't being routed correctly.
>>>>>>>>> I'm sure others in this list have a lot more experience and can
>>>>>>>>> help you out, but have you thought of using a lua script to handle SMS
>>>>>>>>> instead of relying on the send action?
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Sat, Feb 1, 2014 at 2:00 PM, Peter Villeneuve <
>>>>>>>>> petervnv1 at gmail.com> wrote:
>>>>>>>>>
>>>>>>>>>> Hi,
>>>>>>>>>>
>>>>>>>>>> I'm experimenting with GSMopen and I'm having trouble doing
>>>>>>>>>> something which is likely pretty simple.
>>>>>>>>>> I have enabled mod_sms and GSMopen in FS. I can send SIP simple
>>>>>>>>>> messages between 2 registered peers OK.
>>>>>>>>>> I can see that incoming GSM SMS messages arrive in FS as
>>>>>>>>>> expected, but I can't seem to get them converted into SIP SIMPLE format and
>>>>>>>>>> routed to the peer (1000).
>>>>>>>>>> Once they arrive in FS, I can see in the log:
>>>>>>>>>>
>>>>>>>>>> 2014-01-30 20:00:54.840999 [INFO] mod_sms.c:336 Processing text
>>>>>>>>>> message +4412398746->gsm01 in context default
>>>>>>>>>> Chatplan: gsm01 parsing [default->basic p2p] continue=true
>>>>>>>>>> Chatplan: gsm01 Regex (PASS) [basic p2p] to(gsm01) =~ /^(.*)$/
>>>>>>>>>> break=on-false
>>>>>>>>>> Chatplan: gsm01 Action send()
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> My chatplan has:
>>>>>>>>>>
>>>>>>>>>> <?xml version="1.0" encoding="utf-8"?>
>>>>>>>>>> <include>
>>>>>>>>>> <context name="default">
>>>>>>>>>>
>>>>>>>>>> <extension name="basic p2p" continue="true">
>>>>>>>>>> <condition field="to" expression="^(.*)$">
>>>>>>>>>> <!-- <action application="lua" data="test.lua"/> -->
>>>>>>>>>> <action application="send"/>
>>>>>>>>>> </condition>
>>>>>>>>>> </extension>
>>>>>>>>>>
>>>>>>>>>> </context>
>>>>>>>>>> </include>
>>>>>>>>>>
>>>>>>>>>> And in my gsmopen.conf.xml:
>>>>>>>>>>
>>>>>>>>>> <configuration name="gsmopen.conf" description="GSMopen
>>>>>>>>>> Configuration">
>>>>>>>>>> <global_settings>
>>>>>>>>>> <param name="debug" value="8"/>
>>>>>>>>>> <param name="dialplan" value="XML"/>
>>>>>>>>>> <param name="context" value="default"/>
>>>>>>>>>> <param name="hold-music" value="$${moh_uri}"/>
>>>>>>>>>> <param name="destination" value="1000"/>
>>>>>>>>>> </global_settings>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> I believe I'm doing something wrong in the chatplan. Is there any
>>>>>>>>>> transfer action like in the regular XML dialplan?
>>>>>>>>>> I tried creating in the default dialplan the following, hoping
>>>>>>>>>> that it would be similar to sofia calls and transfer the incoming SMS to
>>>>>>>>>> peer 1000, but no dice.
>>>>>>>>>>
>>>>>>>>>> <include>
>>>>>>>>>> <extension name="sms_inbound">
>>>>>>>>>> <condition field="destination_number" expression="^(gsm01)$">
>>>>>>>>>> <action application="transfer" data="1000 XML default"/>
>>>>>>>>>> </condition>
>>>>>>>>>> </extension>
>>>>>>>>>> </include>
>>>>>>>>>>
>>>>>>>>>> So, basically, how can I route the incoming SMS to peer 1000?
>>>>>>>>>>
>>>>>>>>>> Thanks
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> _________________________________________________________________________
>>>>>>>>>> Professional FreeSWITCH Consulting Services:
>>>>>>>>>> consulting at freeswitch.org
>>>>>>>>>> http://www.freeswitchsolutions.com
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Official FreeSWITCH Sites
>>>>>>>>>> http://www.freeswitch.org
>>>>>>>>>> http://wiki.freeswitch.org
>>>>>>>>>> http://www.cluecon.com
>>>>>>>>>>
>>>>>>>>>> FreeSWITCH-users mailing list
>>>>>>>>>> FreeSWITCH-users at lists.freeswitch.org
>>>>>>>>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>>>>>>>>> UNSUBSCRIBE:
>>>>>>>>>> http://lists.freeswitch.org/mailman/options/freeswitch-users
>>>>>>>>>> http://www.freeswitch.org
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> _________________________________________________________________________
>>>>>>>>> Professional FreeSWITCH Consulting Services:
>>>>>>>>> consulting at freeswitch.org
>>>>>>>>> http://www.freeswitchsolutions.com
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Official FreeSWITCH Sites
>>>>>>>>> http://www.freeswitch.org
>>>>>>>>> http://wiki.freeswitch.org
>>>>>>>>> http://www.cluecon.com
>>>>>>>>>
>>>>>>>>> FreeSWITCH-users mailing list
>>>>>>>>> FreeSWITCH-users at lists.freeswitch.org
>>>>>>>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>>>>>>>> UNSUBSCRIBE:
>>>>>>>>> http://lists.freeswitch.org/mailman/options/freeswitch-users
>>>>>>>>> http://www.freeswitch.org
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> _________________________________________________________________________
>>>>>>>> Professional FreeSWITCH Consulting Services:
>>>>>>>> consulting at freeswitch.org
>>>>>>>> http://www.freeswitchsolutions.com
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Official FreeSWITCH Sites
>>>>>>>> http://www.freeswitch.org
>>>>>>>> http://wiki.freeswitch.org
>>>>>>>> http://www.cluecon.com
>>>>>>>>
>>>>>>>> FreeSWITCH-users mailing list
>>>>>>>> FreeSWITCH-users at lists.freeswitch.org
>>>>>>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>>>>>>> UNSUBSCRIBE:
>>>>>>>> http://lists.freeswitch.org/mailman/options/freeswitch-users
>>>>>>>> http://www.freeswitch.org
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> _________________________________________________________________________
>>>>>>> Professional FreeSWITCH Consulting Services:
>>>>>>> consulting at freeswitch.org
>>>>>>> http://www.freeswitchsolutions.com
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Official FreeSWITCH Sites
>>>>>>> http://www.freeswitch.org
>>>>>>> http://wiki.freeswitch.org
>>>>>>> http://www.cluecon.com
>>>>>>>
>>>>>>> FreeSWITCH-users mailing list
>>>>>>> FreeSWITCH-users at lists.freeswitch.org
>>>>>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>>>>>> UNSUBSCRIBE:
>>>>>>> http://lists.freeswitch.org/mailman/options/freeswitch-users
>>>>>>> http://www.freeswitch.org
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> _________________________________________________________________________
>>>>>> Professional FreeSWITCH Consulting Services:
>>>>>> consulting at freeswitch.org
>>>>>> http://www.freeswitchsolutions.com
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> Official FreeSWITCH Sites
>>>>>> http://www.freeswitch.org
>>>>>> http://wiki.freeswitch.org
>>>>>> http://www.cluecon.com
>>>>>>
>>>>>> FreeSWITCH-users mailing list
>>>>>> FreeSWITCH-users at lists.freeswitch.org
>>>>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>>>>> UNSUBSCRIBE:
>>>>>> http://lists.freeswitch.org/mailman/options/freeswitch-users
>>>>>> http://www.freeswitch.org
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> _________________________________________________________________________
>>>>> Professional FreeSWITCH Consulting Services:
>>>>> consulting at freeswitch.org
>>>>> http://www.freeswitchsolutions.com
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Official FreeSWITCH Sites
>>>>> http://www.freeswitch.org
>>>>> http://wiki.freeswitch.org
>>>>> http://www.cluecon.com
>>>>>
>>>>> FreeSWITCH-users mailing list
>>>>> FreeSWITCH-users at lists.freeswitch.org
>>>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>>>> UNSUBSCRIBE:
>>>>> http://lists.freeswitch.org/mailman/options/freeswitch-users
>>>>> http://www.freeswitch.org
>>>>>
>>>>>
>>>>
>>>>
>>>> _________________________________________________________________________
>>>> Professional FreeSWITCH Consulting Services:
>>>> consulting at freeswitch.org
>>>> http://www.freeswitchsolutions.com
>>>>
>>>>
>>>>
>>>>
>>>> Official FreeSWITCH Sites
>>>> http://www.freeswitch.org
>>>> http://wiki.freeswitch.org
>>>> http://www.cluecon.com
>>>>
>>>> FreeSWITCH-users mailing list
>>>> FreeSWITCH-users at lists.freeswitch.org
>>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>>> UNSUBSCRIBE:
>>>> http://lists.freeswitch.org/mailman/options/freeswitch-users
>>>> http://www.freeswitch.org
>>>>
>>>>
>>>
>>> _________________________________________________________________________
>>> Professional FreeSWITCH Consulting Services:
>>> consulting at freeswitch.org
>>> http://www.freeswitchsolutions.com
>>>
>>>
>>>
>>>
>>> Official FreeSWITCH Sites
>>> http://www.freeswitch.org
>>> http://wiki.freeswitch.org
>>> http://www.cluecon.com
>>>
>>> FreeSWITCH-users mailing list
>>> FreeSWITCH-users at lists.freeswitch.org
>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>>> http://www.freeswitch.org
>>>
>>>
>>
>> _________________________________________________________________________
>> Professional FreeSWITCH Consulting Services:
>> consulting at freeswitch.org
>> http://www.freeswitchsolutions.com
>>
>>
>>
>>
>> Official FreeSWITCH Sites
>> http://www.freeswitch.org
>> http://wiki.freeswitch.org
>> http://www.cluecon.com
>>
>> FreeSWITCH-users mailing list
>> FreeSWITCH-users at lists.freeswitch.org
>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>> http://www.freeswitch.org
>>
>>
>
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
>
>
>
>
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://wiki.freeswitch.org
> http://www.cluecon.com
>
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
>
--
Sincerely,
Giovanni Maruzzelli
Cell : +39-347-2665618
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20140213/1fbb05bf/attachment-0001.html
Join us at ClueCon 2013 Aug 6-8, 2013
More information about the FreeSWITCH-users
mailing list