| How to perform custom actions on incoming or outgoing SMS messages |
Thanks to the Event Handler interface you can link actions on each SMS received or transmittedThe main purpose of the Event Handler is allow you to create custom applications and fully customize the functionalities of your SMS Fox Box. There are two ways to access events inside the interface:
Case 1: The Custom Applications Forms To access this area click on the In this window you have two forms, the first is linked to on RECEIVED items event and the second is linked to on SENDED items event. Now is time to proceed with a practical example, we would like to create a game, a little example of Lottery. We would like that people send SMS messages to the number of SMS FoxBox typing in the text a CODE, and we want to answer to the winner with a SMS notification. Analysis of the problem:To create this application we need to control the text of each incoming message, in case of the message with the winning code we need to extract the phone number of the winner and send a SMS with the notification to the From number extracted. This is a shell script that perform all this actions: #!/bin/sh To try this script, copy it and paste it inside the form "Custom application applied to received items". Then send a message with this CODE: 123456 and you will WIN! :-) As you can see in this example, we have created a little parser using `/bin/cat $1 | grep "$SEARCH"` this means list the content of $1 (that is the full path to the received message) and match if it contains the pattern $SEARCH (the winner code). Then we extract the phone number of the winner with: `/bin/cat $1 | /bin/grep "From:" | awk '{print $2}'` this means list the content of $1 search the pattern "From:" and take the number using awk {print $2} (column 2). At the end we proceed generating the notification message. The code below will create a file with this content, the destination To: (previous extracted number) a blank line and the the text of the notification. FILE=`/bin/mktemp /mnt/flash/spool/outgoing/send_XXXXXX`The variable $1 contains the full PATH to the message, and what is the format of the message in this file? Is simply this ! From: KantaThe messages format is fully explained in this article: SMS Fox Box File Format Case 2: The Event Handler FormTo access this area click on the button on the left menu. In this window you have an already filled form: From here, you have full control on all actions that SMS Fox Box perform for receiving or sending a message. You can assign different meanings to LEDS, disable incoming messages or disable outgoing messages and a lot of other process. To activate or deactivate functionalities you need only to uncomment or comment the little blocks enclosed between (# sharp symbol) You have to keep in mind, that you need to pass arguments to the script you want to lauch: Arguments you can pass are:
The SMS FoxBox Software is developed by KDEV (http://www.kdev.it), a Davide Cantaluppi company on Acme Systems FOX GM Hardware |