28
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved. January 2017 Creating IoT Solutions with Serverless Architecture & Alexa John Chang ( 張張張 ) Technology Evangelist [email protected]

Creating IoT Solutions with Serverless Architecture & Alexa

Embed Size (px)

Citation preview

Page 1: Creating IoT Solutions with Serverless Architecture & Alexa

© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

January 2017

Creating IoT Solutions with Serverless Architecture & Alexa

John Chang (張書源 )Technology Evangelist

[email protected]

Page 2: Creating IoT Solutions with Serverless Architecture & Alexa

Today’s agenda• Skill building fundamentals• Voice User-Interface• Alexa skill building

Page 3: Creating IoT Solutions with Serverless Architecture & Alexa

70s 80s 90s 00s Present

mode

GUI

web

mobile

character

VUI

Page 4: Creating IoT Solutions with Serverless Architecture & Alexa
Page 5: Creating IoT Solutions with Serverless Architecture & Alexa
Page 6: Creating IoT Solutions with Serverless Architecture & Alexa

Skill Building Fundamentals

Before we code1. developer.amazon.com2. aws.amazon.com

Page 7: Creating IoT Solutions with Serverless Architecture & Alexa

7

The Alexa Service

Alexa Skills Kit

Alexa Voice

Services

© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Page 8: Creating IoT Solutions with Serverless Architecture & Alexa

8

Alexa Skills Kit: Processing a request

© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Audio

Request

Response

Your service

Speech RecognitionMachine Learning

Natural Language Understanding

Text to Speech

Cards

Page 9: Creating IoT Solutions with Serverless Architecture & Alexa

9© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Cards

Alexa Skills Kit: Utterances and Intents

Response

Your service

Audio

Speech RecognitionMachine Learning

Natural Language Understanding

Text to Speech

RequestIntents

Utterances

Page 10: Creating IoT Solutions with Serverless Architecture & Alexa

ASR – Automatic Speech Recognition

for tē tīmz

• Forty Times?

• For Tea Times?

• For Tee Times?

• Four Tee Times?

Page 11: Creating IoT Solutions with Serverless Architecture & Alexa

Alexa, ask Anime Facts for a factwake word utteranceskill namelaunch

Utterances and Intents

Page 12: Creating IoT Solutions with Serverless Architecture & Alexa

One more pleaseutterance

Utterances and Intents

Alexa, ask Anime Facts for a factwake word utteranceskill namelaunch

Page 13: Creating IoT Solutions with Serverless Architecture & Alexa

GetFactIntentIntent

utterance slot value

Utterances and Intents

One more pleaseutterance

Alexa, ask Anime Facts for a factwake word utteranceskill namelaunch

Page 14: Creating IoT Solutions with Serverless Architecture & Alexa

14

Building an Alexa SkillHosted service• You define interactions for your

Voice App through intent schemas• Each intent consists of two fields:

• The intent field gives the name of the intent

• The slots field lists the slots associated with that intent

• Slots can also included types such as LITERAL, NUMBER, DATE, etc.

Page 15: Creating IoT Solutions with Serverless Architecture & Alexa

15

Building an Alexa SkillHosted service• The mappings between intents and

the typical utterances that invoke those intents are provided in a tab-separated text document of sample utterances.

• Each possible phrase is assigned to one of the defined intents.

• GetHoroscope what is the horoscope for {pisces|Sign}

• GetHoroscope what will the horoscope for {leo|Sign} be {next tuesday|Date}

Page 16: Creating IoT Solutions with Serverless Architecture & Alexa

16© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Audio

Speech RecognitionMachine Learning

Natural Language Understanding

Text to Speech

Cards

Alexa Skills Kit: Requests and Responses

Request

Response

Your service

Page 17: Creating IoT Solutions with Serverless Architecture & Alexa

17

Page 18: Creating IoT Solutions with Serverless Architecture & Alexa

18

Handling Amazon Alexa serviceRequests• You need to handle POST requests to

your service over port 443 and parse the JSON

• You need to check the session variable to see if the user started a new session or if request is from existing one

• Requests always Include a type, requestId and timestamp

• requestId maps directly to LaunchRequest, IntentRequest and SessionEndedRequest

Page 19: Creating IoT Solutions with Serverless Architecture & Alexa

19

Alexa Skills Kit: Request and Response

© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

“Help”

Page 20: Creating IoT Solutions with Serverless Architecture & Alexa

20

Using Lambda for Processing the Request & generating the response

© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Page 21: Creating IoT Solutions with Serverless Architecture & Alexa

21

Demo

© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Page 22: Creating IoT Solutions with Serverless Architecture & Alexa

AnswerIntent {value: “one”}slot valueIntent

one is the answerslot value

Slots in the utterances

The answer is oneslot value

oneslot value

Page 23: Creating IoT Solutions with Serverless Architecture & Alexa

23

Utterances and Intent Schema

Utterances Intent Schema

Page 24: Creating IoT Solutions with Serverless Architecture & Alexa

24

Utterances and Intent Schema

Utterances Intent Schema

Page 25: Creating IoT Solutions with Serverless Architecture & Alexa

25

Built-in and Custom Slot Types

Page 26: Creating IoT Solutions with Serverless Architecture & Alexa

26© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Session Attributes

Page 27: Creating IoT Solutions with Serverless Architecture & Alexa

27

Session Persistence

© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

exports.handler = function (event, context, callback) { var alexa = Alexa.handler(event, context); alexa.appId = appId; alexa.dynamoDBTableName = 'YourTableName'; //

That's it! alexa.registerHandlers(State1Handlers, State2Handlers);

alexa.execute(); };

this.attributes['yourAttribute'] = 'value';

var yourVariable = this.attributes['yourAttribute']

Add dynamoDB table name in your index.js

put

get

Page 28: Creating IoT Solutions with Serverless Architecture & Alexa

Thank you!