質問編集履歴
3
解決しました
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
|
1
|
+
解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました
|
body
CHANGED
@@ -1,248 +1,1 @@
|
|
1
|
-
現在AmazonDeveloperを用いてAmazonEchoを用いた音声ショッピングを行う際の対話モデルの作成を行っています。
|
2
|
-
対話の流れは
|
3
|
-
私「アレクサ、ショッピングを開いて」
|
4
|
-
Alexa「ショッピングへようこそ、何を注文しますか?」
|
5
|
-
私「アクエリアスを三つ注文して」
|
6
|
-
Alexa「アクエリアスを三つですね。こちらの商品を注文してもよろしいでしょうか?」
|
7
|
-
私「はい」
|
8
|
-
Alexa「かしこまりました。最終確認です。アクエリアスを三つ注文してもよろしいですか?」
|
9
|
-
私「お願いします」
|
10
|
-
Alexa「注文が完了しました。到着までお待ちください」
|
11
|
-
といった対話の流れのシステムを現在作成しております。
|
12
|
-
しかし、商品と個数をスロット化して、商品名と個数は好きなように注文を受け取れるようにしたのですが、
|
13
|
-
その受け取ったスロットをもう一度リピートする方法が思い浮かばず。現在難航しております。
|
14
|
-
|
15
|
-
ソースコード
|
16
|
-
------------------------------------------------------------------------------------------------------
|
17
|
-
// This sample demonstrates handling intents from an Alexa skill using the Alexa Skills Kit SDK (v2).
|
18
|
-
|
1
|
+
解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました
|
19
|
-
// session persistence, api calls, and more.
|
20
|
-
//SDKライブラリを読み込む
|
21
|
-
const Alexa = require('ask-sdk-core');
|
22
|
-
|
23
|
-
const LaunchRequestHandler = {
|
24
|
-
canHandle(handlerInput) {
|
25
|
-
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'LaunchRequest';
|
26
|
-
},
|
27
|
-
handle(handlerInput) {
|
28
|
-
const speechText = 'エイチユーエスショッピングへようこそ、何を注文しますか?';
|
29
|
-
const reprompt = 'ご注文をお願いします。'; //しばらく待っても応答が無かったら言わせるときの発話
|
30
|
-
return handlerInput.responseBuilder
|
31
|
-
.speak(speechText)
|
32
|
-
.reprompt(reprompt)
|
33
|
-
.getResponse();
|
34
|
-
}
|
35
|
-
};
|
36
|
-
|
37
|
-
|
38
|
-
const OrderIntentHandler = {
|
39
|
-
canHandle(handlerInput) {
|
40
|
-
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
|
41
|
-
&& Alexa.getIntentName(handlerInput.requestEnvelope) === 'OrderIntent';
|
42
|
-
},
|
43
|
-
handle(handlerInput) {
|
44
|
-
|
45
|
-
const attributes = handlerInput.attributesManager.getSessionAttributes();
|
46
|
-
const slots = handlerInput.requestEnvelope.request.intent.slots;
|
47
|
-
let menu = slots.menu.value || attributes.menu;
|
48
|
-
let amount = slots.amount.value || attributes.amount;
|
49
|
-
|
50
|
-
|
51
|
-
//if(slots.menu.resolutions.resolutionsPerAuthority[0].status.code === "ER_SUCCESS_MATCH"){
|
52
|
-
// menu = slots.menu.resolutions.resolutionsPerAuthority[0].values[0].value.name;
|
53
|
-
// }
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
if(menu === undefined){
|
59
|
-
attributes.amount = amount;
|
60
|
-
handlerInput.attributesManager.setSessionAttributes(attributes);
|
61
|
-
const speechOutput = '何を注文しますか?';
|
62
|
-
const reprompt = '何を注文しますか?';
|
63
|
-
return handlerInput.responseBuilder
|
64
|
-
.speak(speechOutput)
|
65
|
-
.reprompt(reprompt)
|
66
|
-
.getResponse();
|
67
|
-
}
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
if(amount === undefined){
|
72
|
-
attributes.menu = menu;
|
73
|
-
handlerInput.attributesManager.setSessionAttributes(attributes);
|
74
|
-
const speechOutput = 'おいくつ注文しますか?';
|
75
|
-
const reprompt = 'おいくつ注文しますか?';
|
76
|
-
return handlerInput.responseBuilder
|
77
|
-
.speak(speechOutput)
|
78
|
-
.reprompt(reprompt)
|
79
|
-
.getResponse();
|
80
|
-
}
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
const speakOutput = `${menu}を${amount}つですね。こちらの商品を注文してもよろしいでしょうか`;
|
85
|
-
const reprompt=`${menu}を${amount}つですね。こちらの商品を注文してもよろしいでしょうか`;
|
86
|
-
return handlerInput.responseBuilder
|
87
|
-
.speak(speakOutput)
|
88
|
-
.reprompt(reprompt)
|
89
|
-
.getResponse();
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
}
|
97
|
-
};
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
const YesIntentHandler = {
|
102
|
-
canHandle(handlerInput) {
|
103
|
-
return handlerInput.requestEnvelope.request.type === 'IntentRequest'
|
104
|
-
&& handlerInput.requestEnvelope.request.intent.name === 'AMAZON.YesIntent';
|
105
|
-
},
|
106
|
-
handle(handlerInput) {
|
107
|
-
|
108
|
-
|
109
|
-
const speakOutput = "かしこまりました。最終確認です。商品を本当に注文してよろしいでしょうか。";
|
110
|
-
const reprompt = '最終確認です。商品を注文してよろしいでしょうか。';
|
111
|
-
return handlerInput.responseBuilder
|
112
|
-
.speak(speakOutput)
|
113
|
-
.reprompt(reprompt)
|
114
|
-
.getResponse();
|
115
|
-
},
|
116
|
-
};
|
117
|
-
|
118
|
-
|
119
|
-
const AnswerIntentHandler = {
|
120
|
-
canHandle(handlerInput) {
|
121
|
-
return handlerInput.requestEnvelope.request.type === 'IntentRequest'
|
122
|
-
&& handlerInput.requestEnvelope.request.intent.name === 'AnswerIntent';
|
123
|
-
},
|
124
|
-
handle(handlerInput) {
|
125
|
-
|
126
|
-
const speakOutput = "注文が完了しました。商品到着までお待ちください。";
|
127
|
-
return handlerInput.responseBuilder
|
128
|
-
.speak(speakOutput)
|
129
|
-
.getResponse();
|
130
|
-
},
|
131
|
-
};
|
132
|
-
|
133
|
-
const NoIntentHandler = {
|
134
|
-
canHandle(handlerInput) {
|
135
|
-
return handlerInput.requestEnvelope.request.type === 'IntentRequest'
|
136
|
-
&& handlerInput.requestEnvelope.request.intent.name === 'AMAZON.NoIntent';
|
137
|
-
},
|
138
|
-
handle(handlerInput) {
|
139
|
-
|
140
|
-
const speakOutput = "かしこまりました。最初からやり直してください。";
|
141
|
-
return handlerInput.responseBuilder
|
142
|
-
.speak(speakOutput)
|
143
|
-
.getResponse();
|
144
|
-
},
|
145
|
-
};
|
146
|
-
|
147
|
-
const HelpIntentHandler = {
|
148
|
-
canHandle(handlerInput) {
|
149
|
-
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
|
150
|
-
&& Alexa.getIntentName(handlerInput.requestEnvelope) === 'AMAZON.HelpIntent';
|
151
|
-
},
|
152
|
-
handle(handlerInput) {
|
153
|
-
const speakOutput = 'お助けします。何かお困りですか?'; //ヘルプと言われたらここの文が読まれる
|
154
|
-
const reprompt = 'ご注文をお願いします。'; //しばらく待っても応答が無かったら言わせるときの発話
|
155
|
-
return handlerInput.responseBuilder
|
156
|
-
.speak(speakOutput)
|
157
|
-
.reprompt(reprompt)
|
158
|
-
.getResponse();
|
159
|
-
}
|
160
|
-
};
|
161
|
-
const CancelAndStopIntentHandler = {
|
162
|
-
canHandle(handlerInput) {
|
163
|
-
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
|
164
|
-
&& (Alexa.getIntentName(handlerInput.requestEnvelope) === 'AMAZON.CancelIntent'
|
165
|
-
|| Alexa.getIntentName(handlerInput.requestEnvelope) === 'AMAZON.StopIntent');
|
166
|
-
},
|
167
|
-
handle(handlerInput) {
|
168
|
-
const speakOutput = 'またの注文ををお待ちしております。'; //ストップと言った行ったときに読まれる」
|
169
|
-
return handlerInput.responseBuilder
|
170
|
-
.speak(speakOutput)
|
171
|
-
.getResponse();
|
172
|
-
}
|
173
|
-
};
|
174
|
-
const SessionEndedRequestHandler = {
|
175
|
-
canHandle(handlerInput) {
|
176
|
-
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'SessionEndedRequest';
|
177
|
-
},
|
178
|
-
handle(handlerInput) {
|
179
|
-
// Any cleanup logic goes here.
|
180
|
-
return handlerInput.responseBuilder.getResponse();
|
181
|
-
}
|
182
|
-
};
|
183
|
-
|
184
|
-
// The intent reflector is used for interaction model testing and debugging.
|
185
|
-
// It will simply repeat the intent the user said. You can create custom handlers
|
186
|
-
// for your intents by defining them above, then also adding them to the request
|
187
|
-
// handler chain below.
|
188
|
-
const IntentReflectorHandler = { //モデルで使用したインテントが無い場合ここに来る
|
189
|
-
canHandle(handlerInput) {
|
190
|
-
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest';
|
191
|
-
},
|
192
|
-
handle(handlerInput) {
|
193
|
-
const intentName = Alexa.getIntentName(handlerInput.requestEnvelope);
|
194
|
-
const speakOutput = `${intentName}というインテントが呼ばれました`;
|
195
|
-
|
196
|
-
return handlerInput.responseBuilder
|
197
|
-
.speak(speakOutput)
|
198
|
-
//.reprompt('add a reprompt if you want to keep the session open for the user to respond')
|
199
|
-
.getResponse();
|
200
|
-
}
|
201
|
-
};
|
202
|
-
|
203
|
-
// Generic error handling to capture any syntax or routing errors. If you receive an error
|
204
|
-
// stating the request handler chain is not found, you have not implemented a handler for
|
205
|
-
// the intent being invoked or included it in the skill builder below.
|
206
|
-
const ErrorHandler = { //エラーが起きるとここに落ちる
|
207
|
-
canHandle() {
|
208
|
-
return true;
|
209
|
-
},
|
210
|
-
handle(handlerInput, error) {
|
211
|
-
console.log(`~~~~ Error handled: ${error.stack}`);
|
212
|
-
const speakOutput = `すみません。もう一度言ってください。`;
|
213
|
-
|
214
|
-
return handlerInput.responseBuilder
|
215
|
-
.speak(speakOutput)
|
216
|
-
.reprompt(speakOutput)
|
217
|
-
.getResponse();
|
218
|
-
}
|
219
|
-
};
|
220
|
-
|
221
|
-
// The SkillBuilder acts as the entry point for your skill, routing all request and response
|
222
|
-
// payloads to the handlers above. Make sure any new handlers or interceptors you've
|
223
|
-
// defined are included below. The order matters - they're processed top to bottom.
|
224
|
-
exports.handler = Alexa.SkillBuilders.custom()
|
225
|
-
.addRequestHandlers(
|
226
|
-
LaunchRequestHandler,
|
227
|
-
OrderIntentHandler,
|
228
|
-
YesIntentHandler,
|
229
|
-
AnswerIntentHandler,
|
230
|
-
NoIntentHandler,
|
231
|
-
HelpIntentHandler,
|
232
|
-
CancelAndStopIntentHandler,
|
233
|
-
SessionEndedRequestHandler,
|
234
|
-
IntentReflectorHandler, // make sure IntentReflectorHandler is last so it doesn't override your custom intent handlers
|
235
|
-
)
|
236
|
-
.addErrorHandlers(
|
237
|
-
ErrorHandler,
|
238
|
-
)
|
239
|
-
.lambda();
|
240
|
-
|
241
|
-
|
242
|
-
-----------------------------------------------------------------------------------------------------
|
243
|
-
どうすれば、自分が言ったスロットをリピートして注文の再確認を行う対話ができるか現在考えております。
|
244
|
-
言語はNode.jsを用いております。
|
245
|
-
少しでも力を貸していただければ幸いです。
|
246
|
-
宜しくお願い致します。
|
247
|
-
|
248
|
-
わからないことや質問があればいつでもコメントしていただければすぐにお返事致します。
|
2
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -4,9 +4,9 @@
|
|
4
4
|
Alexa「ショッピングへようこそ、何を注文しますか?」
|
5
5
|
私「アクエリアスを三つ注文して」
|
6
6
|
Alexa「アクエリアスを三つですね。こちらの商品を注文してもよろしいでしょうか?」
|
7
|
-
私「
|
7
|
+
私「はい」
|
8
8
|
Alexa「かしこまりました。最終確認です。アクエリアスを三つ注文してもよろしいですか?」
|
9
|
-
私「
|
9
|
+
私「お願いします」
|
10
10
|
Alexa「注文が完了しました。到着までお待ちください」
|
11
11
|
といった対話の流れのシステムを現在作成しております。
|
12
12
|
しかし、商品と個数をスロット化して、商品名と個数は好きなように注文を受け取れるようにしたのですが、
|
@@ -25,7 +25,7 @@
|
|
25
25
|
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'LaunchRequest';
|
26
26
|
},
|
27
27
|
handle(handlerInput) {
|
28
|
-
const speechText = '
|
28
|
+
const speechText = 'エイチユーエスショッピングへようこそ、何を注文しますか?';
|
29
29
|
const reprompt = 'ご注文をお願いします。'; //しばらく待っても応答が無かったら言わせるときの発話
|
30
30
|
return handlerInput.responseBuilder
|
31
31
|
.speak(speechText)
|
@@ -105,13 +105,31 @@
|
|
105
105
|
},
|
106
106
|
handle(handlerInput) {
|
107
107
|
|
108
|
+
|
108
|
-
const speakOutput = "かしこまりました。最終確認です。
|
109
|
+
const speakOutput = "かしこまりました。最終確認です。商品を本当に注文してよろしいでしょうか。";
|
110
|
+
const reprompt = '最終確認です。商品を注文してよろしいでしょうか。';
|
109
111
|
return handlerInput.responseBuilder
|
110
112
|
.speak(speakOutput)
|
113
|
+
.reprompt(reprompt)
|
111
114
|
.getResponse();
|
112
115
|
},
|
113
116
|
};
|
114
117
|
|
118
|
+
|
119
|
+
const AnswerIntentHandler = {
|
120
|
+
canHandle(handlerInput) {
|
121
|
+
return handlerInput.requestEnvelope.request.type === 'IntentRequest'
|
122
|
+
&& handlerInput.requestEnvelope.request.intent.name === 'AnswerIntent';
|
123
|
+
},
|
124
|
+
handle(handlerInput) {
|
125
|
+
|
126
|
+
const speakOutput = "注文が完了しました。商品到着までお待ちください。";
|
127
|
+
return handlerInput.responseBuilder
|
128
|
+
.speak(speakOutput)
|
129
|
+
.getResponse();
|
130
|
+
},
|
131
|
+
};
|
132
|
+
|
115
133
|
const NoIntentHandler = {
|
116
134
|
canHandle(handlerInput) {
|
117
135
|
return handlerInput.requestEnvelope.request.type === 'IntentRequest'
|
@@ -208,6 +226,7 @@
|
|
208
226
|
LaunchRequestHandler,
|
209
227
|
OrderIntentHandler,
|
210
228
|
YesIntentHandler,
|
229
|
+
AnswerIntentHandler,
|
211
230
|
NoIntentHandler,
|
212
231
|
HelpIntentHandler,
|
213
232
|
CancelAndStopIntentHandler,
|
@@ -219,6 +238,7 @@
|
|
219
238
|
)
|
220
239
|
.lambda();
|
221
240
|
|
241
|
+
|
222
242
|
-----------------------------------------------------------------------------------------------------
|
223
243
|
どうすれば、自分が言ったスロットをリピートして注文の再確認を行う対話ができるか現在考えております。
|
224
244
|
言語はNode.jsを用いております。
|
1
ソースコードの変更
title
CHANGED
File without changes
|
body
CHANGED
@@ -25,7 +25,7 @@
|
|
25
25
|
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'LaunchRequest';
|
26
26
|
},
|
27
27
|
handle(handlerInput) {
|
28
|
-
const speechText = 'ショッピングへようこそ、何を注文しますか?';
|
28
|
+
const speechText = 'husショッピングへようこそ、何を注文しますか?';
|
29
29
|
const reprompt = 'ご注文をお願いします。'; //しばらく待っても応答が無かったら言わせるときの発話
|
30
30
|
return handlerInput.responseBuilder
|
31
31
|
.speak(speechText)
|
@@ -88,24 +88,43 @@
|
|
88
88
|
.reprompt(reprompt)
|
89
89
|
.getResponse();
|
90
90
|
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
91
96
|
}
|
92
97
|
};
|
93
98
|
|
94
99
|
|
100
|
+
|
95
|
-
const
|
101
|
+
const YesIntentHandler = {
|
96
102
|
canHandle(handlerInput) {
|
97
103
|
return handlerInput.requestEnvelope.request.type === 'IntentRequest'
|
98
|
-
&& handlerInput.requestEnvelope.request.intent.name === '
|
104
|
+
&& handlerInput.requestEnvelope.request.intent.name === 'AMAZON.YesIntent';
|
99
105
|
},
|
100
106
|
handle(handlerInput) {
|
101
107
|
|
102
|
-
const speakOutput = "かしこまりました。最終確認です。○○を注文してもよろしいですか?";
|
108
|
+
const speakOutput = "かしこまりました。最終確認です。○○を注文してもよろしいですか?";
|
103
109
|
return handlerInput.responseBuilder
|
104
110
|
.speak(speakOutput)
|
105
111
|
.getResponse();
|
106
112
|
},
|
107
113
|
};
|
108
114
|
|
115
|
+
const NoIntentHandler = {
|
116
|
+
canHandle(handlerInput) {
|
117
|
+
return handlerInput.requestEnvelope.request.type === 'IntentRequest'
|
118
|
+
&& handlerInput.requestEnvelope.request.intent.name === 'AMAZON.NoIntent';
|
119
|
+
},
|
120
|
+
handle(handlerInput) {
|
121
|
+
|
122
|
+
const speakOutput = "かしこまりました。最初からやり直してください。";
|
123
|
+
return handlerInput.responseBuilder
|
124
|
+
.speak(speakOutput)
|
125
|
+
.getResponse();
|
126
|
+
},
|
127
|
+
};
|
109
128
|
|
110
129
|
const HelpIntentHandler = {
|
111
130
|
canHandle(handlerInput) {
|
@@ -188,7 +207,8 @@
|
|
188
207
|
.addRequestHandlers(
|
189
208
|
LaunchRequestHandler,
|
190
209
|
OrderIntentHandler,
|
191
|
-
|
210
|
+
YesIntentHandler,
|
211
|
+
NoIntentHandler,
|
192
212
|
HelpIntentHandler,
|
193
213
|
CancelAndStopIntentHandler,
|
194
214
|
SessionEndedRequestHandler,
|
@@ -199,7 +219,6 @@
|
|
199
219
|
)
|
200
220
|
.lambda();
|
201
221
|
|
202
|
-
|
203
222
|
-----------------------------------------------------------------------------------------------------
|
204
223
|
どうすれば、自分が言ったスロットをリピートして注文の再確認を行う対話ができるか現在考えております。
|
205
224
|
言語はNode.jsを用いております。
|