57
Aniruddha Chakrabarti AVP and Chief Architect, Digital, Mphasis @ anchakra | Linkedin.com/in/ aniruddhac | slideshare.net/ aniruddha.chakrabarti / Amazon Alexa Amazon Echo, Tap and Dot

Amazon alexa - building custom skills

Embed Size (px)

Citation preview

Page 1: Amazon alexa - building custom skills

Aniruddha ChakrabartiAVP and Chief Architect, Digital, Mphasis

@anchakra | Linkedin.com/in/aniruddhac | slideshare.net/aniruddha.chakrabarti/

Amazon AlexaAmazon Echo, Tap and Dot

Page 2: Amazon alexa - building custom skills

Agenda• What is Echo and how does it work• Echo, Tap and Echo Dot• Alexa Voice Service (AVS) • Alexa Skill Kit (ASK)• Custom Alexa Skill

Page 3: Amazon alexa - building custom skills

Echo/Alexa Product Line

Amazon Echo Amazon Tap Amazon Echo Dot Echo enabled third party devices

Page 4: Amazon alexa - building custom skills

What is Amazon Echo• Hands-free speaker you control with your

voice.

• Echo connects to the Alexa Voice Service to play music, provide information, news, sports scores, weather, and more - instantly. All you have to do is ask.

• Echo has seven microphones and beam forming technology so it can hear you from across the room - even while music is playing.

• Echo is also an expertly tuned speaker that can fill any room with 360° immersive sound.

• When you want to use Echo, just say the wake word "Alexa" and Echo responds instantly. 

Page 5: Amazon alexa - building custom skills

Echo Details

• Echo needs to be always connected to power outlet (does not have battery)

• Always need to be connected to net (through a high speed router) to be functional as all of it’s power comes from cloud.

• Echo is always on – using wake word (by default “Alexa”) wakes it up

Page 6: Amazon alexa - building custom skills

Echo Dot and Tap

• Has a tiny speaker, otherwise same as Echo – so called Echo Dot

• Typically you'll hook Dot up to your own audio setup (via out jack or Bluetooth), so you can use Alexa with your existing speakers. 

• The tiny speaker won't output much audio - it's only for Alexa voice feedback (which, again, requires Wi-Fi).

• Portable Bluetooth and Wi-Fi enabled speaker 

• Unlike Echo, Tap is wireless & must be set into the included cradle in order to charge

• The Tap isn't an always-on, so you can't say "Alexa" to wake it and instead need to press the microphone button on the front.

Page 7: Amazon alexa - building custom skills

Amazon Echo & Alexa History• Sept ‘14 - Amazon Echo was launched by Amazon• June ‘15 – Echo became widely available in US• March ‘16 - Amazon unveiled the Amazon Echo Dot and Tap• Amazon opened the API (Alexa Skill Skit and Alexa Voice Service) allowing

developers to build new skills• Sept ‘16 – Echo and Dot is now Availabile in white color• Sept ‘16 - Echo became available outside US in UK and Germany

Page 8: Amazon alexa - building custom skills

How does Echo work

Alexa Enabled Device / Alexa Endpoint

Amazon - Echo, Dot, TapAmazon Fire TV, Fire TV Stick3rd Party – Triby, Pebble Watch

Req. Voice Stream

Resp. Voice Stream

Services / Data Sources

"Alexa, what’s the

time?"

“ . . . ”

UserAmazon Alexa Service

Wikipedia, Weather service, Time service, Traffic update service, Weather service,

Music service, News service, etc.

Page 9: Amazon alexa - building custom skills

What is Alexa• Alexa is the brain behind Alexa devices like Echo, Dot, Tap and other 3rd party

Alexa enabled devices.• Alexa is the voice service that powers Amazon Echo, provides capabilities, or skills,

that enable customers to interact with devices in a more intuitive way using voice.• Alexa is similar to Siri, Cortana or ok google/google home.• Alexa runs in the cloud – the device streams info to Alexa service running in the

cloud.• Amazon is continuously improving and enhancing Alexa - so it is always getting

smarter. The more customers use Alexa, the more she adapts to speech patterns, vocabulary, and personal preferences. 

Page 10: Amazon alexa - building custom skills

Skills• Functionalities or capabilities built by third party to extend core skills of Alexa and

build new customer experiences.• Think of Skill in Alexa as an app in mobile parlance• Skill logic could be developed in any language & web stack (Java, Node.js, Python,

C#, Go, PHP)• Skills could be hosted in cloud (AWS, Azure, Google Cloud Platform, Heroku, PCF,

other PaaS or IaaS) or in your data center / on prem. (internet reachable)

Page 11: Amazon alexa - building custom skills

Type of Skills

• Out of the box skills developed by Amazon that comes pre-built when you purchase the device

• Time, Weather, News, Wikipedia, Traffic, Music, …

BUILT IN SKILLS

• Anything that is not covered by Built in Skill

• Food delivery, Request Taxi, Game,

CUSTOM SKILLS

• Skills to control smart home devices like lights, thermostats, router, freeze, car, any smart home automation/IOT device

SMART HOME SKILLS

• For building Flash Briefing skills which delivers pre-recorded audio clips and text-to-speech (TTS) updates to customers.

• Examples include updates from popular broadcasters and blogs, recent headlines, weather

• Each Flash Briefing skill contains one or more content feeds.

FLASH BRIEFING SKILL

Third PartyAmazon

Page 12: Amazon alexa - building custom skills

Alexa Cloud ServicesALEXA VOICE SERVICE (AVS)Scalable cloud service that adds voice-enabled experiences to any connected product (like Echo). Alexa Voice Service performs speech to text (and vice versa), Natural language processing (NLP) and other functions.

ALEXA SKILL KIT (ASK)Collection of self-service APIs, tools, documentation and code samples that make building new Alexa Skills easy and fast.

Page 13: Amazon alexa - building custom skills

+Settings in Developer Portal (Invocation Name, Name, Skill Type, Endpoint, Publishing Info)

Amazon Developer Portal

Custom Skill Components

Intents(Intent schema)

Sample Utterances(Text file)

Slots(Text file for Custom Slots)

Skill Code (Node.js / Java / Python / C# / Go)

Cloud (AWS / Azure / Google Cloud / Private Cloud/datacenter)

Interaction Model

Page 14: Amazon alexa - building custom skills

IntentsINTENTS• What the user specifically wants the skill to do. You map the user's spoken intents to

intents your service can handle.• Intents are specific requests, questions or commands. e.g. "Alexa, Ask Alarmy to set

the alarm for 7:30 am." • All Skills have intents – a skill at min should have one intent• Skills typically have multiple intents• Each intent maps to a method in your code that is called

E.g. CapitalOne has built a Alexa skill for their customers which support these intents• Account balance• Last transactions• Credit card statement (amount due, payment date)• Pay credit card bill

Page 15: Amazon alexa - building custom skills

Intents (Cont’d)BUILT IN INTENTS• Intents that are often used are already defined by Amazon• Allows users to engage with different skills in a consistent way• Using built-in intents for these types of common actions is useful for several

reasons:• You do not need to spend the time writing sample utterances for the intent.• Users can use common, consistent phrases to access the intent across skills. This makes it

easier for users to work with your skill.• Your skill gets the benefit of any future updates to the Alexa service that improve recognition

and utterances for these intents.• E.g. -

• StopIntent, CancelIntent, HelpIntent, YesIntent, NoIntent, RepeatIntent, StartOverIntent, …

https://developer.amazon.com/public/solutions/alexa/alexaskills-kit/docs/implementing-the-built-in-intents

Page 16: Amazon alexa - building custom skills

List of built in intentsIntent Common Utterances PurposeAMAZON.CancelIntent •cancel

•never mind•forget it

Either of the following:•Let the user cancel a transaction or task (but remain in the skill)•Let the user completely exit the skill

AMAZON.HelpIntent •help•help me•can you help me

Provide help about how to use the skill. See “Offer Help for Complex Skills” in the Voice Design Best Practices for guidelines about help text.

AMAZON.NextIntent •next•skip•skip forward

Let the user navigate to the next item in a list.

AMAZON.NoIntent •no•no thanks Let the user provide a negative response to a yes/no question for confirmation.

AMAZON.PauseIntent •pause•pause that Let the user pause an action in progress.

AMAZON.PreviousIntent •go back•skip back•back up

Let the user go back to a previous item in a list.

AMAZON.RepeatIntent •repeat•say that again•repeat that

Let the user request to repeat the last action.

AMAZON.ResumeIntent •resume•continue•keep going

Let the user resume or continue an action.

AMAZON.StartOverIntent •start over•restart•start again

Let the user request to restart an action, such as restarting a game or a transaction.

AMAZON.StopIntent •stop•off•shut up

Either of the following:•Let the user stop an action (but remain in the skill)•Let the user completely exit the skillSee below for more about canceling and stopping.

AMAZON.YesIntent •yes•yes please•sure

Let the user provide a positive response to a yes/no question for confirmation.

Page 17: Amazon alexa - building custom skills

SlotsSLOTSA variable passed to the intent – like when to set alarm, city for weather etc.

BUILT IN SLOT TYPESAmazon.Date, Amazon.Duration, Amazon.Number, Amazon.US_City, Amazon.Four_Digit_Number, Amazon.Time, Amazon.US_State, Amazon.US_First_Name, …

CUSTOM SLOT TYPESUsed for items that are not covered by Amazon’s built-in set of types and is recommended for most use cases where a slot value is one of a set of possible values. Examples – • List of signs (Horoscope)• List of non US cities• List of services (Ola Prime, Ola Micro, Ola Mini, Ola Auto, Ola Shared)• List of stock exchanges (NASDAQ, London stock exchange, NSE, Tokyo stock exchange, Shanghai)

Page 18: Amazon alexa - building custom skills

Parsing Invocation Name, Intent and SlotsAlexa, ask Schneider for nearest distributors in London

Alexa, ask DigiSure for status of my last vehicle claimAlexa, ask MyWeather for temp (No slot type specified – city is

inferred as current location of user)

Wake Word

Invocation Name Intent Slot

Wake Word could be configured to Alexa, Amazon or Echo

Page 19: Amazon alexa - building custom skills

Solution Elements

VUI •Design Voice User Interface (VUI) & Invocation Name•Decide Intents to be supported, Develop Intent Schema (.json)

Speech •Define sample phrases / sample utterances•Define slot types

Build •Build your code (Node / Python / Java)•Host your code (AWS Lambda / Other PaaS options)

Portal •Define your app/skill in amazon developer portal•Define interaction model, link your skill to code hosted in cloud

Test •Test your skill – echoism.io emulator and device (Echo/Dot/Tap)•Submit your skill for certification

Before you start, refer Voice Design Handbook and Voice Design Best Practice

Page 20: Amazon alexa - building custom skills

Voice User Interface (VUI)• Design the voice experience – voice experiences are different than web & mobile

experience• Think about a core functionality that you want to build first – your skill should do

one thing very well, rather than attempting multiple things• Later add additional functionality iteratively• User empathy

Page 21: Amazon alexa - building custom skills

Invocation Name• Invocation name is how Alexa identifies the capability a user wants• Often this is the name if the Skill, though they could be different.• Should uniquely identify your skill, should be catchy and easy to remember and b/w

1 – 3 words (Guidelines) Alexa, ask Schneider for nearest distributors in LondonAlexa, ask DigiSure for status of my last vehicle claim

Page 22: Amazon alexa - building custom skills

Other settings in Amazon Dev Portal• Contains other settings like Skill type (Custom / Smart Home / Flash Briefing),

Name, Language supported, App Id (auto generated) etc

Page 23: Amazon alexa - building custom skills

Other settings in Amazon Dev Portal• Contains Invocation

Model• Intent Schema, • Custom Slot Types• Sample Utterances

Page 24: Amazon alexa - building custom skills

Handling Requests Sent by Alexa• Verify that the Request is Intended for Your Service• To do this validation, every request sent by Alexa includes an application ID. You

can check this ID to ensure that the request was intended for your service.

Page 25: Amazon alexa - building custom skills

Request Types• Launch Request• Intent Request• Session Ended Request• Session Started

• AudioPlayer Requests• PlaybackController Requests

Page 26: Amazon alexa - building custom skills

Request TypesLaunchRequest• Your service receives a LaunchRequest when the user invokes the skill with the

invocation name, but does not provide any command mapping to an intent.• User: “Alexa, talk to Daily Horoscopes” / “Alexa, open Daily Horoscopes”• Skills that just do one thing (such as telling a joke), the service can take action

without requesting more info from user. Services that need more info from user may need to respond with a prompt.

• Maps to onLaunch() in Java SDK• A LaunchRequest always starts a new session

Page 27: Amazon alexa - building custom skills

Request TypesIntentRequest • Your service receives an IntentRequest when the user speaks a command that

maps to an intent. • The request object sent to your service includes the specific intent and any defined

slot values.• Maps to onIntent() in Java SDK• An IntentRequest can either start a new session or continue an existing session,

depending on how the user begins interacting with the skill:

Page 28: Amazon alexa - building custom skills

Request TypesSessionEndedRequest• Your service receives a SessionEndedRequest when a currently open session is

closed for one of the following reasons:1. The user says “exit”.2. The user does not respond or says something that does not match an intent defined in your

voice interface while the device is listening for the user’s response.3. An error occurs.

• Maps to onSessionEnded() in Java SDK

Page 29: Amazon alexa - building custom skills

Request TypesAudioPlayer Requests and PlaybackController Requests• Your service receives the AudioPlayer and PlaybackController requests only if you

are using the AudioPlayer interface to stream audio. • Alexa sends AudioPlayer requests to notify your service about the current status of

the playback. • The PlaybackController request are sent when the user interacts with the device

using hardware buttons, such as a remote control.

Page 30: Amazon alexa - building custom skills

Intent Schema{ "intents": [ { "intent": "MTriviaIntent" }, { "intent": "AMAZON.HelpIntent" }, { "intent": "AMAZON.StopIntent" }, { "intent": "AMAZON.CancelIntent" } ]}

{ "intents": [ { "intent": "SchneiderSearchIntent", "slots": [ { "name": "City", "type": "LIST_OF_CITIES" } ] }, { "intent": "HearMore" }, { "intent": "DontHearMore" }, { "intent": "AMAZON.HelpIntent" }, { "intent": "AMAZON.StopIntent" }, { "intent": "AMAZON.CancelIntent" } ]}

LondonCoventry

Page 31: Amazon alexa - building custom skills

Sample UtterancesMTriviaIntent a factMTriviaIntent a mphasis factMTriviaIntent a emphasis factMTriviaIntent tell me a factMTriviaIntent tell me a mphasis factMTriviaIntent tell me a emphasis factMTriviaIntent give me a factMTriviaIntent give me a mphasis factMTriviaIntent give me a emphasis factMTriviaIntent tell me triviaMTriviaIntent tell me a mphasis triviaMTriviaIntent tell me a emphasis triviaMTriviaIntent give me triviaMTriviaIntent give me a mphasis triviaMTriviaIntent give me a emphasis triviaMTriviaIntent give me some informationMTriviaIntent give me some mphasis informationMTriviaIntent give me some emphasis informationMTriviaIntent tell me somethingMTriviaIntent give me something

SchneiderSearchIntent get nearest distributors in {City}SchneiderSearchIntent get me nearest distributors in {City}SchneiderSearchIntent get best distributors in {City}SchneiderSearchIntent get me best distributors in {City}SchneiderSearchIntent get me {City}SchneiderSearchIntent top {City}SchneiderSearchIntent get top {City}SchneiderSearchIntent get me top {City}SchneiderSearchIntent nearest {City}SchneiderSearchIntent get nearest {City}SchneiderSearchIntent top distributors in {City}SchneiderSearchIntent get top distributors in {City}SchneiderSearchIntent best distributors in {City}SchneiderSearchIntent get best distributors in {City}SchneiderSearchIntent {City}SchneiderSearchIntent for nearest distributors in {City}SchneiderSearchIntent for distributors in {City}SchneiderSearchIntent distributors in {City}

HearMore yesHearMore yepHearMore yeahHearMore sureHearMore yes pleaseHearMore affirmative

DontHearMore noDontHearMore nopeDontHearMore no thank youDontHearMore not nowDontHearMore negative

Page 32: Amazon alexa - building custom skills

Alexa Custom Skill - Reference Architecture

Echo/Dot DeviceAWS Lambda

(Server-less compute in cloud)

Req. Voice Stream1

2 5

REST service

Resp. Voice Stream

Services

On Prem./Hosted/Cloud

API Gateway & Management

"Alexa, ask Digi Bank for …"

“ . . . ”

User Alexa Voice Service (AVS)(Cloud)

3

• Identifies skill name• Analyzes & understands the req.• Sends the custom Alexa skill a

structured representation of user’s req. Custom Alexa Skill

+ Alexa Skill Kit

4

67

8

9

• Your custom Alexa skill receives the req.

• Processes the req. and returns text (image – opt) response

• Alexa converts the returned text to speech

• Streams to Echo/Dot device

Page 33: Amazon alexa - building custom skills

FedEx (Last Mile) – Alexa Reference Architecture

Echo/Dot DeviceAzure (Azure Functions)

Req. Voice Stream1

2 5

REST service

Resp. Voice Stream FedEx Last Mile Services

Cloud

FedEx API Gateway

"Alexa, ask FedEx for …"

“ . . . ”

User Alexa Voice Service (AVS)(Cloud)

3

• Identifies skill name• Analyzes & understands the req.• Sends the custom Alexa skill a

structured representation of user’s req. FedEx Last Mile

Custom Alexa Skill + Alexa Skill Kit

4

67

8

9

• Your custom Alexa skill receives the req.

• Processes the req. and returns text (image – opt) response

• Alexa converts the returned text to speech

• Streams to Echo/Dot device

Cloud

Page 34: Amazon alexa - building custom skills

Hosting OptionsAWS (AMAZON WEB SERVICE)• AWS Lambda (Recommended, SSL key not required & provides a seamless integration)• Java Servlet on EC2 (Elastic Compute Cloud)• AWS Elastic Beanstalk

AZURE• Azure Functions• Azure Web App Service

GOOGLE CLOUD PLATFORM (GCP)• Cloud Functions• App Engine

HEROKU• Heroku Dynos

OWN / ON PREM.• Anything that is internet reachable and returns JSON over HTTP on port 443 (SSL). Need to have a trusted

certificateNote: Using Non AWS hosting would require SSL Keys.

Page 35: Amazon alexa - building custom skills

AWS Lambda• Server-less compute option from AWS• Event driven - executes code on demand as specified event is triggered• Allows scaling without thinking of servers or nodes• Low cost compared to other compute options• To host Alexa skill, Lambda code should be hosted in N.Virginia / US East location

Page 36: Amazon alexa - building custom skills

Azure Functions• Server-less compute option from Azure - Event driven, compute-on-demand• Expose Functions as HTTP API endpoints• Scale Functions based on customer demand• Very similar to AWS Lambda and GCP (Google) Cloud Functions• Supports a variety of languages, including JavaScript, C#, Python, and PHP

Page 37: Amazon alexa - building custom skills

Request JSON• Session detail• User detail• Request detail

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

Page 38: Amazon alexa - building custom skills

Session

Page 39: Amazon alexa - building custom skills

Request - LaunchRequest

Page 40: Amazon alexa - building custom skills

Request - IntentRequest

Page 41: Amazon alexa - building custom skills

Request – IntentRequest (Cont’d)

Page 42: Amazon alexa - building custom skills

Request - SessionEndedRequest

Page 43: Amazon alexa - building custom skills

Response JSON• Response - Text that Alexa says back to

the user. Could be text or SSML• Reprompt – Text Alexa says back to the

user, if user does not respond. Could be text or SSML

• Graphic Card details (title, text, image) – Appears in companion app

• Session Attributes• Should the session be ended

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

Page 44: Amazon alexa - building custom skills

Voice design best practicesGetting Information from the User

• Make It Clear that the User Needs to Respond• Don’t Assume Users Know What to Do• Clearly Present the Options• Keep it brief• Avoid Overwhelming Users with Too Many Choices• Offer Help for Complex Skills• Ask Only Necessary Questions• Obtain One Piece of Information at a Time• Use the Amazon Alexa App to Enhance Discovery

https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-voice-design-best-practices

Page 45: Amazon alexa - building custom skills

Voice design best practicesPresenting Information to the User

• Make Sure Users Know They are in the Right Place – Set the right context while responding

• Present Information in Consumable Pieces – Use pagination where more information need to be presented

• Write for the Ear, not the Eye – make the interaction as verbal as possible, users should feel that they are talking with another human being

• Avoid Technical and Legal Jargon• Use Text-to-Speech Effectively• Use SSML where required

https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-voice-design-best-practices

Page 46: Amazon alexa - building custom skills

Interaction patterns - One shot model vs Dialog model

User – Alexa, ask MyWeather whether it would rain in Bangalore tomorrow

Alexa – There is a 60% chance that it would rain in Bangalore tomorrow

User – Alexa, open MyWeather

Alexa – Welcome to MyWeather. For which city you are looking for weather predictions?

User – Bangalore

Alexa – for which date?

User – tomorrow

Alexa - There is a 60% chance that it would rain in Bangalore tomorrow

ONE SHOT MODEL DIALOG MODEL

Page 47: Amazon alexa - building custom skills

Hello World Alexa Skill (Node.js)exports.handler = function( event, context ) { var response = { outputSpeech: { type: "PlainText", text: "Hello World" }, card: { type: "Simple", title: "Hello World", content: "Alexa Skills Kit" }, shouldEndSession: true }; context.succeed( { response: response } ); };

Page 48: Amazon alexa - building custom skills

exports.handler = function (event, context) { try { console.log("event.session.application.applicationId=" + event.session.application.applicationId); if (event.session.application.applicationId !== "amzn1.echo-sdk-ams.app.[unique-value-here]") { 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); }};

If it’s a new session, initialize the session, etc…

More on request handling …

Verifying that the Request is Intended for Your Service

Occurs when user launches a skill without an intent

Occurs when user specifies an intent

Occurs when session ends

Page 49: Amazon alexa - building custom skills

function onIntent(intentRequest, session, callback) { console.log("onIntent requestId=" + intentRequest.requestId + ", sessionId=" + session.sessionId);

var intent = intentRequest.intent, intentName = intentRequest.intent.name;

// Dispatch to your skill's intent handlers if ("MyColorIsIntent" === intentName) { setColorInSession(intent, session, callback); }

else if ("WhatsMyColorIntent" === intentName) { getColorFromSession(intent, session, callback); }

else if ("AMAZON.HelpIntent" === intentName) { getWelcomeResponse(callback); }

else if ("AMAZON.StopIntent" === intentName || "AMAZON.CancelIntent" === intentName) { handleSessionEndRequest(callback); }

else { throw "Invalid intent"; }}

More on request handling …

Page 50: Amazon alexa - building custom skills

Response - Speech• Text• SSML

Page 51: Amazon alexa - building custom skills

How to respondfunction getColorFromSession(intent, session, callback) { var favoriteColor; var repromptText = null; var sessionAttributes = {}; var shouldEndSession = false; var speechOutput = "";

if (session.attributes) { favoriteColor = session.attributes.favoriteColor; }

if (favoriteColor) { speechOutput = "Your favorite color is " + favoriteColor + ". Goodbye."; shouldEndSession = true; } else { speechOutput = "I'm not sure what your favorite color is, you can say, my favorite color is red"; }

// Setting repromptText to null signifies that we do not want to reprompt the user. // If the user does not respond or says something that is not understood, the session will end. callback(sessionAttributes, buildSpeechletResponse(intent.name, speechOutput, repromptText, shouldEndSession));}

Page 52: Amazon alexa - building custom skills

How to respondfunction buildSpeechletResponse(title, output, repromptText, shouldEndSession) { return { outputSpeech: { type: "PlainText", text: output }, card: { type: "Simple", title: "SessionSpeechlet - " + title, content: "SessionSpeechlet - " + output }, reprompt: { outputSpeech: { type: "PlainText", text: repromptText } }, shouldEndSession: shouldEndSession };}

Page 53: Amazon alexa - building custom skills

SSML - Speech Synthesis Markup LanguageTags Description Usage

Speak Root element of an SSML document. When using SSML with the Alexa Skills Kit, surround the text to be spoken with this tag

<speak> This is what Alexa sounds like without any SSML.</speak>

audio Lets you provide the URL for an MP3 file that the Alexa service can play while rendering a response.

<speak>    Welcome to Car-Fu. <audio src="https://carfu.com/audio/carfu-welcome.mp3" /> You can order a ride, or request a fare estimate. Which will it be?</speak>

break Represents a pause in the speech. Set the length of the pause with the strength or time attributes.

<speak>    There is a three second pause here <break time="3s"/>    then the speech continues.</speak>

p Represents a paragraph. This tag provides extra-strong breaks before and after the tag.

<speak>    <p>This is the first paragraph. There should be a pause after this text is spoken.</p>    <p>This is the second paragraph.</p></speak>

phoneme

s Represents a sentence. This tag provides strong breaks before and after the tag.This is equivalent to:- Ending a sentence with a period (.).- Specifying a pause with <break strength="strong"/>.

<speak>    <s>This is a sentence</s>    <s>There should be a short pause before this second sentence</s>    This sentence ends with a period and should have the same pause.</speak>

Page 54: Amazon alexa - building custom skills

SSML - Speech Synthesis Markup LanguageTags Description Usage

say-as Describes how the text should be interpreted. This lets you provide additional context to the text and eliminate any ambiguity on how Alexa should render the text. Indicate how Alexa should interpret the text with the interpret-as attribute.

• characters, spell-out: Spell out each letter.• cardinal, number: Interpret the value as a cardinal number.• ordinal: Interpret the value as an ordinal number.• digits: Spell each digit separately .• fraction: Interpret the value as a fraction. This works for both

common fractions (such as 3/20) and mixed fractions (such as 1+1/2).

• unit: Interpret a value as a measurement. The value should be either a number or fraction followed by a unit (with no space in between) or just a unit.

• date: Interpret the value as a date. Specify the format with the format attribute.

• time: Interpret a value such as 1'21" as duration in minutes and seconds.

• telephone: Interpret a value as a 7-digit or 10-digit telephone number. This can also handle extensions (for example, 2025551212x345).

• address: Interpret a value as part of street address.w Similar to <say-as>, this tag customizes the

pronunciation of words by specifying the word’s part of speech.

https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/speech-synthesis-markup-language-ssml-reference

Page 55: Amazon alexa - building custom skills

Response – Graphic Card• Interactions between a user and an Alexa device can include home cards displayed

in the Amazon Alexa App, the companion app available for Fire OS, Android, iOS, and desktop web browsers.

• These are graphical cards that describe or enhance the voice interaction. A custom skill can include these cards in its responses

Page 56: Amazon alexa - building custom skills

Response – Graphic Card• Simple Card - Displays plain text. You provide text for the card title and content.• Standard Card - Also displays plain text, but can include an image. You provide the

text for the title and content, and the URL for the image to display.• LinkAccount Card - Special card type only used with account linking. This card lets

users start the account linking process.

Page 57: Amazon alexa - building custom skills

Type of Intents

• Get the time• Get weather update• Get traffic update• Play music• Get the news briefing• Get account balance, get last

transactions, get credit card bill (CapitalOne)

• Track order status (Dominos)• Get nearest distributors (SE)• Check the shipment status (FedEx)

• Set the timer• Send a meeting request• Send an email• Make a reservation for dinner• Buy something from Amazon• Book a ride (Uber)• Pay last credit card bill

(CapitalOne)• Order a pizza (Dominos)

ASKING DOING