What the heck is a Dancing Bird Subscription Notifier?
Like many companies, Safari’s projects are given an internal secret codename that follow a pattern. In Google’s case that pattern is alphabetically ordered confectionary; in our case it’s bird names.
With Safari Flow, an all-new product, we re-architected many of our systems, and we decided to build the user database in Salesforce.com. I realized that we could have some fun whenever a new subscriber joined, alerting the team in the San Francisco office to the good news. So we (OK, I) built Chirpy as a side project, unknown to the rest of the team. Chirpy is a dancing mechanical “bird” who alerts us in a spectacular manner for each new subscription to Safari Flow.
The short version is that whenever a new subscription is created in Salesforce, that event triggers an email to an internal gmail account, which is then picked up by Chirpy. Chirpy – built out of a combination of an old wine box, some oak flooring scraps, a Lego Gearbox, a Raspberry Pi, powered speakers and a lot of cardboard, wire and hot glue – then plays a mating call and spins its spirograph (early Flow Beta testers may recognize these?), all while flapping its wings and flashing some LEDs (Flow colors, of course).
Here’s what happens when you make Chirpy happy:
For those of us in the office when it happens, this is truly motivational, so keep those subscriptions coming!
The longer version of how Chirpy came to be follows, along with links to the individual chapters and books I used to help me (from Safari Flow of course)
As a Product Manager working on Safari Flow, I came across a lot of books on the Raspberry Pi and was immediately hooked on the possibilities of Physical Computing. Plus, since Safari Flow is based on a Django/Python framework, and we rely heavily on GitHub for our collaborative development, I figured what better way to earn a deeper connection with our platform than to build my own stuff in Python with our own content guiding the way AND having a little fun for the launch at the same time…
Right off the bat, I wanted my Pi to be as compact as possible with the bare minimum amount of wires tying it down so I decided that Running Headless via SSH over Wi-Fi was the way I wanted to go. This allowed me to set up Netatalk and attach my Pi as NAS in order to write code in Eclipse (PyDev) on my full-sized/full speed Mac so I don’t have to sit near an ethernet jack—or worse, write code in front of my TV with USB-port hogging/power hungry peripherals and a slow(er) LXDE. Plus, I could drop it into this cool wooden box I had lying around AND SSH from my Android Phone to check my log file and start/stop Chirpy!
I also came across a few neat tricks like having my Pi email its IP address to me at startup so I can plug in anywhere and easily obtain my IP address and be able to ssh in to control my Pi. (Aside: I haven’t (yet) found a good way to connect to a new WiFi access point while headless due to the need to edit the .conf files and/or enter passwords although I would love to see one — I’m thinking a startup script, external LCD & Bluetooth keyboard to re-write wpa_supplicant.conf? Please add any tips to the comments below!)
As an added bonus, I greatly improved my Linux skills and command line tricks such as working with files, crontab and regex among others and my fluency with Version Control using GIT & GitHub to obtain, manage & share my code.
chirpy.py highlights (blevien/chirpy on Github committed from Raspberry Pi)
- Cron job runs Chirpy on every minute since startup
- Chirpy obtains “Last Subscription” date in log file
- Chirpy checks the Gmail Atom feed every minute for new subscriptions
- If a new email is found since last checked, cue stepper motor and LEDs for as long as the sound is playing
- Write new “Last Subscription” time to file, or skip if no new subscription is found
Server Triggers Setup
- Set up a Gmail rule to assign a label to incoming emails that you want to be notified about
- Parse the Gmail Inbox ATOM feed
- Note that the subject has to be unique or the atom feed always thinks they are part of a conversation and only shows you the newest in the thread, regardless of conversation settings in Gmail Inbox.
- Also note that atom feed only returns the newest 20 emails, so that limits the usefulness of using the number of new emails in the inbox as a counter
markReadMidnight.jsruns in a Google Spreadsheet at midnight to mark all “yesterday’s” emails as read
- Raspberry Pi
- Wi Fi Adapter
- ULN2803 – Darlington Driver
- 5v Unipolar Stepper Motor
- Assorted LED & Resistors
- Pi Cobbler (Optional, but helpful & Awesome beginner soldering project
- Solderless Breadboard
- Jumper Wires
- Lego Bevel Gears for wings & spiro (borrowed mine from my sons’ cement mixer)
- Powered speakers (extra points if you build this “Dirt Cheap Amp” instead)
- Amazon Prime box for the Bird parts
- Hot glue gun
- Wiring Up Breadboard & LEDs
- Playing Sound
- Darlington Driver & Stepper Motor (Adafruit Tutorial)
- More cool experiments with Stepper Motors, theory and control using only 555 Timers
I had been excited to learn about Raspberry Pi but didn’t know what I wanted to build -which is half the battle- until this project came along. In the sprit of dogfooding, I learned pretty much everything I needed from the content in Safari Flow, and I even used my experience to make a new topic set in the product called “DIY & Hardware“.
Start a free trial to Safari Flow to get started with some help from these books: