Asterisk PBX SMS sending
Download: ngsms (perl script)Asterisk is an open source IP PBX platform. With Ozeki NG SMS Gateway you can add SMS functionality to Asterisk PBX. Once you have Ozeki NG SMS Gateway installed, you can send voice mail notifications, fax notifications, missed call alerts and SMS text messages on various events. This SMS Gateway provides a much better option for SMS messaging then the built in SMS functionality of Asterisk. Ozeki NG SMS Gateway can use GSM Modem(s) attached to your server and IP SMS connections (SMPP, UCP, CIMD2, etc) to send the SMS messages.
How does it work?
To get the system working, you have to attach a GSM phone or GSM Modem to your PC with a phone-to-PC datacable (Figure 1.). This GSM phone will send the SMS messages. After the phone is attached, you need to install the Ozeki NG SMS Gateway software and configure the GSM Modem in it. Ozeki NG - SMS Gateway will be responsible for encoding the messages and for handling your phone. The next step is to install the ngSMS extension to Asterisk PBX. The ngSMS module can be downloaded on this webpage. It makes it possible for you to use the ngsms command in your asterisk configuration files.
The ngsms module and Ozeki NG - SMS Gateway can be located on two different computers. Often Ozeki NG and the GSM modem is installed on Windows XP and Asterisk PBX with ngsms is running on a Linux box. When the Asterisk PBX would like to send an SMS message, the ngsms module will perform an HTTP request to Windows XP machine running Ozeki NG - SMS Gateway and Ozeki NG will send the message through the attached GSM Modem.
How to use
In this example Asterisk runs on Ubuntu Linux and Ozeki NG SMS
Gateway runs on Windows XP.
On Figure 3 you can see the IP address of the computer on which Ozeki NG SMS
Gateway runs. The IP address is 192.168.91.211
Start Terminal on Ubuntu Linux (Figure 4).
If Terminal is launched install Asterisk with the following
command:
sudo apt-get install asterisk
Create a directory with the name ozekisms with the
following command:
mkdir ozekisms
Enter ozekisms directory
with the following command:cd ozekisms
Download ngsms.tgz:
wget http://www.ozekisms.com/attachments/1/ngSMS.tgz
Extract the downloaded ngsms.tgz file:
tar -xzvf ngSMS.tgz
Enter ngsms directory:
cd ngSMS
In ngsms directory extract the file:
tar -xzvf libwww-perl-5.805.tar.gz
Enter libwww-perl directory:
cd libwww-perl-5.805
Type perl Makefile.PL (Figure 13):
perl Makefile.PL
Type make (Figure 14):
make
Type make test (Figure 15):
make test
Type sudo make install (Figure 16). This command will compile
and install libwww-perl file:
sudo make install
Move up one directory:
cd ..
Extract asterisk-perl complement:
tar -xzvf asterisk-perl-0.10.tar.gz
Enter the extracted directory:
cd asterisk-perl-0.10
Type perl Makefile.PL (Figure 20):
perl Makefile.PL
Type make (Figure 21):
make
Type make test (Figure 22):
make test
Compile and install Perl module for Asterisk (Figure 23):
sudo make install
Move up one directory (Figure 24):
cd ..
Create agi-bin directory in /usr/share/asterisk directory
(Figure 25):
sudo mkdir /usr/share/asterisk/agi-bin
Copy ngsms Perl script into the created agi-bin directory under the name of ngsms (Figure 26):
sudo cp ./ngsms /usr/share/asterisk/agi-bin/ngsms
Open ngsms Perl script to edit (Figure 27):
sudo nano /usr/share/asterisk/agi-bin/ngsms
Specify the IP adress of the computer on which Ozeki NG SMS Gateway runs at $smsgateway line. In our example the IP address is: 192.168.91.211 (Figure 28).
In our example there is a test_config directory on the desktop that contains an extensions.conf and users.conf file (Figure 29).
In users.conf file there are two clients: oz850 and oz851 (Figure 30).
In our example there is a very basic rule defined: if client oz851 is called, ngsms module will be issued and instead of telephone calling, an SMS text message will be sent out (Figure 31):
exten => 850,1,Dial(SIP/oz850) exten => 851,1,AGI(ngsms,+4412300000,This is a test message,+4412300012,,1)
AGI(ngsms,+4412300000,This is a test message,+4412300012,,1)
In this format the parameters should be read as follows:
ngsms | tells AGI to launch the ngsms script |
+4412300000 | is the recipient phone number |
This is a test message | is the message text. You can use variables in it. |
+4412300012 | is the sender phone number. This can be a number or an alphanumeric string. |
is the message type. This can be any of the messagetypes below. Since it is blank the message type will be text. | |
1 | is the extra parameter. For example in a voicemail indication this should contain the number of messages in the mailbox. |
Message types:
For text messages you do not have to specify a messagetype | |
VOICEMAILON | Sets a voicemail indication on the cellphone. The extra parameter contains the number of messages in the mailbox. |
VOICEMAILOFF | Clears a voicemail indication on the cellphone. The extra parameter should be set to 0. |
FAXON | Sets a fax indication on the cellphone. The extra parameter contains the number of messages in the mailbox. |
FAXOFF | Clears a fax indication on the cellphone. The extra parameter should be set to 0. |
EMAILON | Sets an email indication on the cellphone. The extra parameter contains the number of messages in the mailbox. |
EMAILOFF | Clears an email indication on the cellphone. The extra parameter should be set to 0. |
VIDEOON | Sets a video message indication on the cellphone. The extra parameter contains the number of messages in the mailbox. |
VIDEOOFF | Clears a video message indication on the cellphone. The extra parameter should be set to 0. |
WEBLINK | Sends a webpage URL to the phone. This webpage can be opened in the phone browser with a simple click. The extra parameter should contain the URL starting with http:// |
WEBBOOKMARK | Sends a webpage bookmark to the phone. This webpage bookmark will be stored in the phone browser. The extra parameter should contain the URL starting with http:// |
Now extensions.conf file needs to be copied from
test_config directory to /etc/asterisk directory (Figure 32):
sudo cp /home/ozeki/Desktop/test_config/extensions.conf /etc/asterisk/extensions.conf
Now users.conf file also needs to be copied from test_config directory to /etc/asterisk directory (Figure 33):
sudo cp /home/ozeki/Desktop/test_config/users.conf /etc/asterisk/users.conf
Finally, Asterisk service needs to be restart (Figure 34):
sudo service asterisk restart
I simulated a test call: I called oz851 client and ngsms module sends out the SMS message. You can see the sent message in Ozeki NG SMS Gateway on Figure 35.
Further utilization examples
exten=>115,55,AGI(ngsms|+4412300000|You have a voicemail from ${CALLERID}. Message was recorded at ${DATETIME}|+4412300012) exten=>115,55,AGI(ngsms|+4412300000|You have ${VMCOUNT(100)} messages|+4412300012|VOICEMAILON|${VMCOUNT(100)}) exten=>115,55,AGI(ngsms|+4412300000|Clearing voicemail indication on phone|+4412300012|VOICEMAILOFF|0) exten=>115,55,AGI(ngsms|+4412300000|Visit www.ozekisms.com!|+4412300012|WEBLINK|http://www.ozekisms.com) exten=>115,55,AGI(ngsms|+4412300000|Bookmark www.ozekisms.com in your phone browser|+4412300012|WEBBOOKMARK|http://www.ozekisms.com)
How to set Voicemail indication on the cellphone
exten => 115,1,VoiceMail(${EXTEN}) exten => 115,55,AGI(ngsms|+4412300000|You have ${VMCOUNT(100)} messages|+4412300012|VOICEMAILON|${VMCOUNT(100)}) exten => 115,56,AGI(ngsms|+4412300000|You have a voicemail from ${CALLERID}. Message was recorded at ${DATETIME}|+4412300012) exten => 115,57,Hangup
How to clear Voicemail indication
exten => 120,1,VoiceMailMain(${EXTEN}) exten => 120,55,AGI(ngsms|+4412300000|Clearing voicemail indication on phone|+4412300012|VOICEMAILOFF|0) exten => 120,57,Hangup
Highlights
Integrates well with Asterisk AGI architecture! | |
Provides an in-house solution. There is no need to subscribe for a service! | |
Works with all wireless networks in the world! | |
High capacity. Up to 500 SMS/second (on IPSMS connections) | |
Support for local and international recipient number formats | |
Dynamic sender number or (alphanumeric string) | |
International (Unicode) characters can be used in text messages | |
Support for long (multipart) messages | |
Message Waiting Indication Support, to enable Voice mail waiting or Fax waiting indication on cellphones. |
Download Asterisk SMS extension
ngSMS is a small module that you install on your Asterisk PBX. It is a Perl script that uses the AGI interface. This module makes it possible to use the ngSMS command in your configuration files to send text messages.
Download:
Prerequisites:
LWP::UserAgent
Asterisk::AGI
More information
- How to connect SMS Gateway to the telephone network for voice calls
- Ozeki Phone Sytem PBX SMS
- Asterisk PBX SMS
- Prerequisites for Asterisk SMS
- Database
- SMS order
- SMS Pin game
- How to create an SQL Express database for SMS Pin game
- ASP User Script setup for SMS Pin game
- ASP Script for creating pin game
- Appendix
- Feature list of Ozeki NG SMS Gateway
- FAQ of the Ozeki NG SMS Gateway