{"id":15230,"date":"2018-10-04T14:38:06","date_gmt":"2018-10-04T05:38:06","guid":{"rendered":"http:\/\/www.skyarch.net\/blog\/?p=15230"},"modified":"2018-10-04T16:42:45","modified_gmt":"2018-10-04T07:42:45","slug":"%e3%80%90alexa%e3%82%b9%e3%82%ad%e3%83%ab%e9%96%8b%e7%99%ba%e3%80%91dialog%e3%83%a2%e3%83%87%e3%83%ab%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e7%b0%a1%e5%8d%98%e3%82%b9%e3%83%ad%e3%83%83%e3%83%88%e5%87%a6","status":"publish","type":"post","link":"https:\/\/www.skyarch.net\/blog\/%e3%80%90alexa%e3%82%b9%e3%82%ad%e3%83%ab%e9%96%8b%e7%99%ba%e3%80%91dialog%e3%83%a2%e3%83%87%e3%83%ab%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e7%b0%a1%e5%8d%98%e3%82%b9%e3%83%ad%e3%83%83%e3%83%88%e5%87%a6\/","title":{"rendered":"\u3010Alexa\u30b9\u30ad\u30eb\u958b\u767a\u3011Dialog\u30e2\u30c7\u30eb\u3092\u4f7f\u3063\u3066\u7c21\u5358\u30b9\u30ed\u30c3\u30c8\u51e6\u7406"},"content":{"rendered":"<h2>\u306f\u3058\u3081\u306b<\/h2>\n<p>\u30d6\u30ed\u30b0\u521d\u6295\u7a3f\u3001\u958b\u767a\u90e8\u306e\u8fbb\u3067\u3059\u3002<br \/>\n\u6280\u8853\u7684\u306a\u3053\u3068\u3092\u3061\u3087\u3044\u3061\u3087\u3044\u66f8\u3044\u3066\u3044\u3051\u308c\u3070\u306a\u3041\u3068\u601d\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u6700\u8fd1Alexa\u30b9\u30ad\u30eb\u306e\u958b\u767a\u3092\u62c5\u5f53\u3057\u3066\u3044\u307e\u3059\u304c<br \/>\n\u958b\u767a\u4e2d\u306fAmazon Echo\u3068\u4f1a\u8a71\u3092\u3059\u308b\u3053\u3068\u304c\u591a\u304f<br \/>\n\u30c6\u30b9\u30c8\u4e2d\u306b\u306f\u3001\u96a3\u306e\u4eba\u304b\u3089\u300c\u307e\u305fAlexa\u306b\u6012\u3063\u3066\u308b\u300d\u3068\u3044\u3046\u611f\u60f3\u3092\u3044\u305f\u3060\u304d\u307e\u3057\u305f\u3002<\/p>\n<h2>\u76ee\u6b21<\/h2>\n<ul>\n<li><a href=\"#overview\">\u6982\u8981<\/a><\/li>\n<li><a href=\"#no_dialog_model\">\u5f93\u6765\u306e\u66f8\u304d\u65b9<\/a><\/li>\n<li><a href=\"#use_dialog_model\">Dialog\u30e2\u30c7\u30eb\u3092\u4f7f\u7528\u3059\u308b<\/a><\/li>\n<li><a href=\"#conclusion\">\u7d50\u8ad6<\/a><\/li>\n<\/ul>\n<h2 id=\"overview\">\u6982\u8981<\/h2>\n<p>\u30b9\u30ad\u30eb\u306e\u4e2d\u3067\u30e6\u30fc\u30b6\u304b\u3089\u60c5\u5831\u3092\u805e\u304d\u51fa\u3057\u305f\u3044\u3068\u304d\u306f\u30b9\u30ed\u30c3\u30c8\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n\u6b63\u76f4\u3001\u30b9\u30ed\u30c3\u30c8\u5024\u3092\u96c6\u3081\u308b\u51e6\u7406\u306f<del datetime=\"2018-10-04T05:14:16+00:00\">\u9762\u5012<\/del>\u5927\u5909\u3067\u3059\u3002<br \/>\n\u305d\u3053\u3067Dialog\u30e2\u30c7\u30eb\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u30b9\u30ed\u30c3\u30c8\u5024\u304c\u5165\u529b\u3055\u308c\u308b\u307e\u3067\u306e\u51e6\u7406\u3092Alexa\u306b\u304a\u307e\u304b\u305b\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2 id=\"no_dialog_model\">\u5f93\u6765\u306e\u66f8\u304d\u65b9<\/h2>\n<p>\u307e\u305a\u3001Dialog\u30e2\u30c7\u30eb\u3092\u4f7f\u308f\u306a\u3044\u30b9\u30ad\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<br \/>\n\u4eca\u56de\u306f\u3001\u30b5\u30d0\u6599\u7406\u3092\u6ce8\u6587\u3059\u308b\u30b9\u30ad\u30eb\u3092\u4f5c\u3063\u3066\u3044\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u300c\u30a2\u30ec\u30af\u30b5\u3001\u30b5\u30d0\u30b7\u30e7\u30c3\u30d7\u3067\u5473\u564c\u5473\u306e\u30b5\u30d0\u6599\u7406\u30923\u3064\u300d\u306e\u3088\u3046\u306b\u8a71\u3057\u304b\u3051\u308b\u611f\u3058\u3067\u3059\u3002<\/p>\n<h3>\u30b9\u30ed\u30c3\u30c8\u30bf\u30a4\u30d7\u306e\u8a2d\u5b9a<\/h3>\n<p>\u30b5\u30d0\u6599\u7406\u306e\u5473(Taste)\u3092\u30b9\u30ed\u30c3\u30c8\u5024\u306b\u5165\u529b\u3057\u307e\u3059\u3002<br \/>\n\u4eca\u56de\u306f<\/p>\n<ul>\n<li>\u5473\u564c<\/li>\n<li>\u91a4\u6cb9<\/li>\n<li>\u5869<\/li>\n<\/ul>\n<p>\u3092\u7528\u610f\u3057\u307e\u3057\u305f\u3002<br \/>\n<a href=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/26fffd5a875598e53bc12cc4a4f023b1.png\"><br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/26fffd5a875598e53bc12cc4a4f023b1-1024x521.png\" alt=\"\" width=\"728\" height=\"370\" class=\"aligncenter size-large wp-image-15231\" srcset=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/26fffd5a875598e53bc12cc4a4f023b1-1024x521.png 1024w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/26fffd5a875598e53bc12cc4a4f023b1-300x153.png 300w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/26fffd5a875598e53bc12cc4a4f023b1-768x390.png 768w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/26fffd5a875598e53bc12cc4a4f023b1-728x370.png 728w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/26fffd5a875598e53bc12cc4a4f023b1.png 1906w\" sizes=\"auto, (max-width: 728px) 100vw, 728px\" \/><\/a><\/p>\n<p>\u6570\u91cf\u3092\u6271\u3046\u305f\u3081<code>AMAZON.NUMBER<\/code>\u3082\u30b9\u30ed\u30c3\u30c8\u30bf\u30a4\u30d7\u306b\u8ffd\u52a0\u3057\u3066\u304a\u304d\u307e\u3059<br \/>\n<a href=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/c280799f8f5ea1c9cbc8ae041e3ff28a.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-15234\" src=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/c280799f8f5ea1c9cbc8ae041e3ff28a-1024x516.png\" alt=\"\" width=\"728\" height=\"367\" srcset=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/c280799f8f5ea1c9cbc8ae041e3ff28a-1024x516.png 1024w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/c280799f8f5ea1c9cbc8ae041e3ff28a-300x151.png 300w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/c280799f8f5ea1c9cbc8ae041e3ff28a-768x387.png 768w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/c280799f8f5ea1c9cbc8ae041e3ff28a-728x367.png 728w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/c280799f8f5ea1c9cbc8ae041e3ff28a.png 1904w\" sizes=\"auto, (max-width: 728px) 100vw, 728px\" \/><\/a><\/p>\n<h3>\u30a4\u30f3\u30c6\u30f3\u30c8\u306e\u8a2d\u5b9a<\/h3>\n<p>\u30b5\u30d0\u6599\u7406\u3092\u6ce8\u6587\u3059\u308b\u30a4\u30f3\u30c6\u30f3\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<br \/>\n\u540d\u524d\u306f<code>BuyMackerelFoodIntent<\/code>\u306b\u3057\u307e\u3057\u305f\u3002<br \/>\n<a href=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/dbd4c8b60639d77f9245cb6f78a02a59.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-15235\" src=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/dbd4c8b60639d77f9245cb6f78a02a59-1024x520.png\" alt=\"\" width=\"728\" height=\"370\" srcset=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/dbd4c8b60639d77f9245cb6f78a02a59-1024x520.png 1024w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/dbd4c8b60639d77f9245cb6f78a02a59-300x152.png 300w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/dbd4c8b60639d77f9245cb6f78a02a59-768x390.png 768w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/dbd4c8b60639d77f9245cb6f78a02a59-728x370.png 728w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/dbd4c8b60639d77f9245cb6f78a02a59.png 1905w\" sizes=\"auto, (max-width: 728px) 100vw, 728px\" \/><\/a><\/p>\n<h3>Lambda\u306e\u30b3\u30fc\u30c9<\/h3>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nconst Alexa = require('ask-sdk-core');\r\n\r\nconst LaunchRequestHandler = {\r\n    canHandle(handlerInput) {\r\n        return handlerInput.requestEnvelope.request.type === 'LaunchRequest';\r\n    },\r\n    handle(handlerInput) {\r\n        const speechOutput = '\u3044\u3089\u3063\u3057\u3083\u3044\u307e\u305b\u3002\u4f55\u3092\u6ce8\u6587\u3057\u307e\u3059\u304b?';\r\n        const reprompt = '\u5473\u564c\u5473\u3001\u91a4\u6cb9\u5473\u3001\u5869\u5473\u306a\u3069\u304c\u3042\u308a\u307e\u3059\u3002\u4f55\u3092\u6ce8\u6587\u3057\u307e\u3059\u304b?';\r\n        return handlerInput.responseBuilder\r\n            .speak(speechOutput)\r\n            .reprompt(reprompt)\r\n            .getResponse();\r\n    }\r\n};\r\n\r\nconst BuyMackerelFoodIntentHandler = {\r\n    canHandle(handlerInput) {\r\n        return  handlerInput.requestEnvelope.request.type === 'IntentRequest'\r\n            &amp;amp;&amp;amp; handlerInput.requestEnvelope.request.intent.name === 'BuyMackerelFoodIntent';\r\n    },\r\n    handle(handlerInput) {\r\n        let taste = handlerInput.requestEnvelope.request.intent.slots.taste.value;\r\n        let amount = handlerInput.requestEnvelope.request.intent.slots.amount.value;\r\n        let session = handlerInput.attributesManager.getSessionAttributes();\r\n\r\n        \/* \u5473\u3092\u6c7a\u3081\u308b *\/\r\n        if (taste === undefined &amp;amp;&amp;amp; session.taste === undefined){\r\n            return handlerInput.responseBuilder\r\n                .speak('\u4f55\u5473\u306b\u3057\u307e\u3059\u304b?')\r\n                .reprompt('\u5473\u564c\u3001\u91a4\u6cb9\u3001\u5869\u304b\u3089\u9078\u3079\u307e\u3059\u3002\u4f55\u5473\u306b\u3057\u307e\u3059\u304b?')\r\n                .getResponse();\r\n        } else {\r\n            if (taste) {\r\n                session.taste = taste;\r\n                handlerInput.attributesManager.setSessionAttributes(session);\r\n            } else {\r\n                taste = session.taste;\r\n            }\r\n        }\r\n\r\n        \/* \u500b\u6570\u3092\u6c7a\u3081\u308b *\/\r\n        if (amount === undefined &amp;amp;&amp;amp; session.amount === undefined){\r\n            return handlerInput.responseBuilder\r\n                .speak('\u3044\u304f\u3064\u306b\u3057\u307e\u3059\u304b?')\r\n                .reprompt('\u4f55\u500b\u5fc5\u8981\u3067\u3059\u304b?')\r\n                .getResponse();\r\n        } else {\r\n            if (amount) {\r\n                session.amount = amount;\r\n                handlerInput.attributesManager.setSessionAttributes(session);\r\n            } else {\r\n                amount = session.amount;\r\n            }\r\n        }\r\n\r\n        const speechOutput = `${taste}\u5473\u306e\u30b5\u30d0\u6599\u7406\u3092${amount}\u3064\u627f\u308a\u307e\u3057\u305f\u3002`;\r\n        return handlerInput.responseBuilder\r\n            .speak(speechOutput)\r\n            .getResponse();\r\n    }\r\n};\r\n\r\nconst ErrorHandler = {\r\n    canHandle () {\r\n        return true;\r\n    },\r\n    handle (handlerInput, error) {\r\n        const message = &quot;\u3059\u307f\u307e\u305b\u3093\u3001\u3046\u307e\u304f\u805e\u304d\u53d6\u308c\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u3082\u3046\u4e00\u5ea6\u8a00\u3063\u3066\u304f\u3060\u3055\u3044\u3002&quot;;\r\n        return handlerInput.responseBuilder\r\n            .speak(message)\r\n            .reprompt(message)\r\n            .getResponse()\r\n    }\r\n};\r\n\r\n\r\nconst skillBuilder = Alexa.SkillBuilders.custom();\r\nexports.handler = skillBuilder\r\n    .addRequestHandlers(\r\n        LaunchRequestHandler,\r\n        BuyMackerelFoodIntentHandler\r\n    )\r\n    .addErrorHandlers(ErrorHandler)\r\n    .lambda();\r\n<\/pre>\n<p>\u30b9\u30ed\u30c3\u30c8\u5024\u304c\u5165\u529b\u3055\u308c\u3066\u3044\u308b\u304b\u3092\u78ba\u8a8d\u3059\u308b\u51e6\u7406\u306a\u3093\u304b\u306f\u3001\u304a\u306a\u3058\u3088\u3046\u306a\u51e6\u7406\u304c\u4e26\u3093\u3067\u307e\u3059\u306d\u3002<\/p>\n<h3>\u30c6\u30b9\u30c8<\/h3>\n<p>\u3053\u3093\u306a\u611f\u3058\u3067\u30c6\u30b9\u30c8\u3057\u3066\u307f\u307e\u3059\u3002<br \/>\n<a href=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/ceb0300627e434ce2ae6ba93c0b529d5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-15236\" src=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/ceb0300627e434ce2ae6ba93c0b529d5.png\" alt=\"\" width=\"432\" height=\"809\" srcset=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/ceb0300627e434ce2ae6ba93c0b529d5.png 432w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/ceb0300627e434ce2ae6ba93c0b529d5-160x300.png 160w\" sizes=\"auto, (max-width: 432px) 100vw, 432px\" \/><\/a><\/p>\n<p>\u7121\u4e8b\u6ce8\u6587\u3067\u304d\u307e\u3057\u305f\u306d<\/p>\n<p>\u3057\u304b\u3057\u3001\u3053\u306e\u30b3\u30fc\u30c9\u3060\u3068\u30b9\u30ed\u30c3\u30c8\u5024\u304c\u5897\u3048\u308b\u3068\u305d\u306e\u5206if-else\u304c\u5897\u3048\u898b\u3065\u3089\u3044\u30b3\u30fc\u30c9\u3068\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002<br \/>\n\u6b21\u306bDialog\u30e2\u30c7\u30eb\u3092\u4f7f\u7528\u3057\u305f\u5834\u5408\u3067\u3059\u3002<\/p>\n<h2 id=\"use_dialog_model\">Dialog\u30e2\u30c7\u30eb\u3092\u4f7f\u7528\u3059\u308b<\/h2>\n<p>Dialog\u30e2\u30c7\u30eb\u3092\u4f7f\u7528\u3059\u308b\u306b\u306f\u4e00\u90e8\u8a2d\u5b9a\u3092\u6709\u52b9\u306b\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u306e\u3067\u3001\u3084\u3063\u3066\u3044\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<h3>\u30a4\u30f3\u30c6\u30f3\u30c8\u30b9\u30ed\u30c3\u30c8<\/h3>\n<p>\u3053\u3061\u3089\u306e\u753b\u9762\u304b\u3089\u30c0\u30a4\u30a2\u30ed\u30b0\u306e\u7de8\u96c6\u753b\u9762\u306b\u884c\u304d\u307e\u3059\u3002<br \/>\n<a href=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/6801396a3f28a52946a749ec71d6ce04.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-15237\" src=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/6801396a3f28a52946a749ec71d6ce04-1024x496.png\" alt=\"\" width=\"728\" height=\"353\" srcset=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/6801396a3f28a52946a749ec71d6ce04-1024x496.png 1024w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/6801396a3f28a52946a749ec71d6ce04-300x145.png 300w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/6801396a3f28a52946a749ec71d6ce04-768x372.png 768w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/6801396a3f28a52946a749ec71d6ce04-728x353.png 728w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/6801396a3f28a52946a749ec71d6ce04.png 1904w\" sizes=\"auto, (max-width: 728px) 100vw, 728px\" \/><\/a><\/p>\n<p>\u30b9\u30ed\u30c3\u30c8\u5165\u529b\u304b\u3089\u300c\u3053\u306e\u30a4\u30f3\u30c6\u30f3\u30c8\u3092\u5b8c\u4e86\u3055\u305b\u308b\u305f\u3081\u306b\u3001\u3053\u306e\u30b9\u30ed\u30c3\u30c8\u306f\u5fc5\u9808\u3067\u3059\u304b\uff1f\u300d\u3092\u6709\u52b9\u306b\u3057<br \/>\nAlexa\u304c\u3069\u306e\u3088\u3046\u306b\u5c0b\u306d\u308b\u304b\u3068\u3001\u30e6\u30fc\u30b6\u304c\u3069\u306e\u3088\u3046\u306b\u8fd4\u4e8b\u3092\u3059\u308b\u304b\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002<br \/>\n<a href=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/264a766a85b41819e87e1aa62e88755f.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-15238\" src=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/264a766a85b41819e87e1aa62e88755f-1024x494.png\" alt=\"\" width=\"728\" height=\"351\" srcset=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/264a766a85b41819e87e1aa62e88755f-1024x494.png 1024w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/264a766a85b41819e87e1aa62e88755f-300x145.png 300w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/264a766a85b41819e87e1aa62e88755f-768x371.png 768w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/264a766a85b41819e87e1aa62e88755f-728x351.png 728w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/264a766a85b41819e87e1aa62e88755f.png 1908w\" sizes=\"auto, (max-width: 728px) 100vw, 728px\" \/><\/a><\/p>\n<p>\u6570\u91cf\u3082\u540c\u69d8\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002<br \/>\n<a href=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/3e5a0f98f675d36216501ebbe6faa1bc.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-15239\" src=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/3e5a0f98f675d36216501ebbe6faa1bc-1024x494.png\" alt=\"\" width=\"728\" height=\"351\" srcset=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/3e5a0f98f675d36216501ebbe6faa1bc-1024x494.png 1024w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/3e5a0f98f675d36216501ebbe6faa1bc-300x145.png 300w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/3e5a0f98f675d36216501ebbe6faa1bc-768x371.png 768w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/3e5a0f98f675d36216501ebbe6faa1bc-728x352.png 728w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/3e5a0f98f675d36216501ebbe6faa1bc.png 1901w\" sizes=\"auto, (max-width: 728px) 100vw, 728px\" \/><\/a><\/p>\n<p>\u4eca\u307e\u3067\u30d7\u30ed\u30b0\u30e9\u30e0\u306b\u66f8\u3044\u3066\u3044\u305f\u3053\u3068\u3092\u3001Alexa\u5074\u306b\u66f8\u304f\u611f\u3058\u3067\u3059\u306d\u3002<\/p>\n<h3>Lambda\u306e\u30b3\u30fc\u30c9<\/h3>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nconst Alexa = require('ask-sdk-core');\r\n\r\nconst LaunchRequestHandler = {\r\n    canHandle(handlerInput) {\r\n        return handlerInput.requestEnvelope.request.type === 'LaunchRequest';\r\n    },\r\n    handle(handlerInput) {\r\n        const speechOutput = '\u3044\u3089\u3063\u3057\u3083\u3044\u307e\u305b\u3002\u3069\u306e\u5473\u3092\u6ce8\u6587\u3057\u307e\u3059\u304b?';\r\n        const reprompt = '\u5473\u564c\u5473\u3001\u91a4\u6cb9\u5473\u3001\u5869\u5473\u306a\u3069\u304c\u3042\u308a\u307e\u3059\u3002\u4f55\u3092\u6ce8\u6587\u3057\u307e\u3059\u304b?';\r\n        return handlerInput.responseBuilder\r\n            .speak(speechOutput)\r\n            .reprompt(reprompt)\r\n            .getResponse();\r\n    }\r\n};\r\n\r\nconst BuyMackerelFoodIntentHandler = {\r\n    canHandle(handlerInput) {\r\n        return  handlerInput.requestEnvelope.request.type === 'IntentRequest'\r\n            &amp;amp;&amp;amp; handlerInput.requestEnvelope.request.intent.name === 'BuyMackerelFoodIntent';\r\n    },\r\n    handle(handlerInput) {\r\n        let taste = handlerInput.requestEnvelope.request.intent.slots.taste.value;\r\n        let amount = handlerInput.requestEnvelope.request.intent.slots.amount.value;\r\n\r\n        let {dialogState} = handlerInput.requestEnvelope.request;\r\n\r\n        if (dialogState !== 'COMPLETED') {\r\n            return handlerInput.responseBuilder\r\n                .addDelegateDirective()\r\n                .getResponse();\r\n        } else {\r\n            const speechOutput = `${taste}\u5473\u306e\u30b5\u30d0\u6599\u7406\u3092${amount}\u3064\u627f\u308a\u307e\u3057\u305f\u3002`;\r\n            return handlerInput.responseBuilder\r\n                .speak(speechOutput)\r\n                .getResponse();\r\n        }\r\n    }\r\n};\r\n\r\nconst ErrorHandler = {\r\n    canHandle () {\r\n        return true;\r\n    },\r\n    handle (handlerInput, error) {\r\n        const message = &quot;\u3059\u307f\u307e\u305b\u3093\u3001\u3046\u307e\u304f\u805e\u304d\u53d6\u308c\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u3082\u3046\u4e00\u5ea6\u8a00\u3063\u3066\u304f\u3060\u3055\u3044\u3002&quot;;\r\n        return handlerInput.responseBuilder\r\n            .speak(message)\r\n            .reprompt(message)\r\n            .getResponse()\r\n    }\r\n};\r\n\r\n\r\nconst skillBuilder = Alexa.SkillBuilders.custom();\r\nexports.handler = skillBuilder\r\n    .addRequestHandlers(\r\n        LaunchRequestHandler,\r\n        BuyMackerelFoodIntentHandler\r\n    )\r\n    .addErrorHandlers(ErrorHandler)\r\n    .lambda();\r\n<\/pre>\n<h3>\u30c6\u30b9\u30c8<\/h3>\n<p>\u524d\u56de\u3068\u540c\u3058\u3088\u3046\u306b\u30c6\u30b9\u30c8\u3057\u307e\u3059\u3002<br \/>\n<a href=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/14a99f3699a7fb9e0cc115d5c424c5af.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-15240\" src=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/14a99f3699a7fb9e0cc115d5c424c5af.png\" alt=\"\" width=\"434\" height=\"770\" srcset=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/14a99f3699a7fb9e0cc115d5c424c5af.png 434w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2018\/10\/14a99f3699a7fb9e0cc115d5c424c5af-169x300.png 169w\" sizes=\"auto, (max-width: 434px) 100vw, 434px\" \/><\/a><\/p>\n<p>\u5909\u66f4\u524d\u3068\u540c\u3058\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f!<\/p>\n<h2 id=\"conclusion\">\u7d50\u8ad6<\/h2>\n<p>Dialog\u30e2\u30c7\u30eb\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001Alexa\u306f<code>dialogState<\/code>\u3092\u30ea\u30af\u30a8\u30b9\u30c8\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002<br \/>\n\u3053\u306e\u5024\u304c<code>COMPLETED<\/code>\u306b\u306a\u308b\u307e\u3067Alexa\u306b\u304a\u4efb\u305b\u304c\u3067\u304d\u308b\u611f\u3058\u3067\u3059\u3002<\/p>\n<p>\u30b9\u30ed\u30c3\u30c8\u304c\u5165\u529b\u3055\u308c\u305f\u304b\u3069\u3046\u304b\u306e\u51e6\u7406\u306fAlexa\u5074\u3067\u3084\u3063\u3066\u304f\u308c\u308b\u305f\u3081\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u51e6\u7406\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u305b\u3093\u3002<br \/>\n\u4eca\u307e\u3067\u81ea\u5206\u3067\u5224\u5b9a\u3057\u3066\u3044\u305f\u51e6\u7406\u3092\u6e1b\u3089\u3059\u3053\u3068\u304c\u3067\u304d\u3001\u4e0d\u5177\u5408\u306e\u539f\u56e0\u3092\u6e1b\u3089\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u30b9\u30ed\u30c3\u30c8\u306e\u6570\u304c2\u3064\u7a0b\u5ea6\u306a\u3089\u5f93\u6765\u306e\u65b9\u6cd5\u3067\u3082\u5bfe\u51e6\u3067\u304d\u305d\u3046\u3067\u3059\u304c\u30014\u3064\u3068\u304b\u306b\u306a\u308b\u3068Dialog\u30e2\u30c7\u30eb\u304c\u52b9\u679c\u7684\u306b\u306a\u308b\u3068\u601d\u3044\u307e\u3059\u3088!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u306f\u3058\u3081\u306b \u30d6\u30ed\u30b0\u521d\u6295\u7a3f\u3001\u958b\u767a\u90e8\u306e\u8fbb\u3067\u3059\u3002 \u6280\u8853\u7684\u306a\u3053\u3068\u3092\u3061\u3087\u3044\u3061\u3087\u3044\u66f8\u3044\u3066\u3044\u3051\u308c\u3070\u306a\u3041\u3068\u601d\u3063\u3066\u3044\u307e\u3059\u3002 \u6700\u8fd1Alexa\u30b9\u30ad\u30eb\u306e\u958b\u767a\u3092\u62c5\u5f53\u3057\u3066\u3044\u307e\u3059\u304c \u958b\u767a\u4e2d\u306fAmazon Echo\u3068\u4f1a\u8a71\u3092\u3059\u308b\u3053\u3068\u304c\u591a\u304f \u30c6\u30b9\u30c8\u4e2d\u306b\u306f\u3001\u96a3&#8230;<\/p>\n","protected":false},"author":1,"featured_media":15251,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"ja","_original_post":"15230","footnotes":""},"categories":[316,20,19],"tags":[334,335,102],"class_list":{"0":"post-15230","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-alexa","8":"category-aws","9":"category-19","10":"tag-alexa","11":"tag-ask-sdk","12":"tag-aws","13":"ja"},"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts\/15230","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/comments?post=15230"}],"version-history":[{"count":5,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts\/15230\/revisions"}],"predecessor-version":[{"id":15250,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts\/15230\/revisions\/15250"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/media\/15251"}],"wp:attachment":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/media?parent=15230"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/categories?post=15230"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/tags?post=15230"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}