Making SMS Work For You -- Building SMS Actions for Drupal
At the MIT Mobile Experience Lab, we are doing a lot of interesting projects to connect people more with the places they visit, the people they know (or don't know), and information, with an emphasis on helping people while they are mobile. Since an increasing number of mobile people carry mobiles, a lot of my work has been working on ways to create connection by using a cellphone.
Lately in particular I have been working with SMS. The SMS Framework for Drupal is pretty awesome, but we needed better two-way communication. We aren't trying to just let people post to a Drupal site via SMS, we needed to be able to send commands to Drupal via SMS to trigger activity in the site and receive feedback.
I drew a lot of the design for my SMS actions from my experience working with the Services module and it functions in a very similar way. Contrib modules register their own actions (keywords which are triggered off the first word of an incoming SMS) and specify callback methods for those actions. The callbacks then process the text and can fire back responses to the user or simply just perform some action in the system.
An example of this system might be to register yourself as a new user on the site. You might send a text message with the content:
My custom module would provide an action set to SMS Framework like this:
My custom function
my_custom_module_register() would be triggered on any text message that's first word was "register" and would be passed the rest of the message so that it can do whatever it needs to do from there. A function like this, for instance, might take the second word of the text message "cascadingstyle" and the phone number the text message originated from, and attempt to register a new Drupal user. Since Drupal wants an email address typically, perhaps we would simply use the neat service TeleFlip and give the user an "email address" of
firstname.lastname@example.org. (I wouldn't necessarily do this in a real-life situation, but this is just an example so humor me).
If the username were already registered or if there were some other problem, the function would return an error, which could optionally be sent back to the original message sender via SMS.
Were the process a success, we might send a message to the sender congratulating them on registering and telling them about some other text message action that they have now unlocked by registering for the site.
To me, the possibilities of this are extremely exciting and I am looking forward to lots of personal experiments with this interface after I wrap up some other projects.
I noticed that this something along these lines actually falls into the SMS Framework roadmap, along with reworking the framework's receiving mechanisms and working them into the core framework module. Well, in the process of building my SMS Actions I have done a lot of those things. I am actively working to figure out what I need to do here at MIT to release the code under the GPL but will hopefully soon be able to do that.
Coincidentally, Will Wright (one of the head honchos of SMS Framework) recently posted about getting the framework to work with Gnokii whereas I have been working to set up the system to work with Gammu (which is a fork of the oft-forked Gnokii project). It's always very cool when other people are working on the same sorts of things independently and concurrently.