Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Hidetaka Okamoto
Digitalcube / JAWS-UG
How to de...
H i d e t a k a
O k a m o t o
• Digitalcube Co. Ltd.
• JAWS-UG Kyoto, Kobe
• WordCamp Kyoto 2017
I’ll introduce…
• Alexa Skills Kit can easy to make voice application
• AWS Lambda help you to create the Skill more easie...
AGENDA
1. What is Alexa & Alexa Skills Kit ?
2. How to develop the Alexa Skill
3. How to test & deployment your Skill
What is Alexa
And Alexa Skills Kit
Alexa is…
• The voice service that powers Amazon Echo
• Can interact with devices using voice
• Can build new voice experi...
https://developer.amazon.com/alexa-skills-kit/
Alexa Skills Kit (ASK) is…
• Can build engaging skills more easily.
• Collect APIs, tools, docs, examples.
• Can leverage ...
Alexa Skills Kit documentations
• Webinars
• Training videos
• Developer blog
• Podcast
• Events
• and more…
https://devel...
Alexa Skills Kit examples
https://developer.amazon.com/alexa-skills-kit/tutorials
Published our custom Skills
https://www.amazon.com/Digitalcube-Inc-Shifter-man/dp/B07572D7N8/
Shifter man skills is …
• Talking about our service
• Speech out our blog content
• Source code is open.
• https://github....
Check point
• Alexa is the voice service
• Alexa Skills Kit helps us to create App easily
• We can easy to create & deploy...
How to develop the Alexa Skill
A u d i o
C a p t u re
A u d i o
P l a y b a c k
C a l l s o m e A P I
Ta l k
s o m t h i n g
R e s p o n c e
S p e e c h ...
A u d i o
C a p t u re
A u d i o
P l a y b a c k
C a l l s o m e A P I
Ta l k
s o m t h i n g
R e s p o n c e
S p e e c h ...
A u d i o
C a p t u re
A u d i o
P l a y b a c k
C a l l s o m e A P I
Ta l k
s o m t h i n g
R e s p o n c e
S p e e c h ...
AWS Lambda is great Alexa’s backend
https://aws.amazon.com/lambda/
Lambda get JSON from Alexa Skills
{
"request": {
"type": "IntentRequest",
"requestId": "",
"intent": {
"name": "AskPriceIn...
Lambda should return valid JSON
{
"version": "string",
"response": {
"outputSpeech": {
"type": "string",
"text": "string",...
Alexa has SDK (Node.js)
https://www.npmjs.com/package/alexa-sdk
npm init -y
npm install -S alexa-sdk
We can easy to write Alexa code
'use strict';
const Alexa = require('alexa-sdk');
const handlers = {
'LaunchRequest': func...
'use strict';
const Alexa = require('alexa-sdk');
const handlers = {
'LaunchRequest': function () {
this.emit(':tell', 'He...
'use strict';
const Alexa = require('alexa-sdk');
const handlers = {
'LaunchRequest': function () {
this.emit(':tell', 'He...
'use strict';
const Alexa = require('alexa-sdk');
const handlers = {
'LaunchRequest': function () {
this.emit(':tell', 'He...
tell or ask
alexa.emit(
‘:tell’,
‘Talk something, and end session’
);
alexa.emit(
‘:ask’,
‘Talk something, and wait user i...
Can call another API (like WP API)
https://github.com/getshifter/alexa-shifterman/blob/master/index.js#L44-L67
Many Skills examples in GitHub
• https://github.com/alexa/
• “step-by-step” help us to know how to deploy
• All example ha...
How to test & deployment
your Skill
Easy to create Alexa Skills, but We want to …
• Test our code in local environment
• Deploy our code automatically
• Manag...
Easy to create Alexa Skills, but We want to …
• Test our code in local environment
• Deploy our code automatically
• Manag...
Alexa Conversation: Tests for your Alexa skills
https://www.npmjs.com/package/alexa-conversation
npm install -g mocha
npm install --save-dev alexa-conversation
We can easy to test own Alexa code
const conversation = require('alexa-conversation');
const app = require('../index.js');...
We can easy to test own Alexa code
const conversation = require('alexa-conversation');
const app = require('../index.js');...
We can easy to test own Alexa code
const conversation = require('alexa-conversation');
const app = require('../index.js');...
We can easy to test own Alexa code
const conversation = require('alexa-conversation');
const app = require('../index.js');...
Running test by mocha
$ m o c h a t e s t s
E x e c u t i n g c o n v e r s a t i o n : H e l l o A l e x a Te s t
✓ F i n...
ESLint help you to check your code
https://eslint.org/
“Shifter man” is tested two way
# Check the code syntax by ESLint
$ npm run lint
# Test the conversation by alexa-conversa...
Easy to create Alexa Skills, but We want to …
• Test our code in local environment
• Deploy our code automatically
• Manag...
Serverless Framework: create & manage app
https://serverless.com/
$ npm install -g serverless
$ serverless create -t aws-nodejs
$ serverless deploy
We can define AWS resources as YAML
service: alexa-shifter
provider:
name: aws
runtime: nodejs6.10
package:
include:
- nod...
We can define AWS resources as YAML
service: alexa-shifter
provider:
name: aws
runtime: nodejs6.10
package:
include:
- nod...
We can define AWS resources as YAML
service: alexa-shifter
provider:
name: aws
runtime: nodejs6.10
package:
include:
- nod...
We can define AWS resources as YAML
service: alexa-shifter
provider:
name: aws
runtime: nodejs6.10
package:
include:
- nod...
Easy to rollback & checking CloudWatch logs
# Rollback
$ serverless rollback --timestamp timestamp
# Tail the Lamdbda’s lo...
Easy to create Alexa Skills, but We want to …
• Test our code in local environment
• Deploy our code automatically
• Manag...
Serverless FW using CloudFormation
https://serverless.com/
We can define custom resources
custom:
stage: ${opt:stage, self:provider.stage}
defaultProfile: default
logRetentionInDays...
We can define custom resources
custom:
stage: ${opt:stage, self:provider.stage}
defaultProfile: default
logRetentionInDays...
We can define custom resources
custom:
stage: ${opt:stage, self:provider.stage}
defaultProfile: default
logRetentionInDays...
Easy to customize our AWS resources
https://serverless.com/framework/docs/providers/aws/guide/serverless.yml/
All examples are in our GitHub
https://github.com/getshifter/alexa-shifterman
Conclusion
• We can easy to make voice app by Alexa
• AWS help us to create & manage Alexa app
• Let’s create own Alexa Sk...
Join !
https://jaws-ug-kobe.doorkeeper.jp/events/64712
#AWSCommunityDay
Q&A
How to develop Alexa Skill Kit based on Serverless Architecture
How to develop Alexa Skill Kit based on Serverless Architecture
How to develop Alexa Skill Kit based on Serverless Architecture
Upcoming SlideShare
Loading in …5
×

How to develop Alexa Skill Kit based on Serverless Architecture

1,338 views

Published on

AWS Community Day APAC
2017/09/21

Published in: Engineering
  • Be the first to comment

  • Be the first to like this

How to develop Alexa Skill Kit based on Serverless Architecture

  1. 1. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Hidetaka Okamoto Digitalcube / JAWS-UG How to develop Alexa Skills Kit based on Serverless Architecture
  2. 2. H i d e t a k a O k a m o t o • Digitalcube Co. Ltd. • JAWS-UG Kyoto, Kobe • WordCamp Kyoto 2017
  3. 3. I’ll introduce… • Alexa Skills Kit can easy to make voice application • AWS Lambda help you to create the Skill more easier • Serverless Framework can manage your app code • Node.js is good for making Alexa Skill
  4. 4. AGENDA 1. What is Alexa & Alexa Skills Kit ? 2. How to develop the Alexa Skill 3. How to test & deployment your Skill
  5. 5. What is Alexa And Alexa Skills Kit
  6. 6. Alexa is… • The voice service that powers Amazon Echo • Can interact with devices using voice • Can build new voice experiences https://developer.amazon.com/alexa
  7. 7. https://developer.amazon.com/alexa-skills-kit/
  8. 8. Alexa Skills Kit (ASK) is… • Can build engaging skills more easily. • Collect APIs, tools, docs, examples. • Can leverage Amazon’s knowledge of voice. https://developer.amazon.com/alexa-skills-kit
  9. 9. Alexa Skills Kit documentations • Webinars • Training videos • Developer blog • Podcast • Events • and more… https://developer.amazon.com/alexa-skills-kit/learn
  10. 10. Alexa Skills Kit examples https://developer.amazon.com/alexa-skills-kit/tutorials
  11. 11. Published our custom Skills https://www.amazon.com/Digitalcube-Inc-Shifter-man/dp/B07572D7N8/
  12. 12. Shifter man skills is … • Talking about our service • Speech out our blog content • Source code is open. • https://github.com/getshifter/alexa-shifterman
  13. 13. Check point • Alexa is the voice service • Alexa Skills Kit helps us to create App easily • We can easy to create & deploy App by AWS
  14. 14. How to develop the Alexa Skill
  15. 15. A u d i o C a p t u re A u d i o P l a y b a c k C a l l s o m e A P I Ta l k s o m t h i n g R e s p o n c e S p e e c h t o Te x t Te x t t o S p e e c h
  16. 16. A u d i o C a p t u re A u d i o P l a y b a c k C a l l s o m e A P I Ta l k s o m t h i n g R e s p o n c e S p e e c h t o Te x t Te x t t o S p e e c h A l e x a S k i l l s K i t
  17. 17. A u d i o C a p t u re A u d i o P l a y b a c k C a l l s o m e A P I Ta l k s o m t h i n g R e s p o n c e S p e e c h t o Te x t Te x t t o S p e e c h AW S L a m b d a We b A P I A l e x a S k i l l s K i t
  18. 18. AWS Lambda is great Alexa’s backend https://aws.amazon.com/lambda/
  19. 19. Lambda get JSON from Alexa Skills { "request": { "type": "IntentRequest", "requestId": "", "intent": { "name": "AskPriceIntent", "slots": {} }, "locale": "en-US", "timestamp": "2017-08-29T08:26:02Z" }, "context": { "System": { "application": { "applicationId": "amzn1.ask.skill.XXXXXXXX" }, "user": { …
  20. 20. Lambda should return valid JSON { "version": "string", "response": { "outputSpeech": { "type": "string", "text": "string", "ssml": "string" }, "card": { "type": "string", "image": { "smallImageUrl": "string", "largeImageUrl": "string" } …
  21. 21. Alexa has SDK (Node.js) https://www.npmjs.com/package/alexa-sdk
  22. 22. npm init -y npm install -S alexa-sdk
  23. 23. We can easy to write Alexa code 'use strict'; const Alexa = require('alexa-sdk'); const handlers = { 'LaunchRequest': function () { this.emit(':tell', 'Hello'); }, }; module.exports.hello = (event, context, callback) => { var alexa = Alexa.handler(event, context, callback); alexa.registerHandlers(handlers); alexa.execute(); };
  24. 24. 'use strict'; const Alexa = require('alexa-sdk'); const handlers = { 'LaunchRequest': function () { this.emit(':tell', 'Hello'); }, }; module.exports.hello = (event, context, callback) => { var alexa = Alexa.handler(event, context, callback); alexa.registerHandlers(handlers); alexa.execute(); }; We can easy to write Alexa code L o a d a l e x a - s d k
  25. 25. 'use strict'; const Alexa = require('alexa-sdk'); const handlers = { 'LaunchRequest': function () { this.emit(':tell', 'Hello'); }, }; module.exports.hello = (event, context, callback) => { var alexa = Alexa.handler(event, context, callback); alexa.registerHandlers(handlers); alexa.execute(); }; We can easy to write Alexa code L o a d a l e x a - s d k D e f i n e re s p o n s e
  26. 26. 'use strict'; const Alexa = require('alexa-sdk'); const handlers = { 'LaunchRequest': function () { this.emit(':tell', 'Hello'); }, }; module.exports.hello = (event, context, callback) => { var alexa = Alexa.handler(event, context, callback); alexa.registerHandlers(handlers); alexa.execute(); }; We can easy to write Alexa code L o a d a l e x a - s d k D e f i n e re s p o n s e E x e c u t e a p p l i c a t i o n
  27. 27. tell or ask alexa.emit( ‘:tell’, ‘Talk something, and end session’ ); alexa.emit( ‘:ask’, ‘Talk something, and wait user input’, ‘and ask again’ );
  28. 28. Can call another API (like WP API) https://github.com/getshifter/alexa-shifterman/blob/master/index.js#L44-L67
  29. 29. Many Skills examples in GitHub • https://github.com/alexa/ • “step-by-step” help us to know how to deploy • All example has comment (How to customize) • We can easy to create own Alexa Skills
  30. 30. How to test & deployment your Skill
  31. 31. Easy to create Alexa Skills, but We want to … • Test our code in local environment • Deploy our code automatically • Manage our resources in AWS.
  32. 32. Easy to create Alexa Skills, but We want to … • Test our code in local environment • Deploy our code automatically • Manage our resources in AWS.
  33. 33. Alexa Conversation: Tests for your Alexa skills https://www.npmjs.com/package/alexa-conversation
  34. 34. npm install -g mocha npm install --save-dev alexa-conversation
  35. 35. We can easy to test own Alexa code const conversation = require('alexa-conversation'); const app = require('../index.js'); const opts = { name: 'Alexa Shifter man', appId: 'your-app-id', app: app, handler: app.hello }; conversation(opts) .userSays('GetNewFactIntent') .plainResponse .shouldContain("Here's the shifter") .end();
  36. 36. We can easy to test own Alexa code const conversation = require('alexa-conversation'); const app = require('../index.js'); const opts = { name: 'Alexa Shifter man', appId: 'your-app-id', app: app, handler: app.hello }; conversation(opts) .userSays('GetNewFactIntent') .plainResponse .shouldContain("Here's the shifter") .end(); L o a d l i b & t e s t t a rg e t
  37. 37. We can easy to test own Alexa code const conversation = require('alexa-conversation'); const app = require('../index.js'); const opts = { name: 'Alexa Shifter man', appId: 'your-app-id', app: app, handler: app.hello }; conversation(opts) .userSays('GetNewFactIntent') .plainResponse .shouldContain("Here's the shifter") .end(); I n i t t e s t L o a d l i b & t e s t t a rg e t
  38. 38. We can easy to test own Alexa code const conversation = require('alexa-conversation'); const app = require('../index.js'); const opts = { name: 'Alexa Shifter man', appId: 'your-app-id', app: app, handler: app.hello }; conversation(opts) .userSays('GetNewFactIntent') .plainResponse .shouldContain("Here's the shifter") .end(); I n i t t e s t D e f i n e t e s t L o a d l i b & t e s t t a rg e t
  39. 39. Running test by mocha $ m o c h a t e s t s E x e c u t i n g c o n v e r s a t i o n : H e l l o A l e x a Te s t ✓ F i n i s h e d e x e c u t i n g c o n v e r s a t i o n C o n v e r s a t i o n : H e l l o A l e x a Te s t U s e r t r i g g e r s : H e l l o I n t e n t ✓ A l e x a ' s p l a i n t e x t re s p o n s e s h o u l d c o n t a i n : H e l l o . I ' m e x a m p l e s k i l l s f o r y o u r s e r v e r l e s s p ro j e c t s . ✓ A l e x a ' s p l a i n t e x t re s p o n s e s h o u l d c o n t a i n : P l e a s e t e l l m e y o u r n a m e . U s e r t r i g g e r s : N a m e I n t e n t S L O T S : { N a m e S l o t : Ts u y o s h i } ✓ A l e x a ' s p l a i n t e x t re s p o n s e s h o u l d c o n t a i n : N i c e t o m e e t y o u , Ts u y o s h i . E n j o y A l e x a w o r l d ! 4 p a s s i n g ( 1 6 m s )
  40. 40. ESLint help you to check your code https://eslint.org/
  41. 41. “Shifter man” is tested two way # Check the code syntax by ESLint $ npm run lint # Test the conversation by alexa-conversation $ npm test https://github.com/getshifter/alexa-shifterman/blob/master/README.md
  42. 42. Easy to create Alexa Skills, but We want to … • Test our code in local environment • Deploy our code automatically • Manage our resources in AWS.
  43. 43. Serverless Framework: create & manage app https://serverless.com/
  44. 44. $ npm install -g serverless $ serverless create -t aws-nodejs $ serverless deploy
  45. 45. We can define AWS resources as YAML service: alexa-shifter provider: name: aws runtime: nodejs6.10 package: include: - node_modules/ functions: hello: handler: index.hello events: - alexaSkill
  46. 46. We can define AWS resources as YAML service: alexa-shifter provider: name: aws runtime: nodejs6.10 package: include: - node_modules/ functions: hello: handler: index.hello events: - alexaSkill D e f i n e p ro v i d e r
  47. 47. We can define AWS resources as YAML service: alexa-shifter provider: name: aws runtime: nodejs6.10 package: include: - node_modules/ functions: hello: handler: index.hello events: - alexaSkill I n c l u d e l i b r a r i e s D e f i n e p ro v i d e r
  48. 48. We can define AWS resources as YAML service: alexa-shifter provider: name: aws runtime: nodejs6.10 package: include: - node_modules/ functions: hello: handler: index.hello events: - alexaSkill I n c l u d e l i b r a r i e s D e f i n e L a m b d a D e f i n e p ro v i d e r
  49. 49. Easy to rollback & checking CloudWatch logs # Rollback $ serverless rollback --timestamp timestamp # Tail the Lamdbda’s log $ serverless logs -f hello -t https://serverless.com/framework/docs/providers/aws/cli-reference/
  50. 50. Easy to create Alexa Skills, but We want to … • Test our code in local environment • Deploy our code automatically • Manage our resources in AWS.
  51. 51. Serverless FW using CloudFormation https://serverless.com/
  52. 52. We can define custom resources custom: stage: ${opt:stage, self:provider.stage} defaultProfile: default logRetentionInDays: development: "14" production: "90" default: "3" resources: Resources: HelloLogGroup: Properties: RetentionInDays: ${self:custom.logRetentionInDays.${self:custom.stage}, self:custom.logRetentionInDays.default}
  53. 53. We can define custom resources custom: stage: ${opt:stage, self:provider.stage} defaultProfile: default logRetentionInDays: development: "14" production: "90" default: "3" resources: Resources: HelloLogGroup: Properties: RetentionInDays: ${self:custom.logRetentionInDays.${self:custom.stage}, self:custom.logRetentionInDays.default} D e f i n e p a r a m s
  54. 54. We can define custom resources custom: stage: ${opt:stage, self:provider.stage} defaultProfile: default logRetentionInDays: development: "14" production: "90" default: "3" resources: Resources: HelloLogGroup: Properties: RetentionInDays: ${self:custom.logRetentionInDays.${self:custom.stage}, self:custom.logRetentionInDays.default} D e f i n e p a r a m s U p d a t e C W L p ro p s
  55. 55. Easy to customize our AWS resources https://serverless.com/framework/docs/providers/aws/guide/serverless.yml/
  56. 56. All examples are in our GitHub https://github.com/getshifter/alexa-shifterman
  57. 57. Conclusion • We can easy to make voice app by Alexa • AWS help us to create & manage Alexa app • Let’s create own Alexa Skills !
  58. 58. Join ! https://jaws-ug-kobe.doorkeeper.jp/events/64712
  59. 59. #AWSCommunityDay Q&A

×