Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Home Automation with Amazon Echo and Ruby

Home Automation with Amazon Echo and Ruby

My talk from Gotham Ruby Conference 2015! Thanks for coming :)

Avatar for Zach Feldman

Zach Feldman

June 20, 2015

Other Decks in Programming

Transcript

  1. Home Automation with Amazon Echo and Ruby Creating an API

    where there wasn't one to ameliorate first world problems @zachfeldman (c) 2015 @zachfeldman
  2. $ whoami @zachfeldman Co-Founder/Chief Academic Officer New York Code +

    Design Academy nycda.com Classes on web development from basic to advanced, iOS development, and UI/UX design. (c) 2015 @zachfeldman
  3. Built-in functionality "Alexa, set an alarm for 45 seconds from

    now." "Alexa, where is the international space station?" "Alexa, play Sober by Childish Gambino." "Alexa, what's the forecast for tomorrow?" (c) 2015 @zachfeldman
  4. Desired Functionality "Alexa, add an event Breakfast at Tiffany's at

    5:30 stop." "Alexa, tell the world Gotham Ruby Conference rocks stop." "Alexa, tell the world Jesse Chan Norris is the man stop." (c) 2015 @zachfeldman
  5. The alexaho.me project Scraper Scrapes commands from Amazon Echo web

    app. Server Receives scraped commands, parses them. (c) 2015 @zachfeldman
  6. Scraper ☞ Uses watir-webdriver to login to Amazon Echo web

    app ☞ When a new command is posted, sends command to alexaho.me Server application (c) 2015 @zachfeldman
  7. What's in a Watir? "Watir (pronounced Water: I know it’s

    confusing) stands for Web Application Testing in Ruby, and the WebDriver part stands for, um, WebDriver." - watirwebdriver.com (c) 2015 @zachfeldman
  8. But we're not using it for that ...and why couldn't

    you just use nokogiri like everyone else? (c) 2015 @zachfeldman
  9. We're not just web scraping ☞ We're monitoring for ajaxComplete

    events ☞ This is kind of like a webhook, in a way (c) 2015 @zachfeldman
  10. Server ☞ Receives scraped commands from Amazon Echo ☞ Uses

    RegEx-powered parsing to match against key phrases ☞ Activates functionality if key phrases are matched, then further parses input ☞ Could be used with any plain-text input, not just from Echo (c) 2015 @zachfeldman
  11. Server architecture First pass: require 'sinatra' get '/process' do if

    params[:q].scan(/turn on/) # do hue stuff end end (c) 2015 @zachfeldman
  12. Things got more complicated ☞ How do we encourage open

    source contribution? ☞ Documentation ☞ Easily extensible, modular system (c) 2015 @zachfeldman
  13. Imitation: the sincerest form of flattery While Bezos laughs on

    a yacht, alexaho.me was "first to market" with these now-native integrations... ☞ Hue ☞ Google Calendar (contributed) ...there's also an official API now. (c) 2015 @zachfeldman
  14. One final demo "Alexa, get me a cab to Union

    Square, New York, New York stop." (c) 2015 @zachfeldman