SpecificRoomReservationIntent ()
{
const schema = {
date: new IsRequiredValidator(),
time: new IsRequiredValidator(),
duration: new IsRequiredValidator()
};
const validation = this.validate(schema);
var isDate = false;
var isTime = false;
var isDuration = false;
//Checks for required information in most recent input and session data.
//If new required input is saved in the session data bool indicator is... is made 'true'.
//Otherwise user is reprompted
//date
if (validation.failed('date'))
{
console.log("\n \n \n \n \n")
console.log(this.$session.$data.date)
console.log("\n \n \n \n \n")
if (this.$session.$data.date)
isDate = true;
}
else
{
this.$session.$data.date = this.$inputs.date.value;
console.log("\n \n \n \n \n")
console.log(this.$session.$data.date)
console.log("\n \n \n \n \n")
isDate = true;
}
//time
if (validation.failed('time'))
{
if (this.$session.$data.time)
isTime = true;
}
else
{
this.$session.$data.time = this.$inputs.time.value;
isTime = true;
}
//duration
if (validation.failed('duration'))
{
if (this.$session.$data.duration)
isDuration = true;
}
else
{
this.$session.$data.duration = this.$inputs.duration.value;
isDuration = true;
}
console.log("\n \n \n \n \n \n \n");
console.log(isDate);
console.log(isTime);
console.log(isDuration);
console.log("\n \n \n \n \n \n \n");
//Reprompts the user if they do not provide one of the required inputs
if (!isDate)
{
return this.ask('Please tell me what day you want to reserve the room?');
}
if (!isTime)
{
return this.ask("Please tell me what time you want to reserve the room?");
}
if (!isDuration)
{
return this.ask("Please tell me for how long you want to reserve the room?");
}
return this.toIntent('InitializeIteratorIntent');
},
Relevant Logs as shown in code above:
First prompt — date:
this.$session.$data.date:
December 16th 2018
isDate, isTime, isDuration:
true
false
false
Second prompt — time:
this.$session.$data.date
undefined
isDate, isTime, isDuration:
false
true
false
I don’t know why the session data date is disappearing between intent requests. Because of this the user gets stuck infinitely confirming the data and time. Any insights or suggestions?