Doers In Action: Easy Voice Reminder with Heroku and Twilio. Kitty Approved.

We love seeing Doers in action and this API mash is a perfect example of an instant need  solved by the use of accessible APIs. Tryn Mirell needed a simple voice reminder system to make sure her kitty’s litter box was fresh and clean, so she built an app using Heroku and Twilio Voice.

The content below was originally posted on https://mirell.org/posts/heroku_and_twilio.html

Heroku and Twilio

I don’t clean out my cat litter box often enough. It’s true. While the cats miao at me about it, they also miao about … well, anything.

So I decided to learn a bit about Heroku and Twilio.

Heroku is a service, that at least initially, allowed you to run various Ruby web applications, anything that was Rack compatible. (They have since expanded to many other software stacks, that I haven’t explored yet). It’s based on a git deployment, you create a git repo, use the Heroku client to create an application, and push your code.

Twilio basically uses a REST API to interact with phone calls. So when you get a phone call, it sends a POST request with various information. It also sends a POST when you make a phone call, so you can control the conversation as well.

The API basically consists of two parts, one which allows you to initiate actions, and the other a custom XML format that is used for phone calls.

So in order to call me, I needed two parts, something that used the Twilio API to actually call me, then a service that would respond to the POST to say something during the conversation.

twilio-heroku.git is the results of that effort, slightly sanitized.

The last piece is the Rakefile that was actually used to initiate the calls:
require ‘ripl’
require ‘twilio-ruby’

account_sid = ‘BLAH’
auth_token = ‘BLAH’
@client = Twilio::REST::Client.new account_sid, auth_token
@account = @client.account

@call = @account.calls.create({
:from => ‘+15124100439′,
:to => ‘+15127963592′,
:url => ‘http://morning-waterfall-2958.herokuapp.com/’
})

Then this was added as a Rakefile task, and the Heroku scheduler was set up to run that task every day.

Now, I get a lady calling me lovely every day. And that is good. Despite the fact she’s a robot.

Tryn Mirell is a software engineer based in Austin, TX. Read her blog at www.mirell.org and follow her on Twitter @mirell