Alexa, can you help me?

Alexa, can you help me?

A brief introduction to the development of an Alexa Skill for Amazon Echo devices.

D90102aaed6eb7403f745ad75138e777?s=128

Alessandro Calzavara

June 14, 2018
Tweet

Transcript

  1. Alexa, can you help me?

  2. None
  3. None
  4. MUG (Marca User Group) è uno user group trevigiano non

    verticalizzato su nessuna tecnologia o metodologia in particolare. Tutti possono proporre qualsiasi argomento legato al mondo dello sviluppo software. Lo scopo è quello di aggregare e fare network tra il maggior numero di sviluppatori possibile Cosa è MUG
  5. Chi Siamo Francesco Strazzullo Marco Perone Antonio Dell’Ava Ubaldo Pescatore

    George Karametas
  6. Slack https://mug-slack-inviter.herokuapp.com/ Eventi https://github.com/m-u-g/eventi Trello https://trello.com/b/cbJeCFJR/mug-setup Contatti

  7. and now...

  8. Alexa, can you help me?

  9. Who is Alessandro? Alessandro Calzavara is a Senior Mobile Engineer

    that has been working with iOS and Android apps for more than 8 years. The Spreaker Studio App that he’s working on was featured on Google Play Store many times. Currently he is working at Voxnest (that recently acquired Spreaker and Blog Talk Radio) on Spreaker mobile products. @DrAL3X alessandro.calzavara@spreaker.com
  10. Voxnest open position: Mobile Engineer (iOS/Android) Shaping the future of

    Spreaker apps, for both listeners and content creators. 3+ years of experience in at least one platform. Fluent in English. Located in EU. • Remote working • No formal meetings • Flexible vacation plan, with limitless days • Yearly training budget JO IN US!
  11. Agenda Introduction to the smart speakers market Alexa skill foundations

    Development and testing Deployment and certification
  12. Introduction to the smart speakers market

  13. Smart Speakers

  14. A category on its own 16% of US people own

    at least one 11% has an Amazon Echo 4% a Google Home No desktop or mobile, but home device Controlled by voice, and always on No screen (actually it’s optional) It’s partially replacing other devices, like Radio appliances, TVs and smartphones Source: The Smart Audio Report from NPR and Edison Research, Fall Winter 2017
  15. Usage examples Play music, podcasts and audio books Getting the

    news and personal schedule Entertains people (childrens especially) via games or funny things Control home appliances (lights, thermostat, etc) Asking questions about something (weather, sport results, anything from wikipedia, etc)
  16. From user perspective Activate the device by using a special

    keyword (Alexa, Ok Google, Hey Siri) Say the question or command Let the device “think” about it Receive a proper response Forget about the device
  17. DEMO Alexa, introduce, yourself.

  18. Alexa Skill Foundations

  19. 3 key components: Type, Metadata Which phrases are handle by

    your skill Generation of a response for each user request Skill Definition Interaction Model Business Logic
  20. Skill definition Entrypoint at https://developer.amazon.com/alexa Metadata information, example phrases, privacy

    & terms urls, general availability Types: custom, smart home, flash briefing, video, list
  21. None
  22. Interaction model Mapping which phrases your skill is able to

    handle, by Intents Built-in Intents (“Yes/No”, “Stop”, “Nevermind”, etc) Custom Intents (“what's my score“) It’s the most important part of a skill
  23. None
  24. Business Logic Parse an Alexa request and provide a valid

    Alexa response AWS Lambda (Free tier for-the-win!) Alexa Skill Kit SDK, for nodejs and java • https://github.com/alexa/alexa-skills -kit-sdk-for-nodejs • https://github.com/alexa/alexa-skills -kit-sdk-for-java
  25. Alexa Skill Kit SDK (v2) Simplify request routing and response

    generation • Request Handler • Session management • Data persistency Support node 8, async/await, Typescript
  26. RequestHandler interface RequestHandler { canHandle(handlerInput: HandlerInput): Promise<boolean> | boolean; handle(handlerInput:

    HandlerInput): Promise<Response> | Response; }
  27. HandlerInput RequestEnvelope: Contains the entire request body sent to skill.

    AttributesManager: Provides access to request, session, and persistent attributes. ServiceClientFactory: Constructs service clients capable of calling Alexa APIs. ResponseBuilder: Contains helper function to build responses. Context: Provides an optional, context object passed in by the host container. For example, for skills running on AWS Lambda, this is the context object for the AWS Lambda function.
  28. const phrases = require('./phrases'); module.exports = { canHandle(handlerInput) { return

    handlerInput.requestEnvelope.request.type === 'LaunchRequest'; }, handle(handlerInput) { let greetings = phrases.getPhrase('welcome'); let ask = phrases.getPhrase('promptInsert') return handlerInput.responseBuilder .speak(greetings + " " + ask) .reprompt(ask) .getResponse(); }, };
  29. Response interface ResponseBuilder { speak(speechOutput: string): this; reprompt(repromptSpeechOutput: string): this;

    withSimpleCard(cardTitle: string, cardContent: string): this; withStandardCard(cardTitle: string, cardContent: string, smallImageUrl?: string, largeImageUrl?: string): this; [...] getResponse(): Response; }
  30. Final composition const LaunchRequestHandler = require('./src/skill/launchRequestHandler'); //... exports.handler = Alexa.SkillBuilders.custom()

    .addRequestHandlers( LaunchRequestHandler, ReadHandler, InsertHandler, HelpHandler, ExitHandler, FallbackHandler ) .addErrorHandlers( ErrorHandler ) .lambda();
  31. Development and testing

  32. Development Run on my machine? It’s complicated… • You cannot

    use Alexa Service on your machine • Live vs Development works only for interaction model and metadata, not lambda! • Consider making a BETA skill to not touch production until ready Prefer unit testing to iterate more quickly • Use jasmine (or anything you like) to mock resources (DynamoDB, external API, etc) Manual end-to-end testing is still necessary
  33. Manual Testing Testing website: https://developer.amazon.com/alexa/console/ask/ • see full request and

    full response (and listen to it) Simulator in the broswer: https://echosim.io/welcome • better than nothing... Real device • invite your Amazon account as betatester and use it from your device
  34. None
  35. None
  36. Deployment and certification

  37. Deployment Skill definition and interaction model • using the website

    • automate via ASK CLI • changes require approval (certification process) Business logic (via AWS Lambda) • package your code and upload it to S3 • changes are immediate • it’s the same between LIVE and DEVELOPMENT !
  38. Certification All skills must be validated and approved by The

    Alexa Skills Team. They’ll check everything, from metadata to example phrases, to basic behaviours. Certification is required each time you change metadata or the interaction model. This process usually less than 5 business days*. When not approved, they give you detailed explanation of what didn’t work.
  39. Shameless plug Real certification duration is a mystery Crowdsource time

    from tweets with #skillcertificationtime on Twitter. Daily average posted by @skillcerttimes and on skillcertificationtimes.com #skillcertificationtime skillcertificationtimes.com
  40. Official Alexa Skill Kit documentation: https://developer.amazon.com/docs/ask-overviews/build-skills-with-the-alexa-skills-kit.html Alexa Skill Kit for

    Nodejs https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs Skill Certification Time project: https://skillcertificationtimes.com/ https://github.com/dral3x/alexa-skill-certification-times Links
  41. Thanks for listening! Ask anything to me, or to Alexa