AG_HIHI
AG_HIHI

Reputation: 1995

Alexa how to implement intent confirmation?

I am having trouble with implementing a confirmation for an intent. The documentation is really vague. I am currently using jovo framework in writing my code with nodeJs which saved me a ton of time. This is an example of how I want to confirm the user's request:
User: Alexa, play NRJ radio
Alexa: Do you want me to play NRJ radio?
User: Yes
Alexa: I will play NRJ radio
Alexa plays NRJ radio
I have enabled intent confirmation in the Alexa console and I thought that was enough. But, it isn't. And I need to know what to do exactly to make this work. Thank you.
I have read the documentation multiple times and I couldn't understand how I should use dialog.delegate to achieve my goal and whether I should modify the JSON file in the console in one way or another.
This is really confusing so all help is welcome. Thank you :)

Upvotes: 1

Views: 756

Answers (1)

Jan König
Jan König

Reputation: 440

We usually recommend using states for things like this. For example, you could add a state PlayConfirmationState to your question with followUpState and then in this state listen for the AMAZON.YesIntent.

This is how it could look like in your app.js:

app.setHandler({
    'LAUNCH': function() {
        this.followUpState('PlayConfirmationState').
            .ask('Do you want me to play NRJ radio?');
    },

    'PlayConfirmationState': {
        'AMAZON.YesIntent': function() {
            this.alexaSkill().audioPlayer().play('url', 'token')
                .tell('I will play NRJ radio');
        },

        // Other intents in the state

    },

    // Other intents outside the state (stateless)

});

For more information, take a look at the following resources:

Upvotes: 1

Related Questions