Keep previous input state after using validation and this.ask()


#1

Hi,
i’m trying to build my first skill with Jovo and I’m having some troubles with data validation.

First: it looks like there is no support for Alexa’s “Slot Filling” (I don’t know the corresponding Google’s one), right?

So I’m trying to validate user inputs by hand, checking if I’m getting all the required inputs in the user’s request. To do this, I’m using the validate() method, which works as expected. The problem is that, after the user is asked to input the missing parameter, all the other parameters get lost.

This is my code:
const schema = {
da: [
new IsRequiredValidator(),
new ValidValuesValidator([
‘napoli’
])
]
};

    const validation = this.validate(schema);

    if(validation.failed('da')) {
        return this.ask('Da dove parti?');
    }

How can I simply add the user’s response to my question “Da dove parti?” without loosing my previous inputs?


#2

If anybody is interested in the solution, here is mine

if(this.$inputs.da.value != undefined) {
        this.$session.$data.da = this.$inputs.da;
    } else if(this.$session.$data.da != undefined) {
        this.$inputs.da = this.$session.$data.da;
    }

If user inputs something, I save it in a session var. Next time the app enters inside the intent, I check it again. If user had said something else for that input, I’ll overwrite the session var, else I’ll populate the input value with the last session value saved