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

HackHunterdon - "Alexa, how can I help my commu...

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on. →

HackHunterdon - "Alexa, how can I help my community?" (April 26, 2018)

Avatar for Sheil Naik

Sheil Naik

April 26, 2018

More Decks by Sheil Naik

Other Decks in Technology

Transcript

  1. Hi, I’m Sheil! Global Data Technical Trainer at Bloomberg 2

    github.com/sheilnaik twitter.com/sheilnaik
  2. 9

  3. 11 How does Alexa work? “Alexa, will it rain tomorrow?”

    Run corresponding AWS Lambda function to get weather Natural Language Processing Generate response phrase “There’s a 50 percent chance of rain in New York tomorrow.”
  4. 12 What’s AWS Lambda? • Code that runs on-demand, without

    needing a server running • Alexa commands are serverless AWS Lambda functions • Most Lambda functions are written in Node.js or Python • I prefer Python
  5. 14 Alexa Vocabulary • Utterance/Sample - The thing you say

    to Alexa • Intent - The thing that happens (the function that runs) when Alexa hears an utterance • Slot (optional) - Variables/parameters for your intent
  6. 15 Alexa Vocabulary • Utterance/Sample - “Alexa, ask Skinnytaste for

    risotto recipes.” • Intent - SearchForRecipes • Slot - “risotto” Example
  7. 18 Alexa Skills Kit What are you calling your skill?

    • “Alexa, ask [ ] for [ ].” • You may need to phonetically spell it out if Alexa has trouble with the pronunciation • “Gron skis” Invocation Name
  8. 19 Alexa Skills Kit What’s your skill going to do?

    • Retrieve the pancake of the month • Let’s call our intent PancakeOfTheMonth Intents
  9. 20 Alexa Skills Kit How will we trigger the intent?

    “Alexa, ask Gronsky’s…” • what is the pancake of the month • pancake of the month • this month’s pancake Samples (formerly known as Utterances)
  10. 21 Alexa Skills Kit What variables/parameters do I want to

    send to my intent? • Gronsky’s skill currently has no slots • If I was storing every month’s pancake into a database, I could ask for a specific month’s pancake Slots
  11. 22 Alexa Skills Kit Click Build Model to build the

    Alexa interaction model. Build Model
  12. 23 Alexa Skills Kit This is where we connect our

    Alexa Interaction Model to our AWS Lambda function. Endpoint
  13. 27 Lambda • Amazon provides a few sample Node.js Alexa

    templates • I use my own template for building Alexa skills in Python
  14. 28 Lambda I hope you like dictionaries! • When you

    open an Alexa skill, it sends a bunch of data in an “input” dictionary called event • Your Lambda function is taking that “input” dictionary, doing a bunch of stuff, and then sending back a dictionary with the response
  15. 29 Lambda My Lambda function template has five parts: 1.

    The main handler 2. Generic events 3. Determining the intent 4. Running the intent 5. Building a response
  16. 30 Lambda • The first function that gets run when

    the Lambda function starts if event[‘request’][‘type’] == ‘LaunchRequest’: Run the on_launch() generic event if event[‘request’][‘type’] == ‘IntentRequest’: Run the on_intent() generic event Main Handler
  17. 31 Lambda • Events that happen for every Alexa skill

    def on_launch(): Run the get_welcome_response() function that gives the user a “Hey, welcome to my Alexa skill” welcome message. Generic Events
  18. 32 Lambda • Figure out which intent the skill is

    trying to run, and then run the code for that intent def on_intent(): if intent_name == ‘PancakeOfTheMonth’: return get_pancake_of_the_month() Determining the Intent
  19. 33 Lambda • Do the actual thing the intent is

    supposed to do • Pass the result to build_response() to actually make the response that Alexa will say • For Gronsky’s, I scrape their website for the pancake of the month Running the Intent
  20. 34 Lambda • Create a response to speak the result

    of the intent • You can also customize a nice visual “card” to show on the Echo Show or Alexa app • “The pancake of the month for April is carrot cake. To hear more information about Gronsky’s, say ‘Tell me about Gronsky’s’. Otherwise, say ‘Stop’ to quit.” Building the Response
  21. 35 Lambda • Lambda uses a basic Python compiler •

    To add third-party libraries, include them in a .zip file along with your Lambda function and upload to Lambda • pip install requests -t /path/to/folder Adding additional libraries
  22. 37 ASK + Lambda Add Alexa Skills Kit as a

    Lambda trigger Copy your Lambda ARN into the Endpoint tab of Alexa Skills Kit
  23. 40 Call to Action • We as technologists have a

    series of unique and coveted skillsets • As we learn new technologies and experiment with new things, think about ways to apply them in our local communities How can you, as a technologist, make a difference in your community?
  24. 41 Call to Action How can you, as a technologist,

    make a difference in your community? • You’ll have a chance to practice your skills while helping local business owners • It’ll make you feel great! • This is what HackHunterdon is all about!
  25. 42 Call to Action How can you, as a local

    business owner, connect with technologists in your community? • Perform community outreach, engage with programs like HackHunterdon, and stay involved! • Your neighbors want to help you! • How can you incentivize them to do so?
  26. 45 Thank you! • Dawn Woods from Gronsky’s Milk House

    • John Goodwin, Marc Saluk, and the other HackHunterdon organizers • All of you!
  27. Thank you! Sheil Naik Global Data Technical Trainer @ Bloomberg

    github.com/sheilnaik twitter.com/sheilnaik