I recently got engaged. It was a happy occasion, full of surprise, champagne and a beautiful mountain backdrop. Being a technologist I couldn’t resist the chance to do a truly unique proposal.
When I first started dating my now fiance we went through the normal ritual of figuring out what we had in common. One of the first things we identified was a movie - Garden State, written, directed and starring Zach Braff.
In April 2013 Zach Braff launched a Kickstarter campaign for his upcoming movie Wish I Was Here. One of the rewards for the campaign was a 20 second audio clip. Thinking ahead I contributed to the campaign and in October I received the audio clip. Now I had to get to work.
The script I came up with was designed to be delivered as a phone call. Over the years I’ve experimented with Twilio - an amazing API based service for phone and sms messages. What I needed was for Twilio to call and play the mp3, creating the illusion of a real phone call from Zach Braff. I also needed a mechanism to trigger that call while I was remote with only my phone on me.
My plan was I would send a SMS message to Twilio which would then make the call and play the mp3. To do so I needed to build an endpoint that Twilio would callout to whenever it received a text message. As a Salesforce developer I naturally set about building this on Salesforce.
I got an endpoint configured and started to test how the process worked. The caller id and body of the message were passed as parameters. Using the caller id I was able to use to ignore any messages that didn’t come from my phone number. I used the body as a secondary trigger so that I didn’t accidentally set the process off. If all conditions are met then the details are passed to an asynchronous method and an empty response is passed back to Twilio.
The last step makes a callout to the Twilio API with the instructions of what to do. The instructions take the form of TwiML, a simple xml based language with tags like
<Pause>. This was made easy using the Twilio Helper Library for Salesforce. TwiML is great for building interactive voice solutions.
The day before the big day I programmed my Twilio number into my fiance's phone against a new contact Zach Braff and added a cheeky picture from Google Image Search. One of the cool things that Twilio can do is record the call so you can hear the result on the Youtube video below!