This page is working on progresss ....
mod_sms provide a way to route messages in freeswitch, potentially allowing one to build a powerful chatting system like in XMPP using using SIP SIMPLE on SIP clients.
Just like XML Dialplan has dialplan, mod_sms has chatplan.
mod_sms bind on GLOBAL message event system, so it catches all MESSAGE events and then route them to the chatplan. If no chatplan entry matches, it works as default - e.g. two clients sending message in a point-to-point manner.
Compile and Load
In the source tree
mod_sms is a new module (in late Sept 2011), so users who upgrade from an older FreeSWITCH install need to copy freeswitch.xml from source or add the following section to the existing conf/freeswitch.xml.
You'll also need to add mod_sms to the loadable modules in conf/autoload_configs/modules.conf.xml
And then create the conf/chatplan dir. Create a default.xml like this:
Basic Usage With Default Config
I used Eyebeam for test, I believe Xlite should work. The following demo shows a message sent from 1004 to 1019.
Create new contact in Eyebeam and then right click the contact and click instant message then an instant message window will appear.
Type hello and you should get a reply immediately "Hello, you said hello"
The log will like this:
From the log you could find out that the message was caught by mod_sms and then hit the chatplan. The default chatplan just simply sent back a reply.
Just like dialplan tools there's a set of chatplan tools
Reply to a message
fire an event to the FS event system, here's a sample event:
Send the message as is.
You can also directly call the various programming language modules from the chatplan:
These scripts are run directly inside the chatplan. They have to define a function called "chat", which is then run. Here's an example from python:
This interface defines two objects: Message and Args.
Like the session object in the event system, there's a message object in chatplan. The primary functions are:
getHeader — return one of the message headers
serialize — convert the entire message into a string
Here's a sample of handle_chat.lua
message is a standard event so it's the same API as always with an extra method
chat_execute to run the apps.
Args is a string passed to the method containing whatever arguments were passed from the chatplan.
These scripts also have direct access to the variables present in the chatplan. This is done just as done elsewhere: GetGlobalVariable.
Sending a Message from a script
reply functions exist, you may want more direct control over the output of the message. Instead, you can directly create and fire off a message event. The following is an example from Lua:
Sending a Message via ESL
You can also send a message via ESL. mod_sms must be loaded or this will not work.
Here is an example perl script utilizing ESL to send a message.
And the same script in Python.