Andy Davies

Ideas for Improving My Twitter Traffic Bot

The bot I built for keeping me up-to-date with traffic conditions on the M5 has proved handy a few times but it also suffers from a couple of drawbacks…

It only covers the M5, and the whole of the M5 at that, if someone wants updates on the M4, or just part of the M5 there’s no way for them to choose the information that’s relevant to them.

TwitterFeed also introduces a time delay and even on it’s most frequent setting it will only check a feed every 30 minutes - as we found out on Friday morning when we ran into a jam just north of the M4/M5 interchange only to hear our phones get the text message telling us there was a hold up!

So I’ve been thinking about building a new bot that would allow someone to choose the roads (and parts of) they want to receive updates for.

The bot would allow people to send it messages about the roads they’re interested in, grab the traffic feed from the Highways Agency (and perhaps other feeds) on a regular basis, and when there’s something to tell people message them via twitter.

I’m thinking of something that’s quite similar to mytrade’s twitter bot in concept but needs to be more frequent in it’s updates. The language used to communicate with the bot also needs to allow richer concepts as in stock watching terms it needs to support not just broadcasting prices, but broadcasting when a price crosses a user set threshold.

The things I’m looking at right now are:

The syntax for communicating with the bot - something similar to the syntax of mytrade’s bot might be good enough but I need to have a hunt around to see what alternatives are about. (I’m not sure I like twitter’s format for direct messaging and wonder whether !username might be fit better with the @username format used elsewhere on twitter, but there’s not a lot I can do about that!)

Whether to use the REST API or Jabber / XMPP for communicating with twitter. The API pages suggest using Jabber / XMPP for bots that use direct messages so perhaps I’ll follow their advice to begin with.

So time to brush off my coding skills and as I (hopefully) make some progress I’ll add some updates here.

Comments