I want to to tell you the story of our doorman; a diligent, kind hearted chap who is half Slack, half RaspberryPi.
We had a problem
Everyone on our team has a key to the building. However, only two keys actually worked. We had the two guys who arrived earliest keep the functioning keys and they would then press a button upstairs to open the gate for everyone else. To avoid the distraction of a loud bell, comers would call upon their indoor fellows via slack with a polite “door please”.
This worked for a while but eventually the negatives started to weight in: The messages were a distraction, they cluttered our slack channel, and worse, could go unnoticed leaving people stranded at the gate for a while.
We got an idea
How about we have those “door please” slack messages open the door without the need for a human agent? That would clear up our problem and would quite honestly be super cool!
We got to work
We implemented a slack bot, lovingly named Mohsen (محسن), who listens for variants of “door please”. Mohsen is basically two very simple servers: a server running a slack bot hosted on our local company cluster and a second server hosted on a RaspberryPi which in turn interfaces to the door opening mechanism (yeah a RaspberryPi is overkill but we had one lying around so why not). To ensure near 100% availability (despite Egypt’s sketchy internet connectivity), we used a MiFi router to connect to the internet via 3G (yeah 4G is yet to make it to this corner of the world).
The first server is a slack bot that we built using the official slack node client. What it does is listen to a slack channel for every message. If a message matches a certain regex “/door (plz|please|pls)/i”, it sends a request to the second server (residing on the RaspberryPi). The second server, written in python, turns a specific pin on for two seconds and then back off (serving as a control signal) whenever it receives a request from the server running the slack bot.
The Raspberry pi triggers a switching circuit that in turn triggers the door opening mechanism. We implemented this simple relay switching circuit. We then hacked the electric door lock to avail terminals to trigger the door opening circuit as needed (emulating a button press). We then housed the switching circuit into the door opening mechanism’s enclosure so that only the three wires for power, ground and control emerged to interface with the RaspberryPi.
Now whenever someone slacks “door please”, Mohsen opens the gate in a second! The whole thing took about six man hours of work and has since made our lives appreciably better.
This got us excited about automating more stuff. We made a list of the things that can be “delegated” to our friendly doorman. The list included ordering groceries, controlling lights and watering the plants. Seems the guy has his work cut out for him! If you have ideas for what we could get Mohsen to do next, we would love to hear them. Please drop us a comment.
We are a team of data scientists and software engineers working to help enterprises make the most out of their data. Our projects range from data analysis to extract insights, to predictive analytics to support decision making, to scalable production ready data products. Our focus areas are (1) personalization and (2) operational efficiency.