我遇到了一个问题,我必须填写用户的所有插槽。
分享所需的详细信息 -
我用Lex编写了Bot和intent定义。
我将Lex配置导出到Alexa Skill工具包。
目前,我正面临着问题,同时从用户那里获取给定意图的所有插槽的值。
Lambda代码段 -
@Override
public SpeechletResponse onIntent(SpeechletRequestEnvelope<IntentRequest> speechletRequestEnvelope) {
IntentRequest request = speechletRequestEnvelope.getRequest();
Session session = speechletRequestEnvelope.getSession();
log.info(String.format("onIntent. requestId : %s, sessionId : %s, Intent : %s", request.getRequestId(),
speechletRequestEnvelope.getSession().getSessionId(), speechletRequestEnvelope.getRequest().getIntent()));
Intent intent = request.getIntent();
String intentName = (intent != null) ? intent.getName() : null;
if ("HelloWorldIntent".equals(intentName)) {
return getHelloResponse();
} else if ("AMAZON.HelpIntent".equals(intentName)) {
return getHelpResponse();
} else if (LMDTFYIntent.MissingDrivesComplaint.name().equals(intentName)) {
return handleMissingDriveIntent(session, intent);
} else {
return getAskResponse("HelloWorld", "This is unsupported. Please try something else.");
}
}
private SpeechletResponse handleMissingDriveIntent(Session session, Intent intent) {
log.info(String.format("Executing intent : %s. Slots : %s", intent.getName(), intent.getSlots()));
Slot missingDriveSlot = intent.getSlot("missingDate");
Slot missingDrivesCountSlot = intent.getSlot("missingDrivesCount");
printSlots(intent.getSlots());
if(missingDriveSlot == null || missingDriveSlot.getValue() == null) {
printSlots(intent.getSlots());
log.info(String.format("Missing Drives slot is null"));
//return handleMissingDriveDialogRequest(intent, session);
ElicitSlotDirective elicitSlotDirective = new ElicitSlotDirective();
elicitSlotDirective.setSlotToElicit("missingDate");
SpeechletResponse speechletResponse = new SpeechletResponse();
speechletResponse.setDirectives(Arrays.asList(elicitSlotDirective));
SsmlOutputSpeech outputSpeech = new SsmlOutputSpeech();
outputSpeech.setSsml("On which date drives were missing");
speechletResponse.setOutputSpeech(outputSpeech);
return speechletResponse;
} else if(missingDrivesCountSlot == null || missingDrivesCountSlot.getValue() == null) {
printSlots(intent.getSlots());
log.info(String.format("Missing Drive Count is null"));
// return handleMissingDrivesCountDialogRequest(intent, session);
ElicitSlotDirective elicitSlotDirective = new ElicitSlotDirective();
elicitSlotDirective.setSlotToElicit("missingDrivesCount");
SpeechletResponse speechletResponse = new SpeechletResponse();
speechletResponse.setDirectives(Arrays.asList(elicitSlotDirective));
return speechletResponse;
} else if(missingDriveSlot.getValue() != null && missingDrivesCountSlot.getValue() != null) {
printSlots(intent.getSlots());
log.info(String.format("All slots filled."));
SpeechletResponse speechletResponse = new SpeechletResponse();
ConfirmIntentDirective confirmSlotDirective = new ConfirmIntentDirective();
speechletResponse.setDirectives(Arrays.asList(confirmSlotDirective));
return speechletResponse;
} else {
/*SpeechletResponse speechletResponse = new SpeechletResponse();
speechletResponse.setDirectives(Arrays.asList());*/
}
return null;
}
检查方法 -
handleMissingDriveIntent
槽孔 -
missingDate
missingDrivesCount
问题 -
答案 0 :(得分:0)
&#34;请求的技能响应存在问题&#34;
然后Alexa会将该错误消息回复给您。这意味着代码中存在运行时错误。
您可以检查lambda函数中的CloudWatch日志(如果使用的话,可以使用ask cli
工具)。它可以显示发生错误的行号。所以你需要从那里开始。