Text message your Drupal site

In May, while speaking at and attending the Make Web Not War conference in Vancouver, I met up with Adam Kalsey from Tropo and attended his talk outlining how his messaging service, called Tropo, can be integrated with Drupal. I came away with tons of ideas on how to use this service to do neat things with Drupal. I decided to start with some low hanging fruit. We currently have a module for Drupal that plugs into the Webform module and allows users to enter their postal code and return information about their local Member of Parliament (MP) in Canada. This module communicates with the API at howdtheyvote.ca to return all the necessary MP info, such as:

  • Name
  • Political Party
  • Riding
  • Email address
  • Telephone number

This service is most useful when implementing email action campaigns which give visitors to your website the ability to send petition emails to local MP's, based on their postal code. Maintaing an updated list of MP's associated with Postal Codes would be a nightmare for the client or us to manage. Using the howdtheyvote.ca API means that we have someone else looking after that for us :) It seemed logical to extend this service to allow anyone to retrieve their MP's information by simply texting their postal code to an arbitrary phone number. I downloaded the Tropo Web API made a few tweaks to our lookup module and everything worked perfectly. Here's a snippet of the code I used in the module:

if(validate_postal_code($session->getInitialText())) {
  $mplookup = get_mp_howdtheyvote($session->getInitialText(), "OBJECT");
  $result = theme('re_findmymp_sms_mp_details', $mplookup->member);
} else {
  $tropo->say("You did not send a valid postal code, please try again");
print $tropo;

I then signed up for an account at Tropo, got myself a phone number and started developing. Tropo has an awesome live debugger which was a great help throughout. If you want to test this out yourself, please text your postal code (Canada only) to 778 800 1731. Let me know if it works, or doesn't! I've got some more testing to do along with trying to integrate it with another service called Twilio. The preliminary results are awesome and I see lots and lots of potential for integrating these services with Drupal. Do you have any ideas how these services could be used with Drupal? If so please leave a comment.