Javascript implementation of Kannel Box protocol
Description
Kannel.js is a javascript implementation of Kannel Box protocol, it allow write some powerful SMS VAS applications or sms gateways with kannel and node.js
Installation
npm install kannel
Connect to bearerbox using object config
var kannel = app = host : '192.168.10.3' // bearerbox host - default '127.0.0.1' port : 14001 //smsc connection port - default 13001 id : "helloBox" // smsc id - defaut "" frequence : 1 // hearbeat - default 5s ; app; app;
Connect to bearerbox using kannel config file information
var kannel = app = "kannel/kannel.conf?"+ "host=$..bearerbox-host&"+ "port=$..smsbox-port&"+ "id=$.smsbox[-1:].smsbox-id&"+ "frequence=$.smsbox[-1:].frequence-time" ; app; app;
The parser use JSONpath's syntax for access to the json representation of the conf file.
Receive / Send SMS
var kannel = app = "kannel/kannel.conf?"+ "host=$..bearerbox-host&"+ "port=$..smsbox-port&"+ "id=$.smsbox[-1:].smsbox-id&"+ "frequence=$.smsbox[-1:].frequence-time" ; app; app; app;
Send a delivery ACK
var kannel = app = "kannel/kannel.conf?"+ "host=$..bearerbox-host&"+ "port=$..smsbox-port&"+ "id=$.smsbox[-1:].smsbox-id&"+ "frequence=$.smsbox[-1:].frequence-time" ; app; app; app;
Receive ADMIN command from bearerbox
var kannel = app = "kannel/kannel.conf?"+ "host=$..bearerbox-host&"+ "port=$..smsbox-port&"+ "id=$.smsbox[-1:].smsbox-id&"+ "frequence=$.smsbox[-1:].frequence-time" ; app; app; app;
How test samples
Run bearebox
$ cd path/to/kannel.js $ sudo bearerbox kannel/kannel.conf
Test echobox (echo server clusterized)
Usage
$ node samples/echoBox [path to kannel.conf]
Example
$ cd path/to/kannel.js $ node samples/echoBox echoBox worker #{1} is connected to 127.0.0.1:14001 echoBox worker #{3} is connected to 127.0.0.1:14001 echoBox worker #{2} is connected to 127.0.0.1:14001 echoBox worker #{4} is connected to 127.0.0.1:14001
Test replbox (REPL sms)
Usage
$ node samples/replbox [path to kannel.conf]
Example
$ cd path/to/kannel.js $ node samples/replbox replbox is connected to 127.0.0.1:14001
Type your SMS in REPL console, the server send a echo responce for each recieved sms.
Test smsToMail (clusterized)
Usage
$ node samples/smsToMail [path to kannel.conf]
Example
$ cd path/to/kannel.js $ node samples/smsToMail smsToMail worker #{1} is connected to 192.168.2.4:14001 smsToMail worker #{5} is connected to 192.168.2.4:14001 smsToMail worker #{4} is connected to 192.168.2.4:14001 smsToMail worker #{3} is connected to 192.168.2.4:14001 smsToMail worker #{6} is connected to 192.168.2.4:14001 smsToMail worker #{8} is connected to 192.168.2.4:14001 smsToMail worker #{7} is connected to 192.168.2.4:14001 smsToMail worker #{2} is connected to 192.168.2.4:14001
Test messagesBoard (websocket and sms chat)
Usage
$ node samples/messagesBoard [path to kannel.conf]
Example
$ cd path/to/kannel.js $ node samples/messagesBoard Fri Apr 11 2014 04:09:22 GMT+0100 Server is listening on port 14014
Goto to http://127.0.0.1:14014, Type your name, your message or send sms for chat, Enjoy your chat.
Test scripting (coffeeScript and javascript VAS applications)
Usage
$ node samples/scripting [path to kannel.conf]
Example
$ cd path/to/kannel.js $ node samples/scripting scripting box is connected to 127.0.0.1:14001 Fri Apr 11 2014 04:09:22 GMT+0100 Server is listening on port 14014
Goto to http://127.0.0.1:14014, for show the dashboard. Goto to samples/scripting/public/scripts for sms service. The SMS services is identified by the name of script whitout extension. ( Ex : "FUTURE" represent futur.coffee, "COUNT" represent count.js )
You can also send SMS from http request
/cgi-bin/sendsms send sms GET request Paramametres from : default "****" to : receiver text : SMS to send Response Success : http code 200 Fails : http code 403 Example : http://127.0.0.1:14014/cgi-bin/sendsms?from=07086&to=05026&text=Test
[Tuto] Test Kannel.js
Prerequisite
Before start you must now It :
- It's a kannel.js is a librarie who allow to create a smsbox remplacement for more efficient SMS VAS application.
- The new infrastructure become :
+----------+----------+-------------+----------+-------------------------+----------+-------------------------+
| Operator | Protocol | Application | Protocol | Application | Protocol | Application |
+----------+----------+-------------+----------+-------------------------+----------+-------------------------+
| SMSC | <socket> | bearerbox | <socket> | Your NodeJs Application | | |
+----------+----------+-------------+----------+-------------------------+----------+-------------------------+
| Instead of |
+----------+----------+-------------+----------+-------------------------+----------+-------------------------+
| SMSC | <socket> | bearerbox | <socket> | smsbox | <http> | Your NodeJs Application |
+----------+----------+-------------+----------+-------------------------+----------+-------------------------+
- For test processing it you must have
How start a sample
Make your sure kannel is down, configured and work well (bearerbox and smsbox).
- Clone kannel.js reposotory
$ git clone https://github.com/badlee/kannel.js.git
- Go to in mybox
$ cd kannel.js
- Run a bearerbox
$ bearerbox -v 0 /etc/kannel/kannel.conf 1>/tmp/bearerbox.log 2>&1 &
- Run sample
$ node samples/scripting /etc/kannel/kannel.conf
- If you see
scripting box is connected to
all is ok
Send SMS to your application
You can send directly to your shortnumber or to your connected modem. But if you want test localy you must run fakesmsc (part of kannel-extras).
$ /usr/lib/kannel/test/fakesmsc "FROM TO text script"
$ ## Example of test $ /usr/lib/kannel/test/fakesmsc "0708 6061 text hello oshimin" # test hello.js service $ /usr/lib/kannel/test/fakesmsc "1120 8080 text futur" # Test futur services $ /usr/lib/kannel/test/fakesmsc "0708 8080 text count" # Test Count $ /usr/lib/kannel/test/fakesmsc "FROM TO text vote A" # Test de vote $ /usr/lib/kannel/test/fakesmsc "FROM TO text vote B" # Test de vote $ /usr/lib/kannel/test/fakesmsc "FROM TO text vote C" # Test de vote $ /usr/lib/kannel/test/fakesmsc "FROM TO text vote D" # Test de vote
License
(The MIT License)
Copyright (c) 2007-2009 Ulrich Badinga <badinga.ulrich@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.