Interactive Voice Response (IVR) systems are everywhere – when you call the bank, when you use the hotel room telephone, even when you call the Queen! Okay – that last one probably doesn’t happen very often, but I bet the Windsors have an IVR for routing to the appropriate member of royalty. If you’re still a little bit unsure what an IVR is – you have probably used one when you’ve called a number and heard something similar to this:

“To talk to a human, press 1. To talk to an Owl, press 2.”

This type of service is called an Interactive Voice Response. It provides a solution that would otherwise leave the telephony services of companies and large call centers in complete and utter chaos. By routing people through to the correct humans, IVRs help speed up the process of getting things done. Even if you’re routing between two separate people, or a thousand call center agents, IVRs are an invaluable part of telephony systems.

What You’ll Learn

With Twilio building an IVR system is as simple as writing software that listens to the digits a caller types into their phone. In this blog post we will create a simple IVR with Django, a popular MVC framework built in Python. We will learn to:

Set up the django-twilio library in our Django project

Link up a Twilio phone number a Django view

Prompt users to enter some digits into their handset

Programmatically discover and handle the response based on the input

To get started you will need:

A free Twilio trial account. Sign up here to get started, it takes one minute.

An existing Django 1.6 project. If you’ve never used Django before, check out the tutorial on their website. If you would rather read through an example, check out a demo project here.

To learn more about the high-level advantages of building an IVR on Twilio, check out our IVR page.

The django-twilio library

A fantastic Twilio community member, Randall Degges, built the django-twilio library to work seamlessly in Django projects. It’s a pretty cool tool and we’ll be using it today.

Installation

We’re going to need to start a new Django project for this, so once you have installed Django 1.6 with pip like so: