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:

register cascadingstyle

My custom module would provide an action set to SMS Framework like this:

function my_custom_module_sms_action() {
  return array(
      '#method' => 'register',
      '#callback' => 'my_custom_module_register',

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 (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.


Hmm, definitely a lot of

Hmm, definitely a lot of possibilities here. I'd be interested to see what develops in the mobile event realm - ie, crowd interaction at concerts. I've been to a few shows this summer that featured some sort of text message interaction. Usually it's along the lines of send a text message to specified number, winner will be picked near the end of show, winner gets to go backstage.

I'm excited to see how this experience improves and could turn the traditional concert experience (or what is left of the 'traditional' concert experience) into even more of a multimedia experience.

Keep up the hard work Boston boy! :)

I was surprise when looking

I was surprise when looking at my Google Analytics how many people had visited my site from an iPhone. It really made me start thinking about that market in a way I hadn't before. I was concerned that my site might not be well formatted for those visitors and their small screens.

This looks awesome.

This looks awesome. Hopefully we'll be able to see the code soon as I'm curious as to how similar our two approaches are. I'll work on packaging my bit up for testing.

Also as cool coincidence with gnokii and Gammu! Glad you're finding the project useful!

Nice work! Glad to see more

Nice work! Glad to see more people involved with this project.

Instead of only approving actions "if the username were already registered" we were also envisioning another workflow...

Say someone sees a number at an event and sends a message to the website — this action is then responded to as an anonymous user. But at a later time if the user registers at the site they can then claim their actions (based on their phone number) and any new privileges are then granted to their original actions. A good example of this would be content ownership.

I also think this is a great way to create interaction and lead to sign ups.

Anyway, hope to see more from you soon ;)