New Year + Payphones + Twilio

Sometimes I get bored, So I called all of the payphones in Luton simultaneously...

01 January 2014

It's the christmas holidays, which means that after 2-3 days of being surrounded by loved ones and all the niceties of being home... I get bored. So, naturally your brain starts ticking over. I've always liked doing hacks that involved using things in a way you wouldn't expect, A little while ago I used a SNES controller to post to Facebook, and one day I woke up with the mad idea of calling payphones - specifically, I thought it might be nice to try and wish random townsfolk a Happy New Year.

So how do you go about this?

Well, If you're going to call phones you need phone numbers! Easy, Quick Google should have a massive list of these things somewhere. Actually, No. Despite the numbers for each telephone being displayed in the box (they aren't always easy to find, mind you) there doesn't seem to be a resource for payphones by town (I guess that would be to stop this kind of playful mischief). So, nice idea - but there's no data, Time to give up. NO. I've come across these kinds of problems before - There's tons of data in the world, it's just not always correlated yet.

Last year, the Tallest Man in Dorset, Aswad and I briefly worked on a little project together that involved mapping out bus stops. We sat on the M1 and M2 buses in Bournemouth and used a quick little web app I wrote to record the current GPS coordinates of the bus so we could map out the various stops. We didn't do anything with it in the end, but I do have the GPS mapping web app in a private Github repo. I dug it out, added a "phonenumber" field and headed into town.

I used the app to map out the GPS coordinates and telephone number for every public payphone in the Luton town center. I did worry if I was breaking some sort of archaic law but meh, If you're not willing to get into a little trouble now and then, you'll probably never do anything interesting.

Ho Ho Ho, Now I have payphone numbers

Great! Now, how do we call them... and what do I even want to say? Well, I've known about this cool company, Twilio, for about a year and a half now. The first time I tried to write something with it I was using PHP at a Facebook hack day and my experience wasn't great (With PHP that is, The Twilio docs are really rather good) so I wasn't too sure about what I'd be able to do.

Boy, was I wrong to be apprehensive. With Twilio's Node.js helper library, making phone calls is so simple. I had my Node server making phone calls within 10 minutes. Sorted. All I had to do now was connect to an SQL database (My old GPS web app thingy connected to MYSQL and I couldn't be bothered to rewrite it for MongoDB), iterate through the numbers and place the calls. You can do that like so...

for(var x = 0; x < data.length; x += 1){

		to: data[x].phonenumber,
		from: "+44[MY TWILIO PHONE NUMBER]",
		timeout: 30
	}, function(err, call) {


Twilio doesn't call phones as soon as they are dialled, It queues them and works through the list at a rate of one per second, So the more phones I ring the bigger the time difference is between the first and last phone ringing. I had about 40 phones going in the town center so that means there's potentially a 40 seconds gap between the first and last phone but it doesn't matter too much, each phone will ring for 15 minutes until it's either picked up or it disconnects, so it's pretty likely they'll all be going for quite a little while.

With all of that out of the way, I needed a way to trigger the phones at my whim. Hey! I've used Node.js, let's just call it with an endpoint - So I call the function inside route /make-the-calls and bam, The phones start ringing.


So, What did I say to people?

Well, Those of you who have either worked or drank with me will probably have learned that I play Bagpipes (How well I shall leave to your judgement) so naturally I shouted "HAPPY NEW YEAR!!!" and then had Auld Lang Syne belt out of the phones Bagpipe style.

Did anybody answer?

Oh Yeah, They answered alright. In the days leading up to New Years Eve, I would trigger the phones every now and then to test everything was working. It's quite satisying walking through a town watching people try to work out what the hell is going on.

Here's a grab of my Twilio dashboard stats.

An image displaying the number of calls I made An image displaying the number of miuntes people listened to the call An image displaying the duration of the calls I placed

Amazingly, 321 people answered the phone - 27 of those were immediately after midnight, the rest in the day preceeding and following NYE. Some crazy folk seem to have actually held the line until the Bagpipes finished.

How much did this cost me?

Phone calls do cost money and so Twilio does charge for their service per call or text. Don't let that deter you, Their rates are insanely cheap; I'll be using them again. But, How much did I spend? Well, Nothing. Twilio's Developer Evangelist Syd Lawrence popped into our offices a little while ago and very kindly gave me a voucher code worth about £10 (Thanks Syd). I've used most of that up, but I've made 300 phone calls that have made up 421 minutes of talk time. That's bang for your buck.

What next?

Well, I've had my fun with payphones for now, But I'm going to keep tagging the locations and collecting the phone numbers, Everyone needs a hobby, right? When the dataset get's to a useful size, I'll release it - I did find a list of certain payphones (the famous red telephone boxes) across the UK, I'll manually input them when I get a chance. I've put the code I used on Github, It's really crude... took about an hour to put together so I don't expect people to be dazzled by it, but hey! It was a ton of fun.