Following Up

From: Evan Verworn

Years ago I wrote about all my problems about voicemail. What I didn't write about then, was my solution that I made in the following month. This seems to have become a much more popular service that is available since the time I originally wrote that post. And in turn, has encouraged me to write how I solved my problem with voicemail and maybe you can too.

How We're Going to Solve This

  1. Person calls our phone number and we don't pick up. Call gets forwarded to a number that we choose.
  2. We send our custom greeting.
  3. We listen for what they have to say
    1. (Bonus) We take the voice recording and run voice-to-text over it.
  4. We text our cell number with the transcript and attach the recording.

Determining Compatibility

For this to work you need to change the phone number in your phone that the voicemails get sent to. Normally this is the provider default that gives you the "This person is not available at the moment." For me this was available in my phone app settings under "Voicemail". This might not be available for you to change, in which case you'll have to make a call to your phone provider to change this on their end, or hope that the gsm codes work for you.

Pick your Provider

I decided to go with Twilio as my phone provider of choice, for 2 main reasons.

  1. At the time, it was the cheapest provider.
  2. It has a voice to text feature.

If I were to implement this again, I would even opt for their WhatsApp service as it's cheaper. But for the rest of this post I'm going to be assuming that you're using Twilio.

Let's Buy a Phone Number

So in Twilio, you pick your region and can search for any number that is available. You'll want to pick something local to you, so that you don't incur extra charges for the people calling you.

Once we have our number, we can set up webhooks that run when people call or text it.

Twilio Interface Pretty self explainitory. When a call comes in, Twilio will send a GET request to that URL.

The format of the Twilio request is documented well, but in a nut shell we need to return what Twilio should do with this phone call. In this case, play an mp3.

<?xml version="1.0" encoding="UTF-8"?>
<Record timeout="5" action="/twilio/end" transcribeCallback="/twilio/transcribed" />
<Say voice="woman">Please hang up and try again</Say>
<Hangup />

Breaking this down, Twilio will execute these tasks in order when it recieves a call.

So what happens at those two endpoints? Well the required action one is actually trivial, it just returns some XML saying to hangup.

<?xml version="1.0" encoding="UTF-8"?>
<Hangup /><!-- yup that it -->

The more interesting endpoint is the transcribeCallback. When that's called the request will have the transcription in the body, but also have a link to the recorded mp3.

The below is some of the old code that I use. You can tell because I used vars.'/transcribed', function(req, res) {
var transciption = "<transcription failed>";
// We can't just use the twilio media url because they
// don't use the correct response headers for .mp3 so
// we have to proxy it.
var fullRecording = req.body['RecordingUrl'] + ".mp3";
var partial = fullRecording.match(/api\.twilio\.com\/(.+)$/)[1];
var fromNumber = req.body['From'].match(/^(?:\+?1)(.+)$/)[1]
if(req.body["TranscriptionStatus"] == "completed") {
transciption = req.body["TranscriptionText"];
var client = require('twilio')(keys['ACCOUNT-SID'], keys['AUTH-KEY']);
// send a MMS with an attached .mp3
to: "+12895551234", // your voicemail number
body: "(" + fromNumber + ") " + transciption,
mediaUrl: '' + partial,
}, function(err, message) {
console.log("SMS Sent.");

I think overall pretty straight forward. The only weird part is that we proxy their full mp3 link through our own service, and that's only because they send back a Content-Type: application/octet-stream response header, which their API doesn't like receiving. So I just proxy the request returning Content-Type: audio/mpeg and everything works out.

And really that's it. Now when you call your number, you should hear your greeting, and after leaving a message, be sent a text message with an attached MP3!

First off, if you're following along, Congratulations! You just implemented a service in under 100 lines that knocks the socks off any default phone provider voicemail. Pat yourself on the back.

How Much Did This Cost Me

Surprisingly, not much. Assuming you're using or to host your webhooks (which you totally can do). The only thing you have to pay for is Twilio. You'll pay $1/month for the phone number, and 2¢ for sending a text message with a media attachment, and a ¼¢/minute for recording your message and 5¢/minute for the text transcription.

For me, I receive about 10 voicemails a month, at most. So that comes to $1.775/month.

I've had this for about 4 years as of the time of this writing, and I do not regret it at all. This has made receiving phone calls more enjoyable, as now I don't feel obligated to pick up or else have that unclearable voicemail notification. I know that I can silence the call, and after 10 seconds have a text message arrive with a transcript of what was said.

This is a great weekend project that personally I found extremely fulfilling. Now, go forth and kill traditional voicemail!