Andy Davies

Web Performance Consultant

Roll Your Own Traffic Alerts Using Twitter and Yahoo Pipes

In the early hours of Tuesday morning there was a three lorry smash on the M5 just north of Bristol resulting in diesel and olive oil being spilt all over the road and a closed motorway. A work colleague sent Nic (my wife) a text message to let her know but unfortunately it arrived just after she had got on the motorway and so the fifteen (ish) miles to work took three hours!

During her three hours stuck on the motorway we had a few calls and of course there were questions about why wasn’t there a way of letting people know about traffic problems so they could take alternate routes came up (either via signs before you get on the motorway or via text messages etc.)

A quick Google found a few sites that would send a text message when there were traffic problems but they wanted to charge a minimum of 50p a text!

So ever curious, I wondered how hard could it be to roll a free version of my own?

In the UK, the Highways Agency conveniently provides RSS feeds for traffic incidents - http://www.highways.gov.uk/traffic/11278.aspx - now all that I needed was a way to filter the feed and fire off a text message.

I’ve played with Yahoo Pipes in the past so it was my first port of call to filter the whole of the UK feed for just incidents affecting the M5. If you’re interested the pipe’s here: http://pipes.yahoo.com/andydavies/m5traffic (Tim later pointed out that I could skip this step and just use the M5 feed instead, but I might add a date and time to the message so I haven’t changed from Pipes yet).

So now the feed contains just the incidents affecting the M5, what ways are there of firing off a text message? A quick email to underscore about RSS to SMS conversion and back came the suggestion of using Twitter and it’s API (again, thanks to Tim).

After playing for a while with trying to drive Twitter’s API from Yahoo Pipes and deciding against it, I found twitter feed. twitter feed does what it says on the tin - takes a feed and uses it to update a twitter account

So create a new twitter account - imaginatively named UK_M5_Traffic - use twitter feed to link it to the Yahoo Pipe, set my main twitter account to follow it and send me a text message when it’s updated and there it is, a free automatic alert system for traffic incidents on the M5.

The first message through was a bit on the useless side as it just used the title from the item and the title doesn’t contain enough information about where the problem is, but switching twitter feed to use the description fixed that. As twitter can only display 140 characters, the end of the message gets cut off but there’s enough information for it to be useful.

If anyone wants to keep an eye on the M5, the final result is here: http://twitter.com/UK_M5_Traffic

Comments