質問編集履歴

3

解決しました

2019/09/02 10:05

投稿

退会済みユーザー
test CHANGED
@@ -1 +1 @@
1
- AmazonEchoを用い対話システムの対話リピート機能の実装
1
+ 解決しまし解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました
test CHANGED
@@ -1,495 +1 @@
1
- 現在AmazonDeveloperを用いてAmazonEchoを用いた音声ショッピングを行う際の対話モデルの作成を行っています。
2
-
3
- 対話の流れは
4
-
5
- 私「アレクサ、ショッピングを開いて」
6
-
7
- Alexa「ショッピングへようこそ、何を注文しますか?」
8
-
9
- 私「アクエリアスを三つ注文して」
10
-
11
- Alexa「アクエリアスを三つですね。こちらの商品を注文してもよろしいでしょうか?」
12
-
13
- 私「はい」
14
-
15
- Alexa「かしこまりました。最終確認です。アクエリアスを三つ注文してもよろしいですか?」
16
-
17
- 私「お願いします」
18
-
19
- Alexa「注文が完了しました。到着までお待ちください」
20
-
21
- といった対話の流れのシステムを現在作成しております。
22
-
23
- しかし、商品と個数をスロット化して、商品名と個数は好きなように注文を受け取れるようにしたのですが、
24
-
25
- その受け取ったスロットをもう一度リピートする方法が思い浮かばず。現在難航しております。
26
-
27
-
28
-
29
- ソースコード
30
-
31
- ------------------------------------------------------------------------------------------------------
32
-
33
- // This sample demonstrates handling intents from an Alexa skill using the Alexa Skills Kit SDK (v2).
34
-
35
- // Please visit https://alexa.design/cookbook for additional examples on implementing slots, dialog management,
1
+ 解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました解決しました
36
-
37
- // session persistence, api calls, and more.  
38
-
39
- //SDKライブラリを読み込む
40
-
41
- const Alexa = require('ask-sdk-core');
42
-
43
-
44
-
45
- const LaunchRequestHandler = {
46
-
47
- canHandle(handlerInput) {
48
-
49
- return Alexa.getRequestType(handlerInput.requestEnvelope) === 'LaunchRequest';
50
-
51
- },
52
-
53
- handle(handlerInput) {
54
-
55
- const speechText = 'エイチユーエスショッピングへようこそ、何を注文しますか?';
56
-
57
- const reprompt = 'ご注文をお願いします。'; //しばらく待っても応答が無かったら言わせるときの発話
58
-
59
- return handlerInput.responseBuilder
60
-
61
- .speak(speechText)
62
-
63
- .reprompt(reprompt)
64
-
65
- .getResponse();
66
-
67
- }
68
-
69
- };
70
-
71
-
72
-
73
-
74
-
75
- const OrderIntentHandler = {
76
-
77
- canHandle(handlerInput) {
78
-
79
- return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
80
-
81
- && Alexa.getIntentName(handlerInput.requestEnvelope) === 'OrderIntent';
82
-
83
- },
84
-
85
- handle(handlerInput) {
86
-
87
-
88
-
89
- const attributes = handlerInput.attributesManager.getSessionAttributes();
90
-
91
- const slots = handlerInput.requestEnvelope.request.intent.slots;
92
-
93
- let menu = slots.menu.value || attributes.menu;
94
-
95
- let amount = slots.amount.value || attributes.amount;
96
-
97
-
98
-
99
-
100
-
101
- //if(slots.menu.resolutions.resolutionsPerAuthority[0].status.code === "ER_SUCCESS_MATCH"){
102
-
103
- // menu = slots.menu.resolutions.resolutionsPerAuthority[0].values[0].value.name;
104
-
105
- // }
106
-
107
-
108
-
109
-
110
-
111
-
112
-
113
-
114
-
115
- if(menu === undefined){
116
-
117
- attributes.amount = amount;
118
-
119
- handlerInput.attributesManager.setSessionAttributes(attributes);
120
-
121
- const speechOutput = '何を注文しますか?';
122
-
123
- const reprompt = '何を注文しますか?';
124
-
125
- return handlerInput.responseBuilder
126
-
127
- .speak(speechOutput)
128
-
129
- .reprompt(reprompt)
130
-
131
- .getResponse();
132
-
133
- }
134
-
135
-
136
-
137
-
138
-
139
-
140
-
141
- if(amount === undefined){
142
-
143
- attributes.menu = menu;
144
-
145
- handlerInput.attributesManager.setSessionAttributes(attributes);
146
-
147
- const speechOutput = 'おいくつ注文しますか?';
148
-
149
- const reprompt = 'おいくつ注文しますか?';
150
-
151
- return handlerInput.responseBuilder
152
-
153
- .speak(speechOutput)
154
-
155
- .reprompt(reprompt)
156
-
157
- .getResponse();
158
-
159
- }
160
-
161
-
162
-
163
-
164
-
165
-
166
-
167
- const speakOutput = `${menu}を${amount}つですね。こちらの商品を注文してもよろしいでしょうか`;
168
-
169
- const reprompt=`${menu}を${amount}つですね。こちらの商品を注文してもよろしいでしょうか`;
170
-
171
- return handlerInput.responseBuilder
172
-
173
- .speak(speakOutput)
174
-
175
- .reprompt(reprompt)
176
-
177
- .getResponse();
178
-
179
-
180
-
181
-
182
-
183
-
184
-
185
-
186
-
187
-
188
-
189
-
190
-
191
- }
192
-
193
- };
194
-
195
-
196
-
197
-
198
-
199
-
200
-
201
- const YesIntentHandler = {
202
-
203
- canHandle(handlerInput) {
204
-
205
- return handlerInput.requestEnvelope.request.type === 'IntentRequest'
206
-
207
- && handlerInput.requestEnvelope.request.intent.name === 'AMAZON.YesIntent';
208
-
209
- },
210
-
211
- handle(handlerInput) {
212
-
213
-
214
-
215
-
216
-
217
- const speakOutput = "かしこまりました。最終確認です。商品を本当に注文してよろしいでしょうか。";
218
-
219
- const reprompt = '最終確認です。商品を注文してよろしいでしょうか。';
220
-
221
- return handlerInput.responseBuilder
222
-
223
- .speak(speakOutput)
224
-
225
- .reprompt(reprompt)
226
-
227
- .getResponse();
228
-
229
- },
230
-
231
- };
232
-
233
-
234
-
235
-
236
-
237
- const AnswerIntentHandler = {
238
-
239
- canHandle(handlerInput) {
240
-
241
- return handlerInput.requestEnvelope.request.type === 'IntentRequest'
242
-
243
- && handlerInput.requestEnvelope.request.intent.name === 'AnswerIntent';
244
-
245
- },
246
-
247
- handle(handlerInput) {
248
-
249
-
250
-
251
- const speakOutput = "注文が完了しました。商品到着までお待ちください。";
252
-
253
- return handlerInput.responseBuilder
254
-
255
- .speak(speakOutput)
256
-
257
- .getResponse();
258
-
259
- },
260
-
261
- };
262
-
263
-
264
-
265
- const NoIntentHandler = {
266
-
267
- canHandle(handlerInput) {
268
-
269
- return handlerInput.requestEnvelope.request.type === 'IntentRequest'
270
-
271
- && handlerInput.requestEnvelope.request.intent.name === 'AMAZON.NoIntent';
272
-
273
- },
274
-
275
- handle(handlerInput) {
276
-
277
-
278
-
279
- const speakOutput = "かしこまりました。最初からやり直してください。";
280
-
281
- return handlerInput.responseBuilder
282
-
283
- .speak(speakOutput)
284
-
285
- .getResponse();
286
-
287
- },
288
-
289
- };
290
-
291
-
292
-
293
- const HelpIntentHandler = {
294
-
295
- canHandle(handlerInput) {
296
-
297
- return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
298
-
299
- && Alexa.getIntentName(handlerInput.requestEnvelope) === 'AMAZON.HelpIntent';
300
-
301
- },
302
-
303
- handle(handlerInput) {
304
-
305
- const speakOutput = 'お助けします。何かお困りですか?'; //ヘルプと言われたらここの文が読まれる
306
-
307
-      const reprompt = 'ご注文をお願いします。';    //しばらく待っても応答が無かったら言わせるときの発話
308
-
309
- return handlerInput.responseBuilder
310
-
311
- .speak(speakOutput)
312
-
313
- .reprompt(reprompt)
314
-
315
- .getResponse();
316
-
317
- }
318
-
319
- };
320
-
321
- const CancelAndStopIntentHandler = {
322
-
323
- canHandle(handlerInput) {
324
-
325
- return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
326
-
327
- && (Alexa.getIntentName(handlerInput.requestEnvelope) === 'AMAZON.CancelIntent'
328
-
329
- || Alexa.getIntentName(handlerInput.requestEnvelope) === 'AMAZON.StopIntent');
330
-
331
- },
332
-
333
- handle(handlerInput) {
334
-
335
- const speakOutput = 'またの注文ををお待ちしております。'; //ストップと言った行ったときに読まれる」
336
-
337
- return handlerInput.responseBuilder
338
-
339
- .speak(speakOutput)
340
-
341
- .getResponse();
342
-
343
- }
344
-
345
- };
346
-
347
- const SessionEndedRequestHandler = {
348
-
349
- canHandle(handlerInput) {
350
-
351
- return Alexa.getRequestType(handlerInput.requestEnvelope) === 'SessionEndedRequest';
352
-
353
- },
354
-
355
- handle(handlerInput) {
356
-
357
- // Any cleanup logic goes here.
358
-
359
- return handlerInput.responseBuilder.getResponse();
360
-
361
- }
362
-
363
- };
364
-
365
-
366
-
367
- // The intent reflector is used for interaction model testing and debugging.
368
-
369
- // It will simply repeat the intent the user said. You can create custom handlers
370
-
371
- // for your intents by defining them above, then also adding them to the request
372
-
373
- // handler chain below.
374
-
375
- const IntentReflectorHandler = {   //モデルで使用したインテントが無い場合ここに来る
376
-
377
- canHandle(handlerInput) {
378
-
379
- return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest';
380
-
381
- },
382
-
383
- handle(handlerInput) {
384
-
385
- const intentName = Alexa.getIntentName(handlerInput.requestEnvelope);
386
-
387
- const speakOutput = `${intentName}というインテントが呼ばれました`;
388
-
389
-
390
-
391
- return handlerInput.responseBuilder
392
-
393
- .speak(speakOutput)
394
-
395
- //.reprompt('add a reprompt if you want to keep the session open for the user to respond')
396
-
397
- .getResponse();
398
-
399
- }
400
-
401
- };
402
-
403
-
404
-
405
- // Generic error handling to capture any syntax or routing errors. If you receive an error
406
-
407
- // stating the request handler chain is not found, you have not implemented a handler for
408
-
409
- // the intent being invoked or included it in the skill builder below.
410
-
411
- const ErrorHandler = {   //エラーが起きるとここに落ちる
412
-
413
- canHandle() {
414
-
415
- return true;
416
-
417
- },
418
-
419
- handle(handlerInput, error) {
420
-
421
- console.log(`~~~~ Error handled: ${error.stack}`);
422
-
423
- const speakOutput = `すみません。もう一度言ってください。`;
424
-
425
-
426
-
427
- return handlerInput.responseBuilder
428
-
429
- .speak(speakOutput)
430
-
431
- .reprompt(speakOutput)
432
-
433
- .getResponse();
434
-
435
- }
436
-
437
- };
438
-
439
-
440
-
441
- // The SkillBuilder acts as the entry point for your skill, routing all request and response
442
-
443
- // payloads to the handlers above. Make sure any new handlers or interceptors you've
444
-
445
- // defined are included below. The order matters - they're processed top to bottom.
446
-
447
- exports.handler = Alexa.SkillBuilders.custom()
448
-
449
- .addRequestHandlers(
450
-
451
- LaunchRequestHandler,
452
-
453
- OrderIntentHandler,
454
-
455
- YesIntentHandler,
456
-
457
- AnswerIntentHandler,
458
-
459
- NoIntentHandler,
460
-
461
- HelpIntentHandler,
462
-
463
- CancelAndStopIntentHandler,
464
-
465
- SessionEndedRequestHandler,
466
-
467
- IntentReflectorHandler, // make sure IntentReflectorHandler is last so it doesn't override your custom intent handlers
468
-
469
- )
470
-
471
- .addErrorHandlers(
472
-
473
- ErrorHandler,
474
-
475
- )
476
-
477
- .lambda();
478
-
479
-
480
-
481
-
482
-
483
- -----------------------------------------------------------------------------------------------------
484
-
485
- どうすれば、自分が言ったスロットをリピートして注文の再確認を行う対話ができるか現在考えております。
486
-
487
- 言語はNode.jsを用いております。
488
-
489
- 少しでも力を貸していただければ幸いです。
490
-
491
- 宜しくお願い致します。
492
-
493
-
494
-
495
- わからないことや質問があればいつでもコメントしていただければすぐにお返事致します。

2

修正

2019/09/02 10:05

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -10,11 +10,11 @@
10
10
 
11
11
  Alexa「アクエリアスを三つですね。こちらの商品を注文してもよろしいでしょうか?」
12
12
 
13
- 私「大丈夫です。
13
+ 私「はい
14
14
 
15
15
  Alexa「かしこまりました。最終確認です。アクエリアスを三つ注文してもよろしいですか?」
16
16
 
17
- 私「最終確認しました。
17
+ 私「お願いしま
18
18
 
19
19
  Alexa「注文が完了しました。到着までお待ちください」
20
20
 
@@ -52,7 +52,7 @@
52
52
 
53
53
  handle(handlerInput) {
54
54
 
55
- const speechText = 'husショッピングへようこそ、何を注文しますか?';
55
+ const speechText = 'エイチユーエスショッピングへようこそ、何を注文しますか?';
56
56
 
57
57
  const reprompt = 'ご注文をお願いします。'; //しばらく待っても応答が無かったら言わせるときの発話
58
58
 
@@ -212,7 +212,43 @@
212
212
 
213
213
 
214
214
 
215
+
216
+
215
- const speakOutput = "かしこまりました。最終確認です。○○を注文してよろしいで";
217
+ const speakOutput = "かしこまりました。最終確認です。商品本当に注文してよろしいでしょう";
218
+
219
+ const reprompt = '最終確認です。商品を注文してよろしいでしょうか。';
220
+
221
+ return handlerInput.responseBuilder
222
+
223
+ .speak(speakOutput)
224
+
225
+ .reprompt(reprompt)
226
+
227
+ .getResponse();
228
+
229
+ },
230
+
231
+ };
232
+
233
+
234
+
235
+
236
+
237
+ const AnswerIntentHandler = {
238
+
239
+ canHandle(handlerInput) {
240
+
241
+ return handlerInput.requestEnvelope.request.type === 'IntentRequest'
242
+
243
+ && handlerInput.requestEnvelope.request.intent.name === 'AnswerIntent';
244
+
245
+ },
246
+
247
+ handle(handlerInput) {
248
+
249
+
250
+
251
+ const speakOutput = "注文が完了しました。商品到着までお待ちください。";
216
252
 
217
253
  return handlerInput.responseBuilder
218
254
 
@@ -418,6 +454,8 @@
418
454
 
419
455
  YesIntentHandler,
420
456
 
457
+ AnswerIntentHandler,
458
+
421
459
  NoIntentHandler,
422
460
 
423
461
  HelpIntentHandler,
@@ -440,6 +478,8 @@
440
478
 
441
479
 
442
480
 
481
+
482
+
443
483
  -----------------------------------------------------------------------------------------------------
444
484
 
445
485
  どうすれば、自分が言ったスロットをリピートして注文の再確認を行う対話ができるか現在考えております。

1

ソースコードの変更

2019/08/29 14:33

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -52,7 +52,7 @@
52
52
 
53
53
  handle(handlerInput) {
54
54
 
55
- const speechText = 'ショッピングへようこそ、何を注文しますか?';
55
+ const speechText = 'husショッピングへようこそ、何を注文しますか?';
56
56
 
57
57
  const reprompt = 'ご注文をお願いします。'; //しばらく待っても応答が無かったら言わせるときの発話
58
58
 
@@ -178,41 +178,79 @@
178
178
 
179
179
 
180
180
 
181
+
182
+
183
+
184
+
185
+
186
+
187
+
188
+
189
+
190
+
181
- }
191
+ }
182
-
192
+
183
- };
193
+ };
184
-
185
-
186
-
187
-
188
-
194
+
195
+
196
+
197
+
198
+
199
+
200
+
189
- const AnswerIntentHandler = {
201
+ const YesIntentHandler = {
190
202
 
191
203
  canHandle(handlerInput) {
192
204
 
193
205
  return handlerInput.requestEnvelope.request.type === 'IntentRequest'
194
206
 
195
- && handlerInput.requestEnvelope.request.intent.name === 'AnswerIntent';
207
+ && handlerInput.requestEnvelope.request.intent.name === 'AMAZON.YesIntent';
196
-
208
+
197
- },
209
+ },
198
-
210
+
199
- handle(handlerInput) {
211
+ handle(handlerInput) {
200
-
201
-
202
-
212
+
213
+
214
+
203
- const speakOutput = "かしこまりました。最終確認です。○○を注文してもよろしいですか?"; //ここの〇〇の部分に商品名と個数を入れたい
215
+ const speakOutput = "かしこまりました。最終確認です。○○を注文してもよろしいですか?";
204
-
216
+
205
- return handlerInput.responseBuilder
217
+ return handlerInput.responseBuilder
206
-
218
+
207
- .speak(speakOutput)
219
+ .speak(speakOutput)
208
-
220
+
209
- .getResponse();
221
+ .getResponse();
210
-
222
+
211
- },
223
+ },
212
-
224
+
213
- };
225
+ };
226
+
227
+
228
+
214
-
229
+ const NoIntentHandler = {
230
+
215
-
231
+ canHandle(handlerInput) {
232
+
233
+ return handlerInput.requestEnvelope.request.type === 'IntentRequest'
234
+
235
+ && handlerInput.requestEnvelope.request.intent.name === 'AMAZON.NoIntent';
236
+
237
+ },
238
+
239
+ handle(handlerInput) {
240
+
241
+
242
+
243
+ const speakOutput = "かしこまりました。最初からやり直してください。";
244
+
245
+ return handlerInput.responseBuilder
246
+
247
+ .speak(speakOutput)
248
+
249
+ .getResponse();
250
+
251
+ },
252
+
253
+ };
216
254
 
217
255
 
218
256
 
@@ -378,7 +416,9 @@
378
416
 
379
417
  OrderIntentHandler,
380
418
 
381
- AnswerIntentHandler,
419
+ YesIntentHandler,
420
+
421
+ NoIntentHandler,
382
422
 
383
423
  HelpIntentHandler,
384
424
 
@@ -400,8 +440,6 @@
400
440
 
401
441
 
402
442
 
403
-
404
-
405
443
  -----------------------------------------------------------------------------------------------------
406
444
 
407
445
  どうすれば、自分が言ったスロットをリピートして注文の再確認を行う対話ができるか現在考えております。