How CustomSongSender Uses Twilio to Send Silly Songs

This is a guest post by Derrek Wayne, winner of our Valentine’s Day developer contest, on how he used Twilio’s API to make Custom Song Sender.

Derrekwayne My godparents are awesome. Every year, on our birthdays, they call my sister and I and sing a lovely duet of Happy Birthday. After learning about Twilio, I mentioned it to my sister and we thought – why not let everyone send silly birthday songs?

So she and I dreamed up At that web page, you can send silly birthday and valentines songs to your friends and family. All you do is enter your phone number as well as the number of the person you’re sending the song to, and then paypal a few bucks to the songwriter/hacker (that’s me). The app then calls you, and you “customize” the song by recording the recipient’s name and your message. Then the recipient gets called and they receive the song. Silly fun!!

Now to the nuts and bolts stuff. This LAMP application is written in PHP and MySQL. It’s very basic. It’s basically three parts: front end, back end and Twilio integration.

UI/UX Front End

The front end shows the prospective customer that they could send happiness for a few bucks. If the marketing sufficiently validates their prejudices and mitigates their concerns (and they like the music :D), they plop down a few paypal bucks and enter their info. I’d like to point out here that I borrowed (blatantly copied) the design of (the absolutely amazing) Go there, bask in the awesomeness, then read the creator’s blog at, the dude is brilliant.  

MySQL PHP CronJobs Back End

The backend runs php scripts with cronjobs. These scripts followup with users to make sure they’ve created/received their gift – for instance – once a song is customized and sent, the backend calls the recipient to deliver the song. If they pick up and listen to it that’s great, but sometimes they don’t, right? So the system hangs up and does not leave a message (because that’s really really tricky due to the many different answering machine formats) and then follows up with an SMS message. See how easily this can be done with the twilio REST API.

Twilio with PHP

All the features I wanted to include in the app were easy to make with Twilio – TwiMIL is very well thought out, simple yet robust. One interesting code problem to solve on this project was how to let the user re-record their “customization” of the song (the message and recipient’s name) if they chose to do so. After spending some time reading the voicemail tutorial, I realized I could achieve this with PHP session variables, because Twilio works like requesting a web page in a browser. Neat.

The Music

Music music music! Music and mobile devices, oh I could talk about that all weekend with you (email me at about an upcoming startup weekend for my next Twilio app). Writing and recording the eight songs that this app delivers was a really fun challenge and a nice counterpart to the coding.

And now… sock puppets performing one of the silly valentines songs from!