Automatic Off-Air Phone Calls with Twilio

Get a call when you're off-the-air

For a long time, I’ve used and recommended the Pira CZ Silence Detector software for radio dead-air, off-air, and program fail monitoring. When everything else fails, this tool can be a massive life-saver! However, it’s always been a little tricky to trigger automatic phone calls. Thankfully, I’ve now got an easy solution!

Firstly… why would you want a phone call? Isn’t email and/or SMS sufficient in this day and age? It mostly is, except the notification sound of an SMS won’t necessarily wake you up in the middle of the night when you go off air. Phone calls are loud, obnoxious, and can bypass your do-not-disturb mode.

This script uses Twilio’s Programmable Voice service as an inexpensive way of triggering phone calls via an API. Twilio allows us to place a call to most countries in the world from only US$0.013. It’s pay-as-you-go, with a $10 free trial balance.

Obviously this requires a reliable internet connection (you can’t trigger an alarm if the internet connection has gone down). These days, most radio stations should already have decent redundancy in this area so I think it’s a reasonable dependancy for off-air monitoring.

We also still rely on the amazing Pira CZ software to do the silence detection.

You could also use this utility with other programs such as PathfinderPC, although you’ll need to change some of the steps in these instructions.

The software I’ve created to do this is a small EXE which can be triggered by Pira, and send a command to Twilio to place a call. That’s it. No bells and whistles. Just some basic config and an API call. The code is even on GitHub!

Download on GitHub

Setup Instructions

(Don’t worry, it’s easy!)

  1. Sign up for a Twilio account
    1. Fil out your details
    2. Put in your phone number to receive a verification SMS
    3. You will receive $10 free credit to help you get started
  2. ‘Buy’ a phone number in Twilio. This will become your outgoing phone number for alarms.
    1. In some countries, you need to verify you are located nearby to purchase a number.
    2. Phone numbers are very cheap ($2.50/month in Australia, so don’t worry about blowing your budget on telecomm services)
  3. Find your Twilio Account SID and Auth Token
    1. These are found on the Account Settings page in the console
    2. Take note of these two values – you’ll need them in Step 8
  4. Download and install Pira CZ Silence Detector
    1. Download the file off the website
    2. Install it on a Windows PC
    3. Setup an audio input to the computer
    4. Configure and test the basic functionality in the program (you may wish to trigger an email to yourself to test it)
  5. Download the latest version of the Twilio Caller app
  6. Extract the ZIP to a simple location on your local hard drive (e.g. C:\TwilioCaller\)
  7. Open ‘config.json‘ in a Text Editor (e.g. Wordpad) and fill in the values
    1. Insert the Account SID and Auth Token (found in Step 3)
    2. Insert your Outgoing Caller ID number (created in Step 2)
      This should be in the international format (e.g. +61288063416)
    3. Save your changes to the file
  8. Back in the Pira software, create an Open/Play Alarm Task and add it to the list of tasks
    1. Set “File 1” to the EXE path (e.g. C:\TwilioCaller\TwilioCaller.exe)
    2. Set “Parameters” to ‘–call=”+614111222″ –message=”Your radio station is of the air”
    3. You will need to substitute in your own phone number (international numbering format) and message to be read out by the robot voice
  9. Test the software by simulating some silence
    1. Either mute the input or drag the threshold slider all the way up to 0dB

At this point, you should either receive a phone call – or receive an error message. The black command line box which flashes up on the screen is normal. All errors and debug messages are logged to the file TwilioCaller.log, found in the same folder as TwilioCaller.exe.

If the log file doesn’t exist, it means either:

  • the program hasn’t started, or
  • your permissions in the folder are wrong

That’s it! Hopefully you are now receiving dead-air alarms directly to your phone.

Other options

  • Multiple destination phone numbers in the –call option can be separated by a comma. Every phone number will be triggered simultaneously.
  • You can also specify the option –from=”+61288063416″, allowing you to call out from multiple numbers based on the type of alarm. For instance, you may wish to have one number per radio station).

Have suggestions? Found a bug? Want to contribute?

The source code is free for all on Github. If you have a problem, log an issue. If you want to contribute, please feel free to do a Pull Request!

Get the Broadcast Technology Newsletter

Sign up for the email newsletter about media and technology. Sent irregularly. No spam.

I'm Anthony Eden, and I'm a broadcast technologist. I've been working in broadcast media since 2008 (getting my start in Community Radio while still at school), and developing software and websites for just as long. Right now, I work full time for Hope Media, and provide some freelance services through Media Realm.

Follow Anthony on Twitter: @anthony_eden or Google+