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

Alexa Skills (or The Unexpected Virtue of Laziness) -

Alexa Skills (or The Unexpected Virtue of Laziness) -

Aswini Kumar Dasika talks about Alexa Skills (or The Unexpected Virtue of Laziness).

Aswini gave us an overview on how to develop custom Alexa Skills, their potential use in modern Web development and for accessibility needs.

Frontend NE

January 05, 2018
Tweet

More Decks by Frontend NE

Other Decks in Programming

Transcript

  1. Alexa Skills or The Unexpected Virtue of Laziness !! Aswini

    Dasika Principal Software Engineer DWP Digital
  2. Alexa intelligent personal assistant developed by Amazon capable of voice

    interaction music playback making to-do lists setting alarms streaming podcasts playing audiobooks providing weather, traffic, and other real-time information can control compatible smart devices such as light bulbs, TVs etc.
  3. Echo (1st Gen) Echo Dot Echo Plus (built-in ZigBee smart

    home hub) Echo Show Echo Buttons (Alexa Gadgets) Echo (2nd Gen)
  4. Sample Intent Handling Code exports.handler = function (event, context) {

    try { // Restrict this function to just a given skill id if (event.session.application.applicationId !== “your_skill_id”) { context.fail("Invalid Application ID"); } if (event.session.new) { onSessionStarted({requestId: event.request.requestId}, event.session); } if (event.request.type === "LaunchRequest") { onLaunch(event.request, event.session, function callback(sessionAttributes, speechletResponse) { context.succeed(buildResponse(sessionAttributes, speechletResponse)); }); } else if (event.request.type === "IntentRequest") { onIntent(event.request, event.session, function callback(sessionAttributes, speechletResponse) { context.succeed(buildResponse(sessionAttributes, speechletResponse)); }); } else if (event.request.type === "SessionEndedRequest") { onSessionEnded(event.request, event.session); context.succeed(); } } catch (e) { context.fail("Exception: " + e); } };
  5. function onIntent(intentRequest, session, callback) { var intent = intentRequest.intent, intentName

    = intentRequest.intent.name; // dispatch custom intents to handlers here if (intentName === 'WiggleIndicator') { handleWiggleRequest(intent, session, callback, false); } else if (intentName === 'FailIndicator') { handleFailRequest(intent, session, callback, false, “"); } else if (intentName === 'AMAZON.YesIntent') { handleYesRequest(intent, session, callback); } else if (intentName === 'AMAZON.NoIntent') { handleNoRequest(intent, session, callback); } else if (intentName === 'AMAZON.HelpIntent') { handleHelpRequest(intent, session, callback); } else if (intentName === 'AMAZON.CancelIntent' || intentName == 'AMAZON.StopIntent') { handleStopRequest(intent, session, callback); } else { throw "Invalid intent"; } }
  6. function handleWiggleRequest(intent, session, callback, atLaunch) { if(intent.slots) { var wiggleIndicatorsSlot

    = intent.slots.WiggleIndicators; var wiggleIndicatorName; if (wiggleIndicatorsSlot && wiggleIndicatorsSlot.value) { wiggleIndicatorName = wiggleIndicatorsSlot.value.toLowerCase(); } /* YOUR SKILL LOGIC HERE */ var output = “SOMETHING FOR ALEXA TO SAY"; var speechletResponse = buildSSMLSpeechletResponse(output, "", "false"); callback(session.attributes, speechletResponse); } else { /* SOMETHING WRONG, HANDLE IT ! */ } } function handleFailRequest(intent, session, callback, wrongPlayOption, wiggleIndicatorName) { /* YOU KNOW THE PLAYER FAILED IF YOU ARE HERE, SO NO NEED TO INTERROGATE INTENT AND THE SLOT */ /* LOGIC TO GATHER GAME SCORES etc. HERE */ output = “SOMETHING FOR ALEXA TO SAY UPON PLAYER”S FAILURE OR GAME ENDED"; speechletResponse = buildSSMLSpeechletResponse(output, "", "true"); callback(session.attributes, speechletResponse); } }
  7. Speech Synthesis Markup Language (SSML) https://developer.amazon.com/docs/custom-skills/speech-synthesis-markup-language-ssml-reference.html function getApplauseSSML(score) { var

    applauseSSML = ""; if (score <= 2 ) { applauseSSML = "<emphasis level=\"strong\"><audio src=\"https://s3-eu-west-1.amazonaws.com/ash-sounds/boo.mp3\" /></emphasis>"; } else if(score <= 10 ) { applauseSSML = "<emphasis level=\"strong\"><audio src=\"https://s3-eu-west-1.amazonaws.com/ash-sounds/applause.mp3\" /></emphasis>"; } else { applauseSSML = "<emphasis level=\"strong\"><audio src=\"https://s3-eu-west-1.amazonaws.com/ash-sounds/cheer.mp3\" /></emphasis>"; } return applauseSSML; }
  8. function buildSSMLSpeechletResponse(output, repromptText, shouldEndSession) { return { outputSpeech: { type:

    "SSML", ssml: output }, reprompt: { outputSpeech: { type: "SSML", ssmlssml: repromptText } }, shouldEndSession: shouldEndSession }; } function buildSpeechletResponse(title, output, shouldEndSession) { return { outputSpeech: { type: "PlainText", text: output }, card: { type: "Simple", title: title, content: output } shouldEndSession: shouldEndSession }; }
  9. Alexa Skills Lingo Alexa, ask polygon pal about a pentagon

    } } —> Wake Word —> Launch Phrase —> Invocation Name } } —> Utterance • Alexa • Echo • Computer • Amazon —> • Ask • Launch • Play • Tell • & more at —> https://developer.amazon.com/docs/custom-skills/understanding-how-users-invoke-custom-skills.html
  10. More Games.. err Demos ? Mind Your Words - DynamoDB

    What3Words - Google Location API, Amazon Device API, What3Words API Mark My Words - Word based game, DynamoDB
  11. What kind of skills can I build ? • Custom

    Skills • Smart Home Skills • Flash Briefing Skills • Video Skills • List Skills https://developer.amazon.com/docs/ask-overviews/understanding-the-different-types-of-skills.html
  12. Potential for Voice Control Technology in Application Development Paper Forms

    —> Email Attachments —> Web Forms —> Voice Interactive Technology
  13. • Can revolutionise how our customers interact with our product

    - Do away with web forms ? • Improve accessibility with a new way to solve problems - Take commands by voice DEMO - JobSearch skill • Natural Language Processing (NLP) APIs - use them to create organisation specific NLP universe and host them on-premise using Alexa for business. • Amazon Lex - sophisticated, natural language chatbots with flexibility of natural language understanding (NLU) and automatic speech recognition (ASR)