Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Introduction to building alexa skills and putting your amazon echo to work

3,447 views

Published on

So you bough a brand new Echo/Tap/Dot device... now what? Well if you want to start hacking away and building your own skills this session is for you. We will cover the basic building blocks to get you up and running with your very own first custom skill.

Published in: Devices & Hardware
  • Be the first to comment

Introduction to building alexa skills and putting your amazon echo to work

  1. 1. INTRODUCTION TO BUILDING ALEXA SKILLS AND PUTTING YOUR AMAZON ECHO TO WORK. ABE DIAZ
  2. 2. @abe238 WHO’S THIS GUY? Was: Developer -> Evangelist ->Product Manager Now: Technical Program Manager @ ‣ Alexa Enthusiast (not an Expert) Contact Info: Twitter: @abe238 info@abediaz.com
  3. 3. @abe238
  4. 4. @abe238 HOW DID I END UP HERE?
  5. 5. @abe238 TEXT http://bit.ly/alexatwilio
  6. 6. @abe238 TEXT ME: “ALEXA, OPEN SMS AND TEXT MY WIFE “I LOVE YOU”!” WIFE: “HEY, WHO THE HELL IS TEXTING ME!” ALEXA: “OK”
  7. 7. @abe238 GOT HOOK?
  8. 8. @abe238 BEFORE I FORGET… WHO WANTS SOME FREE STUFF? WANT AN ALEXA ENABLED DEVICE? ▸ 1) Do this TODAY! ▸ bit.ly/alexacheckin ▸ Event Name: CODEDAY ▸ Within 30 days fill this out: ▸ bit.ly/alexabootcamp
  9. 9. @abe238 ALEXA SKILLS WHAT ARE THESE SKILLS YOU TALK ABOUT? ▸ Alexa provides a set of built-in capabilities, referred to as skills. For example, Alexa’s abilities include playing music from multiple providers, answering questions, providing weather forecasts, and querying Wikipedia. ▸ The Alexa Skills Kit (ASK) lets you teach Alexa new skills. Customers can access these new abilities by asking Alexa questions or making requests. You can build skills that provide users with many different types of abilities. ▸ There are two main types of skills Custom Skills and Smart Home Skills. This session will focus on Custom Skills.
  10. 10. @abe238 WHAT IS AN ALEXA SKILL?
  11. 11. @abe238 SKILL SERVICE
  12. 12. @abe238 ALEXA SKILLS ALEXA SKILL SERVICE ▸ A skill service is nothing but a piece of code accessible on the internet that responds to commands sent out by Alexa enabled devices. ▸ In theory you can write (and host) your code in any language as long as you are able to handle http requests.
  13. 13. @abe238 ALEXA SKILLS ALEXA SKILL SERVICE ▸ Typically this code is written in three preferred languages: ▸ Why those three languages? ▸ Because these are the ones supported in AWS Lambda’s code editor. ▸ Why do I care about AWS Lambda?
  14. 14. @abe238 ALEXA SKILLS WHY USE AWS LAMBDA? Using an AWS Lambda function for your service eliminates some of the complexity around setting up and managing your own endpoint: ▸ You do not need to administer or manage any of the compute resources for your service. ▸ ▸ You do not need an SSL certificate. ▸ You do not need to verify that requests are coming from the Alexa service yourself. Access to execute your function is controlled by permissions within AWS instead. ▸ AWS Lambda runs your code only when you need it and scales with your usage, so there is no need to provision or continuously run servers. ▸ Alexa encrypts its communications with Lambda utilizing TLS. ▸ For most developers, the Lambda free tier is sufficient for the function supporting an Alexa skill. The first one million requests each month are free. Note that the Lambda free tier does not automatically expire, but is available indefinitely. #SERVERLESS
  15. 15. @abe238 ALEXA SKILLS CODE MANAGEMENT WITHIN AWS LAMBDA How do you upload or manage your code in AWS Lambda? ▸ Write your code directly in the code editor in the Lambda console (Node.js or Python). ▸ Write your code offline and copy and paste it into the Lambda console editor (Node.js or Python). ▸ Write your code offline and upload it to the Lambda function in a zip file (Node.js, Python, or Java). ▸ Use the Eclipse IDE and the AWS Toolkit for Eclipse (Java). For details, see Using AWS Lambda with the Toolkit for Eclipse.
  16. 16. @abe238 ALEXA SKILLS DIRECTLY EDIT YOUR CODE
  17. 17. @abe238 ALEXA SKILLS UPLOAD YOUR CODE
  18. 18. @abe238 IF NOT USING AWS LAMBDA ▸ Best Resource: http://bit.ly/alexawalterquesada
  19. 19. @abe238 SKILL INTERFACE MODEL
  20. 20. @abe238 ALEXA SKILLS WHAT COMPOSES A SKILL’S INTERFACE When designing and building a custom skill, you create the following: ‣ A set of intents that represent actions that users can do with your skill. These intents represent the core functionality for your skill. ‣ A set of sample utterances that specify the words and phrases users can say to invoke those intents. You map these utterances to your intents. This mapping forms the interaction model for the skill. ‣ An invocation name that identifies the skill. The user includes this name when initiating a conversation with your skill. ‣ A cloud-based service that accepts these intents as structured requests and then acts upon them. This service must be accessible over the Internet. You provide an endpoint for your service when configuring the skill. ‣ A configuration that brings all of the above together so that Alexa can route requests to the service for your skill. You create this configuration in the developer portal.
  21. 21. @abe238 ALEXA SKILLS WHAT COMPOSES A SKILL’S INTERFACE
  22. 22. @abe238 ALEXA, ASK ONEBUSAWAY, WHERE IS MY BUS? Me (in the morning) SAMPLE ALEXA REQUEST INVOCATION NAME INTENT: FIND BUS INTENT
  23. 23. @abe238 ALEXA SKILLS INTENTS ‣ There are Custom and Built-In Intents ‣ Built-In Intents help abstract a lot of the logic for default actions like cancelling or repeating a prompt.
  24. 24. @abe238 ALEXA SKILLS SAMPLE UTTERANCES The words to be used to invoke a specific intent are called utterances.
  25. 25. @abe238 ALEXA SKILLS CARDS (WITHIN THE APP) Cards are also part of a skill’s interface. Here is an example of a skill card within the Alexa mobile app. ALEXA, GET HIGH TIDE FOR SEATTLE FROM TIDE POOLER NOTE: CARDS CAN HAVE TEXT OR IMAGES (JPG, PNG)
  26. 26. @abe238 ALEXA SKILLS USER FLOW (INCLUDING CARDS)
  27. 27. @abe238 ALEXA SKILLS END TO END USER FLOW
  28. 28. @abe238 ALEXA SKILLS SLOT TYPES ‣ To avoid having to define hundreds of sample utterances, the concept of slot types was created. ‣ This allows us to insert a variable in the sample utterances descriptions that can handle multiple values.
  29. 29. @abe238 ALEXA SKILLS SLOT TYPES
  30. 30. @abe238 ALEXA SKILLS SLOT TYPES
  31. 31. @abe238 ALEXA SKILLS SLOT TYPES
  32. 32. EVERY SKILL IS DIFFERENT
  33. 33. @abe238 TYPES OF SKILLS WHAT PATTERN DOES MY SKILL FIT? Every skill is different, but there are similar patterns across skills. ▸ Fact Skills: ▸ How to Skills: ▸ Decision Trees: ▸ Other: Audio Player, Games, Custom “ALEXA, OPEN CAT FACTS” “ALEXA, ASK MY BARTENDER HOW TO MAKE A MOJITO” ME: “ALEXA, ASK PLAY HOOKY IF I SHOULD STAY IN BED” ALEXA: “IS IT RAINING OUTSIDE?” ME: “YES” ALEXA: “OK, IS ELLEN PLAYING ON THE TV?” ME: “NO” ALEXA: “THEN I THINK YOU GET GET OUT OF BED.”
  34. 34. @abe238 WHAT DO WE NEED TO START?
  35. 35. @abe238 INGREDIENTS FOR A SKILL WHAT DO I NEED TO BUILD A SKILL ▸ Amazon Developer Account (developer.amazon.com) ▸ App Configuration ▸ AWS Account (aws.amazon.com) ▸ Lambda function: ▸ Easy: https://s3.amazonaws.com/memodoring-cloudformation/cloudformation.json ▸ Region: US East (N. Virginia) This is the only region with Alexa skills support. ▸ Resource: bit.ly/alexa123cloud
  36. 36. @abe238 DEMO CREATING LAMBDA FUNCTIONS FROM A TEMPLATE ▸ Create a stack using the cloud formation template. ▸ You will see 3 lambda functions created in your console. (Go to: Services > Compute > Lambda) ▸ For each Lambda function, create a trigger (Alexa Skill) and test (Start Session). ▸ References for templates (github.com/alexa): ▸ bit.ly/alexa123fact ▸ bit.ly/alexa123decision ▸ bit.ly/alexa123howto
  37. 37. @abe238 DEMO CREATING LAMBDA FUNCTIONS FROM SCRATCH ▸ Select name, runtime ▸ Code: ▸ inline ▸ zip file ▸ S3 - Use this if planning to plug into CI engine for deployments ▸ Role: ▸ Basic Execution will cover most scenarios ▸ If planning to store values, then select micro service or create a custom role with dynamodb permissions.
  38. 38. @abe238 DEMO DEALING WITH SESSIONS ▸ Every time a user invokes a skill name, a session is created. ▸ While inside the skills, if the user is being reprompted for input, the same session remains active. ▸ Because of that, the recommendation is to handle long term sessions by persisting data separately in a data store like DynamoDB.
  39. 39. @abe238 ALEXA DYNAMODB ▸ Amazon DynamoDB ▸ Use DynastyJS ▸ https://www.npmjs.com/package/dynasty ▸ Promise-based DynamoDB API ▸ 5 reads/writes per second by default ▸ Reference: http://bit.ly/alexadynamopersistence
  40. 40. @abe238 ACCOUNT LINKING ▸ If you need to authenticate users, Lambda can do so by means of Account Linking. ▸ Account linking uses OAuth 2.0
  41. 41. @abe238 MORE INFO WHAT CAN YOU DO WITH ALEXA? ▸ Start your car remotely: http://fortune.com/2016/08/18/ hyundai-genesis-amazon/ ▸ Open your door lock: http://fortune.com/2016/07/28/ alexa-amazon-august-smart-lock/ ▸ Where’s my stuff? http://www.geekwire.com/2016/ amazon-adds-package-tracking-alexas-abilities/ ▸ Alexa talks back: http://mashable.com/2016/09/08/ amazon-echo-push-notifications/
  42. 42. @abe238 MORE INFO IFTTT
  43. 43. @abe238 MORE INFO BUILD YOUR OWN ECHO
  44. 44. @abe238 MORE INFO TEST WITHOUT A DEVICE
  45. 45. @abe238 MORE INFO THINGS YOU CAN’T DO ▸ Collect sensitive data: Health, PII ▸ Be respectful of Brands (“Harry Potter”) ▸ For now, there are no such notifications. ▸ Can’t actively listen to mics (e.g. make calls through the device)
  46. 46. @abe238 ALEXA, ASK REWIND AND CAPTURE, WHY IS IT CALLED AMAZON? DEMO
  47. 47. @abe238 REMEMBER TO DO THIS TODAY WANT AN ALEXA ENABLED DEVICE? ▸ 1) Do this TODAY! ▸ bit.ly/alexacheckin ▸ Event Name: CODEDAY ▸ Within 30 days fill this out: ▸ bit.ly/alexabootcamp

×