Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Short introducing development Alexa Skills

Short introducing development Alexa Skills

Alexa meetup #01, hosted by Haarlem.tech

Hidetaka Okamoto

April 11, 2018
Tweet

More Decks by Hidetaka Okamoto

Other Decks in Technology

Transcript

  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. 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. 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
  4. 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. 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 ! ”
  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 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. 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. 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. 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. 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
  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 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
  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 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
  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 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
  14. 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": { …
  15. Lambda should return valid JSON { "version": "string", "response": {

    "outputSpeech": { "type": "string", "text": "string", "ssml": "string" }, "card": { "type": "string", "image": { "smallImageUrl": "string", "largeImageUrl": "string" } …
  16. 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(); };
  17. '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
  18. '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
  19. '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
  20. tell or ask alexa.emit( ‘:tell’, ‘Talk something, and end session’

    ); alexa.emit( ‘:ask’, ‘Talk something, and wait user input’, ‘and ask again’ );
  21. 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
  22. Easy to create Alexa Skills, but We want to …

    • Test our code in local environment • Deploy our code automatically • Manage our resources in AWS.
  23. Easy to create Alexa Skills, but We want to …

    • Test our code in local environment • Deploy our code automatically • Manage our resources in AWS.
  24. 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();
  25. 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
  26. 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
  27. 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
  28. 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 )
  29. “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
  30. Easy to create Alexa Skills, but We want to …

    • Test our code in local environment • Deploy our code automatically • Manage our resources in AWS.
  31. 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
  32. 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
  33. 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
  34. 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
  35. 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/
  36. Easy to create Alexa Skills, but We want to …

    • Test our code in local environment • Deploy our code automatically • Manage our resources in AWS.
  37. 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}
  38. 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
  39. 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
  40. Conclusion • We can easy to make voice app by

    Alexa • AWS help us to create & manage Alexa app • Let’s create own Alexa Skills !