Ben Dodson

Freelance iOS, Apple Watch, and Apple TV Developer

How's the London Underground? Ask Siri!

After seeing SiriProxy in action on YouTube, I was keen to grab an iPhone 4S to have a play with it. I managed to pick one up at the Apple Store yesterday and today I'm pleased to release my first SiriProxy plugin; TubeUpdates. It's a basic plugin that lets you ask Siri for the status of a London Underground line thanks to my TubeUpdates API.

SiriProxy-TubeUpdates - A standard request

I've not dabbled with Ruby for a while but building the plugin was fairly straightforward. All of the code is available on GitHub but the main piece looks like this:

listen_for /[what is,what's] the status of (.*)/i do |line|
	encodedline = line.gsub(' ', '+')
	url = URI.parse(''+encodedline)
	json = Net::HTTP::get url
	result = JSON.parse json
	say result["status"]
	if result["messages"].count > 0
	    response = ask "There are additional details. Would you like to hear them?"
	    if(response =~ /yes/i) #process their response            
	        result["messages"].each { | message |
	            say message

The matching in the first line ensures that you can ask either "what is (or what's) the status of (the line name)". This is then url encoded and "the line name" is sent to a Siri endpoint I created on the Tube Updates site. The site will return a JSON string of the tube line status which is then parsed and spoken back to the user. E.g. "The Circle line is running a good service".

If there are any messages for the line (these are generally details of delays), then an additional step is performed; the user is asked if they would like to hear the details and answering "yes" will list them.

SiriProxy-TubeUpdates - A delayed line

And that's pretty much it! I've got a few ideas for more complex plugins that can interface directly with iPhone apps so I'll have a play with those when I get a spare moment. If you've got any comments or feature requests for this plugin, then get in touch.

As an aside, this is the first project I've published that is written in Ruby and the first time I've put anything up on GitHub.

How not to ask for an iOS app review - A review of Jumpship Thrust Control 2 » « Goodbye Gowalla