Short introducing development Alexa Skills

Short introducing development Alexa Skills

Alexa meetup #01, hosted by Haarlem.tech

75486cbfd37125f121cf4a6c5614601c?s=128

Hidetaka Okamoto

April 11, 2018
Tweet

Transcript

  1. 1.

    S h o r t i n t ro d

    u c i n g d e v e l o p m e n t A l e x a S k i l l s A l e x a m e e t u p # 0 1 , h o s t e d b y H a a r l e m . t e c h
  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. 4.
  4. 6.

    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 A l e x a , o p e n X X X “ H e l l o A l e x a ! ” S p e e c h t o Te x t Te x t t o S p e e c h
  5. 7.

    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 A l e x a , o p e n X X X “ H e l l o A l e x a ! ” S p e e c h t o Te x t Te x t t o S p e e c h
  6. 8.

    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 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 , o p e n X X X “ H e l l o A l e x a ! ”
  7. 9.

    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 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 , o p e n X X X “ H e l l o A l e x a ! ”
  8. 10.

    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 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 , o p e n X X X “ H e l l o A l e x a ! ”
  9. 11.

    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 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 , o p e n X X X “ H e l l o A l e x a ! ”
  10. 12.

    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 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 , o p e n X X X “ H e l l o A l e x a ! ”
  11. 13.

    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 “ H e l l o A l e x a ! ” 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 , o p e n X X X
  12. 14.

    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 A l e x a , o p e n X X X “ H e l l o A l e x a ! ” S p e e c h t o Te x t Te x t t o S p e e c h
  13. 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 A l e x a , o p e n X X X “ H e l l o A l e x a ! ” 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
  14. 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 A l e x a , o p e n X X X “ H e l l o A l e x a ! ” 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 AW S L a m b d a We b A P I
  15. 18.

    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": { …
  16. 19.

    Lambda should return valid JSON { "version": "string", "response": {

    "outputSpeech": { "type": "string", "text": "string", "ssml": "string" }, "card": { "type": "string", "image": { "smallImageUrl": "string", "largeImageUrl": "string" } …
  17. 22.

    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(); };
  18. 23.

    '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
  19. 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 D e f i n e re s p o n s e
  20. 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 E x e c u t e a p p l i c a t i o n
  21. 26.

    tell or ask alexa.emit( ‘:tell’, ‘Talk something, and end session’

    ); alexa.emit( ‘:ask’, ‘Talk something, and wait user input’, ‘and ask again’ );
  22. 28.

    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
  23. 29.
  24. 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.
  25. 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.
  26. 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();
  27. 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
  28. 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
  29. 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
  30. 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 )
  31. 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
  32. 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.
  33. 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
  34. 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
  35. 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
  36. 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
  37. 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/
  38. 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.
  39. 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}
  40. 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
  41. 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
  42. 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 !