I'm using the Dialog Model to fulfill the required slots of the intents in my java lambda function.
I have similar slots in some intents and I would like to use the same utterances to fulfill theses slots.
Now, If a User has to fulfill the required slots of one intent, sometimes the skill detect an other intent during this process (Because some utterances are similar to other intents).
Is it possible to force the skill to stay in one intent until all required slots are fulfilled or I'm doing something wrong?
//Get Dialog State
DialogState dialogueState = request.getDialogState();
if (dialogueState.equals(DialogState.STARTED)) {
System.out.println("In if");
isDialog = true;
// 1. Create DialogIntent based on your original intent
DialogIntent dialogIntent = new DialogIntent(intent);
// 2. Create Directive
DelegateDirective dd = new DelegateDirective();
dd.setUpdatedIntent(dialogIntent);
List<Directive> directiveList = new ArrayList<Directive>();
directiveList.add(dd);
SpeechletResponse speechletResp = new SpeechletResponse();
speechletResp.setDirectives(directiveList);
// 3. return the response.
speechletResp.setNullableShouldEndSession(false);
return speechletResp;
} else if (dialogueState.equals(DialogState.COMPLETED)) {
isDialog = false;
log.info("onIntent, inside dialogueState IF statement");
Message message = new Message();
String speechText = "";
String repromptSpeech = "Kann ich dir noch anderweitig behilflich sein?";
String m = intent.getSlot(_MESSAGETEXT).getValue();
message.setMessage(m);
// message.setMessage(intent.getSlot(_MESSAGETEXT).getValue());
System.out.println("Message Text: " + m);
String firstname = intent.getSlot(_USERFIRSTNAME).getValue().toLowerCase();
String lastname = intent.getSlot(_USERLASTNAME).getValue().toLowerCase();
String receiverUserId = "";
if(db.checkIfUserExistsByName(firstname, lastname)) {
receiverUserId = db.getUserIDByName(firstname, lastname);
}else {
speechText = "Der angegebene Empfänger existiert leider nicht! Bitte probiere es erneut!";
return getSpeechletResponse(speechText, "", true);
}
// Check if the receiver is the same like the current user
if(receiverUserId.equals(user.getUserID())) {
speechText = "Ich glaube nicht, dass du dir selbst eine Nachricht schicken willst.";
return getSpeechletResponse(speechText, "", true);
}else {
message.setUserID(receiverUserId);
message.setCreator(user.getUserID());
message.setStatus(MessageStatus.UNREAD.toString());
message.setDate(DateParser.getDateOfTodayAsString());
db.addMessage(message);
speechText = "Die Nachricht wurde erfolgreich an " + firstname + " " + lastname + " geschickt!";
}
return getSpeechletResponse(speechText, repromptSpeech, true);
} else {
log.info("onIntent, inside dialogueState ELSE statement");
DelegateDirective dd = new DelegateDirective();
List<Directive> directiveList = new ArrayList<Directive>();
directiveList.add(dd);
SpeechletResponse speechletResp = new SpeechletResponse();
speechletResp.setDirectives(directiveList);
speechletResp.setNullableShouldEndSession(false);
return speechletResp;
}