How I Built a Multi-User Door Buzzer for Our Apartment

Full disclosure: a lot of people have talked about this idea, this is just my implementation of it for our apartment.  You can check out if you want someone else to administer yours or post to Elance/oDesk/HackerNews/Twitter to get someone to build it for you.  Look for something cool from @gregkoberger with all those features I left out (user management, UI, adding new roomies, adding more numbers etc.)

Making a Present for My Roommates

About a month ago, I moved to a 3-story loft in SOMA with my husband Kevin and our good friends Park and Kat.  My sister also graduated college and joined a local startup, so she’ll be moving in with us next week.  With 5 people living here and only 2 master keys to the front door, we had a bit of an access problem right away.  My roommates, knowing I haven’t had a chance to code since the move started, were nice enough to suggest a build an app with my Twilio skills (full disclosure: I work there) and we tested it out last night – it works, so I’d love to share.

How A Call Box Works

If you’ve lived in an apartment with a call box for buzzing people into your apartment before, this will sound pretty familiar.  There is a list of names and corresponding codes listed on the callbox display, you dial the number and it rings the person who lives there, they press a key and the door is unlocked.

What happens inside the callbox is a little more interesting – because the sound the keypress makes, which is called a DTMF tone, is actually a pretty amazing little thing.  Tone dialing was arguably one of the earliest massive implementations of human-to-computer communication.

Phreaking Out the Phone with DTMF Tones

There is a long history of phreaking (the image to the right is of a bluebox built by Steve Jobs and Steve Wozniak, on display at the Computer History Museum) by playing DTMF tones and other tones (pulses, pins, etc), and the things telecommunications hackers achieved without any kind of API like Twilio is pretty amazing.  In my case, the call box just requires the person who receives the call to press 6 to open the door, and responds when the 6 DTMF tone is played.  This tone doesn’t have to come from pressing a key though,  I can just play the audio file into the phone to mimic the action of a keypress – and the doors opens!

The simplest implementation of this is just to have the door automatically open when anyone dials your extension.  I don’t recommend setting your callbox up this way, because you might accidentally let in people who are messing with the box looking for a way in so they can do bad things.  My street has a lot of bums and other riff-raff on it, so I wanted something with a couple different types of security.  So here’s what I did.

Setting Up My Call Box with Twilio

If you haven’t heard of my company, Twilio, before the really quick elevator pitch is that we are the AWS of telecommunications, making it easy to send/receive calls and text messages programmatically and only paying for what you use.  It’s pretty sweet, its a startup, and I’d love your feedback on it.  So here we go:

  • Get a local Twilio number (or you can use the sandbox number for free)
  • Tell your building administrator to add your name/number to the box
  • Build a simple app that forwards the call to your cell phone so you can make sure the box can recognize DTMF tones passed from a forwarded call

Doing this test before you build your full blown app is really important, it will save you from debugging an issue outside of your control.  You just need to create this little callbox.xml file, save it somewhere on the web (publicly accessible on Dropbox is a handy option, our try Twimlets)

callbox.xml (replace 415-555-1212 with an actual phone number)

  1. <Response>
  2. <Dial>415-555-1212</Dial>

  3. </Response>

If you are using your Twilio trial account, make sure you use the Twilio sandbox number and remember your pin code for testing (or email me at and I can manually remove this restriction from your account). If you run into problems just email for 24/7 support, or tweet @twilio

Building the Full App

Now that your testing is done, it’s time to build the full app with just a little PHP.  This took me about 25 minutes to write from scratch in Emacs, probably will take you a whole lot less with all the sample code.  Here’s the spec for how the app should work:

Need to have:

  • visitor or roommate dials our extension in the call box and our Twilio number is called
  • menu is read to visitors, giving them the option of which roommate to contact
  • roommates have a secret code they can punch in to bypass the menu and open the door
  • if the visitor selects one of the roommates from the menu options, that roommate gets a call and presses a number on their cellphone dialpad to buzz in

Nice to have:

  • menu selections can be made at anytime, without waiting for the menu to finish, because that is just annoying
  • roommates can be simultaneously dialed on multiple numbers (cellphone, work, house phone) if they want
  • fun audio files can be played when someone is let in

callbox.php – this file controls what happens when the callbox is dialed


  1. <?php
  2. header(“content-type: text/xml”);
  3. echo “<?xml version=\”1.0\” encoding=\”UTF-8\”?>\n;
  4. ?>
  5. <Response>
  6. <Gather action=”/doorbell_gather.php” method=”POST”>
  7. <Say voice=”woman”>If you are here for Katrina, press 2.</Say>
  8. <Say voice=”woman”>For Danielle, press 3.</Say>
  9. <Say voice=”woman”>For Park, press 4.</Say>
  10. <Say voice=”woman”>For Kevin, press 5.</Say>
  11. </Gather>
  12. </Response>

Two important things to point out here. First, notice that the menu options in the tag are nested within . This is awesome, because it means Twilio is listening for a keypress the entire time and you can interrupt the menu with your selection at anytime. Also, you’ll see if you check out the Twilio example code that usually includes the numDigits parameter, but we’re excluding it on purpose here because we want to accept secret pin codes in addition to single digit selections. You’ll see why in a moment.

doorbell_gather.php – this file determines what to do with the keypad data we just received

Note on this code: There are definitely more elegant ways to write this, but in my mission to convert all my roommates to geeks I’ve opted for something they can easily understand in case they want to change their secret codes without my help.  All pincodes have been changed for this example.


  1. <?php
  2. if($_REQUEST[‘Digits’] == ‘2’) {
  3. header(“Location: katrina.xml”);
  4. }
  5. if($_REQUEST[‘Digits’] == ‘3’) {
  6. header(“Location: danielle.xml”);
  7. }
  8. if($_REQUEST[‘Digits’] == ‘4’) {
  9. header(“Location: park.xml”);
  10. }
  11. if($_REQUEST[‘Digits’] == ‘5’) {
  12. header(“Location: kevin.xml”);
  13. }
  14. if($_REQUEST[‘Digits’] == ‘1234’) {
  15. header(“Location: secret-danielle.xml”);
  16. }
  17. if($_REQUEST[‘Digits’] == ‘6677’) {
  18. header(“Location: secret-park.xml”);
  19. }
  20. if($_REQUEST[‘Digits’] == ‘9988’) {
  21. header(“Location: secret-kevin.xml”);
  22. }
  23. if($_REQUEST[‘Digits’] == ‘6786’) {
  24. header(“Location: secret-katrina.xml”);
  25. }
  26. header(“content-type: text/xml”);
  27. echo “<?xml version=\”1.0\” encoding=\”UTF-8\”?>\n;
  28. ?>
  29. <Response>
  30. <Say>I’m sorry, but the person you attempted to reach is unavailable.  Please try again later.</Say>
  31. </Response>

So Twilio is passing the keypress data as ‘Digits’ and we’re telling Twilio where to go depending on what was pressed. Pretty simple. The little bit of TwiML at the bottom only plays if the roommate called doesn’t answer their phone.

So now we need to create:

  • roommate.xml – which calls the selected roommate so they can buzz in their guest
  • secret-roommate.xml – which automatically opens the door when the code is entered

You might be wondering why everyone has their own secret-roommate.xml file, when they all do the same thing.  I decided it would be fun to prank my roommates with a funny theme song or movie quote before the door would unlock…

To complete this code, you’ll need to get an audio file (.wav or .mp3) of the DTMF tone you want to play back to the machine.  I used this awesome DTMF generator, and they host the audio file for you.

roommate.xml – the file that calls the selected roommate

  1. <Response>
  2. <Say>Connecting you to [Roommate’s Name] now</Say>
  3. <Dial>415-555-1212</Dial>
  4. </Response>

secret-roommate.xml – the file that opens the door is the roommate enters the correct pin code. The first <Play> contains a fun audio clip from Back to the Future, the second one plays the DTMF tone that will open the door (make sure to change this depending on which tone will open your specific door).

  1. <Response>
  2. <Play></Play>
  3. <Play></Play>
  4. </Response>

So there you go, now you can manage a callbox for a bunch of roommates, add secret pin codes, and even give selective access to delivery people, cleaning staff, or whoever else is coming by to visit. Let me know if you find any bugs or have ideas for how to make this cooler in the comments.

Photo credits:

  • Call box:
  • Touch Tone Telephones, 1966:
  • Bluebox:

Related posts

  • Pingback: Tweets that mention How I Built a Multi-User Door Buzzer for Our Apartment | Danielle Morrill --

  • Pingback: How I Built an Apartment Buzzer for Multiple Roommates » News, Hacker, View, Comments » App Developer Tyler Johnson Blog -

  • Danielle,

    Great article. I assume that the phone to door interface was existing? If you did build that, can you expand your tutorial to include that part?



  • Nick Reed

    ala Buzzer-o-matic!

  • I love it! Now I want to move to an apartment just to try it out.

  • That is pretty seriously incredible. I wish I had an apartment or lived in a housing complex so I could actually use it.

  • Hey Jordan – yes the door to phone thing was the callbox already outside that is usually configured to just call a landline inside the apartment.

    Hey Nick – Seattle represent!

    If anyone implements this I’d really love to hear about the reactions from your roomies

  • Maverick

    Is your next post “How to build an asterisk system from scratch, buy a switch, some did’s, contract with a telco, and eliminate the need for a telephony api like twilio?”

  • If I knew the answer to that, I’d be building a better Twilio. In the meantime, our Asterisk geeks are hard at work

  • Utah_Dave

    Can’t Twilio generate dtmf tones? Seems like a common enough pbx function to include in their API

    This is a really cool app! I did something similar at work using our existing asterisk server. I play audio over our paging system as well if people don’t answer their phones.

  • Nice usage!

    At my place, I have a group (“Gate”) set up in Google Voice which forwards the number to my cell phone and if I can’t access my phone, then the custom voicemail that caller hears is the DTMF key (“9” in my case) sound and so if I am not able to get the phone, it will automatically buzz them in.

  • Huh… how funny. I just wrote an script that does exactly this last week. I’m using Twilio as well– coincidence? Ha!

  • Nice article. I like to read it. Thanks for sharing

  • Hopefully someone can successfully productize this, it isn’t a technological breakthrough but the right marketing could make it into something of a geek fad. Whether it is a product, or just a feature of some broader home automation tool, or even just a clever marketing gadget for some home owners association… I don’t know. Googling around, it looks like hacking the callbox has been popular even longer than I thought (and much longer than Twilio has been around).

    RE: “can’t Twilio send DTMF tones” — Yes it can on if you want it to automatically play the tone upon answer, but in my case this didn’t make sense for how I was using it.

  • Pingback: How I Built a Multi-User Door Buzzer For our Apartment | Danielle …()

  • Mike

    As a long time customer and advocate of Twilio, I am beside myself that you, an employee of Twilio, have the audacity to write this post.

    • Hi Mike, I’m sorry that you find my writing this post offensive – I absolutely appreciate that you are a long time customer and supporter of Twilio and I’d really like your feedback on why you think writing this post is such a bad thing?

  • Pingback: Hot Dog Files()

  • Pingback: Hot Dog Files()

  • Danielle!

    Me and some room mates are moving into a place next month! We are going to use this for sure!

    Question. If for some reason the place I have my files (all the XML) goes down … does Twilio have like a fail over URL it can go to?

  • Yes, there is a fallback URL you can set in settings — I’d suggest Dropbox as a good backup

  • Pingback: How to Automatically Buzz Guests In | Ben Deaton()

  • Pingback: How to automatically buzz guests in your neighborhood or apartment |

  • Musuoka

    Ray Ban Sunglass
    Ray Ban Outlet
    [URL=]Ray Ban Sunglass[/URL]
    [URL=]Ray Ban Outlet[/URL]

  • Kate

    Not what I had hoped to find – I have a non-call box, but well done. We have a direct buzzer system that seems to have tiny mice carrying signal back and forth. Love the roommate code. Answer me these questions three….

  • You have such brilliant idea in thinking of a way on how to have access with permission by using the call box equipment. And I agree with you that it would not be enough security measures in one apartment because there are dubious people always on the look out. So much better to install modern widgets giving outmost privacy and security for your comfort. 

  • Good to know this piece of information about call box, but then still annoying to display, better to used some electronic gadgets. 

  • Passing by…

    Completely unrelated, but, I must say it….Danielle you are very beautiful, I am so sad that you are already spoken for… 🙁
     If you find yourself un-married, just send smoke signals and I will come find you. 😉

    Awesome article by the way…. Keep it up

    • Hrrm.


  • Pingback: How to automatically buzz guests in your neighborhood or apartment | J Ben Deaton()

  • I think I need this buzzer for my apartment. Most of the time, I can’t hear the knock on the door specially when I’m on the bedroom. Thanks for this information!

  • Pingback: annihilable becrimson basidial()

  • Pingback: beryllia cabellerote antihylist()

  • Pingback: How to automatically buzz guests in your neighborhood or apartment | Only A Model()