Share
Embed
Alexa, can you help me?
A brief introduction to the development of an Alexa Skill for Amazon Echo devices.
Alessandro Calzavara
June 14, 2018
Transcript
41 slides
-
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 -
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 [email protected] -
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! -
Agenda Introduction to the smart speakers market Alexa skill foundations
Development and testing Deployment and certification -
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 -
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) -
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 -
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 -
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 -
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 -
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 -
Alexa Skill Kit SDK (v2) Simplify request routing and response
generation • Request Handler • Session management • Data persistency Support node 8, async/await, Typescript -
RequestHandler interface RequestHandler { canHandle(handlerInput: HandlerInput): Promise<boolean> | boolean; handle(handlerInput:
HandlerInput): Promise<Response> | Response; } -
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. -
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(); }, }; -
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; } -
Final composition const LaunchRequestHandler = require('./src/skill/launchRequestHandler'); //... exports.handler = Alexa.SkillBuilders.custom()
.addRequestHandlers( LaunchRequestHandler, ReadHandler, InsertHandler, HelpHandler, ExitHandler, FallbackHandler ) .addErrorHandlers( ErrorHandler ) .lambda(); -
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 -
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 -
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 ! -
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. -
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 -
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