33
Advanced Alexa Skills Kit Advanced Alexa Skills Kit @merryoscar [email protected] www.opearlo.com

A Cloud Guru Advanced Alexa Skills Kit Development - Oscar Merry

Embed Size (px)

Citation preview

Page 1: A Cloud Guru Advanced Alexa Skills Kit Development - Oscar Merry

Advanced Alexa Skills Kit

Advanced Alexa Skills Kit

@[email protected]

www.opearlo.com

Page 2: A Cloud Guru Advanced Alexa Skills Kit Development - Oscar Merry

Advanced Alexa Skills KitIntro• Why this course?

• Prerequisites:• Amazon Developer Account• AWS Account• NodeJS Installed• Alexa Enabled Device

• Code Files - https://github.com/MerryOscar/voice-devs-lessons

Page 3: A Cloud Guru Advanced Alexa Skills Kit Development - Oscar Merry

Advanced Alexa Skills KitIntro to Alexa

The Voice Service that powers Amazon Echo

Page 4: A Cloud Guru Advanced Alexa Skills Kit Development - Oscar Merry

Advanced Alexa Skills KitThe Alexa Ecosystem

Page 5: A Cloud Guru Advanced Alexa Skills Kit Development - Oscar Merry

Advanced Alexa Skills KitWhat Can Alexa Do?

Page 6: A Cloud Guru Advanced Alexa Skills Kit Development - Oscar Merry

Advanced Alexa Skills KitWhy Build Skills?

Page 7: A Cloud Guru Advanced Alexa Skills Kit Development - Oscar Merry

Advanced Alexa Skills KitAlexa Skills Kit Request Response Model

• Alexa communicates with your Skill’s backend (web service or AWS Lambda function) via a HTTPS Request-Response format

• When a user interacts with your Skill, Alexa sends your service a POST request containing a JSON body

Page 8: A Cloud Guru Advanced Alexa Skills Kit Development - Oscar Merry

Advanced Alexa Skills KitAlexa Skills Kit Request Response Model• Request Body:

• session – Information about the current session

• context – Information about the current state of the Alexa service and the device

• request – Information about the user’s request type:• Launch Request• IntentRequest• SessionEndedRequest• AudioPlayer Requests• PlaybackController Requests

https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-interface-reference

Page 9: A Cloud Guru Advanced Alexa Skills Kit Development - Oscar Merry

Advanced Alexa Skills KitAlexa Skills Kit Request Response Model• Response Body:

• outputSpeech – What Alexa will say as a response

• card – Card object to be rendered in the Alexa companion app as part of the response

• reprompt – What Alexa will say if the session is to remain open and a reprompt is necessary

• shouldEndSession – indicates whether the session should close

• directives – Array of directives specifying device level actions such as for the AudioPlayer interface

https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-interface-reference

Page 10: A Cloud Guru Advanced Alexa Skills Kit Development - Oscar Merry

Advanced Alexa Skills KitAlexa NodeJS SDKhttps://github.com/alexa/alexa-skills-kit-sdk-for-nodejs

Easily build Alexa Skills with nodeJS and AWS LambdaHelper events for new sessions and unhandled eventsHelper functions for easy state managementSimple configuration for persistent database storage in DynamoDBSpeech output automatically wrapped in SSMLOfficially supported by Amazon

Page 11: A Cloud Guru Advanced Alexa Skills Kit Development - Oscar Merry

Advanced Alexa Skills KitAlexa Development Environment• Amazon Developer Portal• https://developer.amazon.com/alexa

• AWS Lambda• https://aws.amazon.com/console/

• AWS CLI• https://aws.amazon.com/cli/

• Code Files – https://github.com/MerryOscar/voice-devs-lessons

Page 12: A Cloud Guru Advanced Alexa Skills Kit Development - Oscar Merry

Advanced Alexa Skills Kit

Voice Devs Alexa Skill

Page 13: A Cloud Guru Advanced Alexa Skills Kit Development - Oscar Merry

Advanced Alexa Skills KitVoice Devs Skill – Intro • Aim – Build an Alexa Skill that gives people information about

upcoming Alexa Developer meetups, showcasing a wide range of Alexa’s capabilities.

• Alexa, ask Voice Devs for the next Alexa meetup?• Alexa, ask Voice Devs which cities have Alexa meetups?• Alexa, ask Voice Devs how many members the New York Alexa meetup has?• Alexa, ask Voice Devs about the London Alexa Devs meetup• Alexa, ask Voice Devs for the latest Alexa Devs podcast

Page 14: A Cloud Guru Advanced Alexa Skills Kit Development - Oscar Merry

Advanced Alexa Skills KitVoice Devs Skill - Sections• Voice Devs Project

1. Creating a Basic Skill2. Simple Intents3. SSML Audio4. Complex Conversations5. Persistent Database Storage6. State Management7. Account Linking8. Using the Meetup API (1)9. Using the Meetup API (2)10. Audio Streaming11. Opearlo Alexa Skill Analytics12. Multiple Languages

Page 15: A Cloud Guru Advanced Alexa Skills Kit Development - Oscar Merry

Advanced Alexa Skills Kit1. Creating a Basic Skill• Skill Template – https://github.com/MerryOscar/voice-devs-lessons

• Speech Assets• Intent Schema• Custom Slots• Utterances

• Lambda

• publish_lambda.sh

Page 16: A Cloud Guru Advanced Alexa Skills Kit Development - Oscar Merry

Advanced Alexa Skills Kit2. Simple Intents• Alexa, ask Voice Devs how many cities have Alexa meetups?

• Alexa, ask Voice Devs if {City} has an Alexa meetup?

• Alexa, ask Voice Devs who’s the organiser of the {City} Alexa meetup?

Page 17: A Cloud Guru Advanced Alexa Skills Kit Development - Oscar Merry

Advanced Alexa Skills Kit3. SSML Audio• SSML is a markup language that provides a standard way to mark up text for the

generation of synthetic speech

• The Alexa Skills Kit supports the following SSML tags:

• speak – root element of SSML document (node SDK automatically wrapped)• audio – add short audio clips in response (HTTPS, MP3, 90s, 48kbps, 16000 Hz)• break – add a custom length pause to the response• p – represents a paragraph break• phoneme – provides phonetic pronunciation for the contained text• s – represents a sentence break• say-as – describes how text should be interpreted (characters, date, telephone)• w – interpret a word as specific grammar role (verb, noun, past principle)

Page 18: A Cloud Guru Advanced Alexa Skills Kit Development - Oscar Merry

Advanced Alexa Skills Kit4. Complex Conversations• Aim create complex & personal conversations between Alexa and your

user:

• Session Attributes

• Persistent Database Storage

• State Management

• Account Linking

Page 19: A Cloud Guru Advanced Alexa Skills Kit Development - Oscar Merry

Advanced Alexa Skills Kit5. Persistent Database Storage• Often we want information we’ve captured from our user to be stored

between sessions.

• The Alexa-SDK provides an easy way to do this via Amazon DynamoDB.

• Simply add the DynamoDB table name to your Alexa object:

alexa.dynamoDBTableName = 'YourTableName';

Page 20: A Cloud Guru Advanced Alexa Skills Kit Development - Oscar Merry

Advanced Alexa Skills Kit6. State Management

• Why State Management?• Alexa-SDK comes with built in State Management• Alexa-SDK will route incoming intents to the correct function handler based on state• State is persisted in DynamoDB along with Session Attributes• Use the ’Unhandled’ handler DynamoDB to cover intents that are called in a state

that doesn’t support them

Onboarding State Main State Some Other

State

Page 21: A Cloud Guru Advanced Alexa Skills Kit Development - Oscar Merry

Advanced Alexa Skills Kit7. Account Linking• Allows user to link their Alexa account with an account from a 3rd party

system or your own user account system

• Allows user to make authenticated requests to this system

• Do I need account linking? – Can I just use the userId attribute to manage user attributes between sessions?

Page 22: A Cloud Guru Advanced Alexa Skills Kit Development - Oscar Merry

Advanced Alexa Skills KitOAuth2 Roles in Alexa• Resource owner: the end user who wants to connect your Skill with their user

account in another system.

• Resource server: The server hosting the resources the user wants to access. This server is part of the external system, and it must be able to accept and respond to requests using access tokens.

• Authorization server: The server that authenticates the identity of the resource owner and issues access tokens.

• Client App: The application making the requests to the resource server on behalf of the resource owner. In this context, this is the Alexa Skill.

Page 23: A Cloud Guru Advanced Alexa Skills Kit Development - Oscar Merry

Advanced Alexa Skills KitAlexa OAuth Data Flow – Login with Amazon

Page 24: A Cloud Guru Advanced Alexa Skills Kit Development - Oscar Merry

Advanced Alexa Skills KitAuthorization Code Grant vs Implicit Grant• Authorization Code Grant:

• Authorization Server returns an Authorization Code• Alexa service uses Authorization Code to request an Access Token and Refresh Token• Supports Refresh Tokens• More Secure

• Implicit Grant:• Authorization Server returns an Access Token• Simpler• No Refresh Token support

Page 25: A Cloud Guru Advanced Alexa Skills Kit Development - Oscar Merry

Advanced Alexa Skills Kit8. Using the Meetup API (1)• Account Link with Meetup.com in order to access information about

the user and Alexa events:

•Meetup Organisers

Page 26: A Cloud Guru Advanced Alexa Skills Kit Development - Oscar Merry

Advanced Alexa Skills Kit9. Using the Meetup API (2)• Account Link with Meetup.com in order to access information about

the user and Alexa events:

• Number of Members• Next Event

Page 27: A Cloud Guru Advanced Alexa Skills Kit Development - Oscar Merry

Advanced Alexa Skills Kit10. Audio Streaming• The AudioPlayer interface provides your skill the ability to stream

audio and monitoring playback progression.

• Your skill can send directives to start and stop the playback.

• The Alexa service sends your skill AudioPlayer Requests to give you information about the playback state, such as when the track is nearly finished, or when playback starts and stops.

Page 28: A Cloud Guru Advanced Alexa Skills Kit Development - Oscar Merry

Advanced Alexa Skills Kit10. Opearlo Alexa Skill Analytics• Free!• Install in 5 mins!• Fully Customisable Voice Events + Variables!

Page 29: A Cloud Guru Advanced Alexa Skills Kit Development - Oscar Merry

Advanced Alexa Skills Kit10. Audio Streaming• Required Intents:

• AMAZON.PauseIntent• AMAZON.ResumeIntent

• Optional Intents:• AMAZON.CancelIntent• AMAZON.LoopOffIntent• AMAZON.LoopOnIntent• AMAZON.NextIntent• AMAZON.PreviousIntent• AMAZON.RepeatIntent• AMAZON.ShuffleOffIntent• AMAZON.ShuffleOnIntent• AMAZON.StartOverIntent

• AudioPlayer Directives:• AudioPlayer.Play – Sends Alexa a command to stream the audio file identified

by the specified audioItem.

• AudioPlayer.Stop – Stops any currently playing audio stream.

• AudioPlayer.ClearQueue – Clears the queue of all audio streams.

• AudioPlayer Requests:• AudioPlayer.PlaybackStarted – Sent when Alexa begins playing the audio

stream previously sent in a Play directive. This lets your skill verify that playback began successfully.

• AudioPlayer.PlaybackFinished – Sent when the stream that Alexa is playing comes to an end on its own.

• AudioPlayer.PlaybackStopped – Sent when Alexa stops playing an audio stream in response to a voice request or an AudioPlayer directive.

• AudioPlayer.PlaybackNearlyFinished – Sent when the currently playing stream is nearly complete and the device is ready to receive a new stream.

• AudioPlayer.PlaybackFailed – Sent when Alexa encounters an error when attempting to play a stream.

Page 30: A Cloud Guru Advanced Alexa Skills Kit Development - Oscar Merry

Advanced Alexa Skills KitMultiple Languages

Page 31: A Cloud Guru Advanced Alexa Skills Kit Development - Oscar Merry

Advanced Alexa Skills KitSummary!• Part 1 – Intro to Alexa

• Intro to Alexa Skills Kit• Alexa NodeJS SDK• Alexa Development Environment

• Part 2 – Voice Devs Project1. Creating a Basic Skill2. Simple Intents3. SSML Audio4. Complex Conversations5. Persistent Database Storage6. State Management7. Account Linking8. Using the Meetup API (1)9. Using the Meetup API (2)10. Audio Streaming11. Alexa Skill Analytics12. Multiple Languages

github.com/MerryOscar/voice-devs-lessons

Page 32: A Cloud Guru Advanced Alexa Skills Kit Development - Oscar Merry

Advanced Alexa Skills KitVoice Best Practice• Voice Best Practice• Do user testing early on• Don’t start coding until the Voice Interaction Model has been done• Keep Alexa’s responses as short as possible• Don’t have too many steps in the conversation• It’s worth spending time on the ‘half-happy’ paths - Have a backup layer within the skills

backend that does keyword matching if the slots weren’t exactly recognized

• Discoverability• Who is going to be using the voice app?• How will they find out about it?• What will be the reason they come to use the voice app?

Page 33: A Cloud Guru Advanced Alexa Skills Kit Development - Oscar Merry

Advanced Alexa Skills KitThank You!

analytics.opearlo.com

Email – [email protected] - @merryoscarLinkedIn- uk.linkedin.com/in/oscarmerry