- FreeSWITCH 1.8
- Anthony Minessale II Giovanni Maruzzelli
- 167字
- 2025-04-04 18:52:56
mod_sms and chatplan
Chatplan is the dialplan for chats. Chatplan is the new black! First of all you must edit /usr/local/freeswitch/conf/autoload_configs/modules.conf.xml and uncomment mod_sms loading at FS startup, as follows:
<load module="mod_sms"/>
Then you restart FreeSWITCH, or manually load mod_sms from fs_cli:
load mod_sms
Now, we must edit the chatplan in /usr/local/freeswitch/conf/chatplan/default.xml :
<?xml version="1.0" encoding="utf-8"?> <include> <context name="public"> <extension name="demo"> <condition field="to" expression="^(3\d{3})@.*$"> <action application="info"/> <action application="set" data="to=${to_user}-${to_host}"/> <action application="set" data="dest_proto=conf"/> <action application="set" data="chat_proto=conf"/> <action application="set" data="skip_global_process=true"/> <action application="set" data="from=${from_user}"/> <action application="set" data="final_delivery=true"/> <action application="set" data="from_full=<sip:${from_user}@${from_host}>"/> <action application="info"/> <action application="send"/> <action application="stop"/> <action application="info"/> </condition> </extension> </context> </include>
This chatplan will intercept the SIMPLE SIP instant messages sent to the conference extension (regular expression beginning with "3", then three times a number, then "@" something) and route them to the conference chat itself (the "to" field mimics the internal FreeSWITCH routing of conference chat events).
We then shape the "from" fields, so they look better when displayed in conference chat.
Before and after those transformations, we output to the FreeSWITCH console all the message variables (same as the "info" application in dialplan): before and after the treatment.
This chatplan will allow for a bridge between incoming SIP instant messages and conference chat events.
Don't forget to reload the FreeSWITCH configuration from fs_cli:
reloadxml