Automatic Apartment Building Door Opener

Using Twilio to Replace Key Fob Entry

Tanner Jones
4 min readMar 2, 2017

Why Am I Even Doing this: Our Current Setup

Our apartment building has two ways of opening the main doors

  1. using a key fob or
  2. using the ‘phone entry system’.

The phone entry system works like this: Imagine there are two people:

  • Joel the Knocker who wants to enter the apartment building
  • Billy the Gate-keeper who lives at the apartment
  1. Joel the Knocker goes over to the phone entry system
  2. Joel searches the phone entry system directory for the person he wants to visit (Billy the Gate-keeper). When he finds Billy in the directory, he will see Billy’s 3–5 digit ‘code number’
  3. Joel enters the special code number into the phone entry system
  4. (Now for the reason they call it the phone entry system) Billy receives a phone call from the phone entry system.
  5. Billy answers the call and presses ‘9' on his phone
  6. When Billy presses ‘9', the apartment door unlocks and Joel can come in

So What’s Wrong?

Key fobs work great for people who use the building regularly (like residents), but are bad for irregular visitors (pizza delivery people, cleaning / laundry service people).

The phone entry system is good for irregular visitors, however, it requires the apartment resident (Billy) to be near their phone in order to answer the call to let them in.

In my case, I’m not always near my phone and even when I am I usually have it on silent so I frequently miss calls.

And, due to the high number of pizza, laundry, grocery drop-off visits I get, I wanted to make a solution that wouldn’t require me to have to manually answer each phone call.

Here is an easy solution that uses Twilio, even if you don’t know how to code.

How to Build an Automatic Apartment Door Opener

What you need:

  • A Twilio account
  • A Twilio phone number (cost $1 a month)

Twilio is a company that lets you buy phone numbers and use them in your coding projects. If you’ve ever received a text message update from Uber or a text message update about your package being delivered, or anything else that you know wasn’t probably sent by a human, you probably were contacted by a Twilio number.

For the project, we need a number that will do Billy’s two jobs automatically:

  • Answering the phone
  • Pressing the ‘9' button

Lets get started:

1. Create a Twilio account

Sign up here at Twilio.com

2. Buy a Twilio number

3. Go to the Twiml bin page and create a new Twiml Bin.

https://www.twilio.com/console/dev-tools/twiml-bins

4. Give the Twiml Bin a name (I chose the creative ‘Apartment Door Opener’), and copy this code into the TWIML Box.

<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Pause length="2"></Pause>
<Say>Doing facial recognition scan.</Say>
<Pause length="2"></Pause>
<Play digits="wwww9"></Play>
<Pause length="1"></Pause>
<Say>Visitor entry recorded. Please enter.</Say>
</Response>

You don’t need to understand the above code, but if you’re curious, here is what it is telling the Twilio phone number you just bought to do:

Line 1: The format and coding language of this code is XML

Line 2: Answer the phone.

Line 3: Wait 2 seconds before speaking.

Line 4: Say ‘Doing Facial Recognition Scan’ (I have high hopes that one day someone at my apartment will hear this and ask management how they can get facial recognition too)

Line 5: Wait another 2 seconds.

Line 6: wait for four half seconds (that’s what each ‘w’ means in the code) and then press ‘9’

Line 7: wait for 1 second

Line 8: Say ‘Visitor entry recorded, please enter’.

Line 9: End the phone call

Alright, back to the steps…

5. Go back to the phone number page of the phone you just purchased

This URL lists your phone numbers — click on yours https://www.twilio.com/console/phone-numbers/incoming

Step 6: Select the Twiml bin you just made as the ‘when a call comes in' option

Result

Here are some shaky-handed iPhone videos that show the before and after at our apartment

In the Future…

Two things:

1. This could be more awesome. We could add the ability to have our Twilio number ask for a ‘codeword’ from Joel the Knocker, and open the door If the code word is correct, or respond with a fail buzzer noise if the code word was wrong. If I wasn’t entirely swamped with work, I think I would set that up as a handful of AWS Lambda functions connected to API gateway functions. If I ever do this, you know that I’ve finally got my work life under control…and that my social life is probably in a sad place.

2. I’m going to try to put the following into practice this year: Every time I complete a small project that isn’t confidential, I’m going to release it (or a write up about it like this one) into the world. Follow me on Medium or Twitter if you’re interested!

--

--

Tanner Jones

Operations + Marketing @Charisma Hacking, Sporadic Content @ExplainGood