Holiday Happiness is Just a Phone Call Away

12.10.2014 - No Comments

happy-medium-holiday-2014.jpg

It’s that time in between Thanksgiving and Christmas. You’re trying to finish up some projects before the end of the year, but all you can think about is getting your holiday shopping done and finalizing winter travel plans.

How can you be expected to slow down and enjoy the moment?

No worries –- that’s what the new Happy Medium Holiday Hotline is for:

515-532-5531

Call the number above to connect to our hotline and hear a handful of goodies (including a carol sung by Happy Medium team members)!

Inspiration

Back in 2011, someone created a Hall and Oates Hotline, which gathered some attention. All you did was call a number, select a Hall and Oates song, and it was played back to you.

And just a few weeks ago, the Des Moines Web Geeks had a mini Twilio hackathon where we built a variety of apps, from a text-to-GIF service to a text version of a magic eight ball.

Seeing how easy it was to tap into the text and voice features of the Twilio API made me want to experiment on an internal tool that was both easy to develop and fun to use.

Fun, light-hearted, and simple –- that was the inspiration for the Happy Medium Holiday Hotline.

Creating the Holiday Hotline

Our hotline was built using an implementation of the Twilio API.

If you’re not familiar with Twilio, it’s a web service built to help developers interact easily with phones via text messages and calls. If you’ve ever had a website text you a confirmation code, you know what I’m talking about.

We’ve open sourced the code, so you can follow along if you’re interested in building a hotline of your own.

Step 1: Planning

I started with a basic structure for the hotline. First, we would present callers with a traditional menu, because who isn’t familiar with those endless, automated customer service menus? We’d use the  TwiML verb to collect the caller’s option, and then process that input.

Twilio accepts a parameter for a callback URL, so we can send callers to a different URL after they answer a question. Once Twilio loads the new URL, we can print out a  TwiML verb to respond the user’s request (or to ask another question).

Step 2: Singing Carols

Twilio has a handy  TwiML verb, which lets you play audio files over the phone to a caller. I convinced the Happy Medium team to sing along as I fumbled along at the piano to a rousing rendition of “Let It Snow,” all while recording the session on a couple USB condenser mics.

I edited the audio session and exported it as an MP3 to use in the hotline application.

Step 3: Implementation

To implement the hotline, we stuck with a tried and true scripting language: PHP.

We encapsulated the functionality of the hotline into a single PHP class for organizational purposes. For the Twilio callbacks, we used $_GET parameters to pass back different “states” of the application without having to build out different endpoints. This method worked great for an application of this size.

We used PHP Composer to install a handy PHP Twilio helper library, and we used Grunt rsync to deploy the static files to our web server.

Takeaways

Does the Happy Medium Holiday Hotline serve any real purpose? Maybe not. Was it fun to make and will it make people smile? I hope so.

But the real takeaway while creating the hotline was that it’s really simple to make an automated phone system using the Twilio API. This would come in handy if a client’s website application needed to interact with users over phone calls or text messages.

Although we’re using our phones less and less for actual calling, being able to interact with users over traditional forms of communication, like phone calls, is a useful tool.

Have you used the Twilio API for any projects? What’s the craziest thing you might build?

Sign up here for our weekly newsletter, It's a Snappy Readium