2

I'm using the AWS ASK SDK for Node.js V2 to build an Alexa skill, and I'm wondering if it's possible to programmatically generate or update 'Alexa Prompt' for the 'Intent confirmation'.

The challenge is that we are running a search for a price, and the goal is to inject the price into the 'Intent confirmation' message, before asking for it.

I was thinking of trying to 'reprompt' the user, and force the reprompt after I have a price, but this feels dirty:

module.exports = {
    canHandle(handlerInput) {
        return (
            handlerInput.requestEnvelope.request.type === 'IntentRequest' &&
            handlerInput.requestEnvelope.request.intent.name ===
                'HelloWorldIntent'
        );
    },
    async handle(handlerInput) {
        let speechText;
        let repromptText;
        
        //perform web request to get price
        //then dynamically update the intent confirmation response prompt to include price, 
        //before asking intent confirmation prompt?
        
        return handlerInput.responseBuilder
            .speak(speechText)
            .getResponse();
    }
}

The documentation is lacking to say the least.

heartunicyclist
  • 313
  • 1
  • 3
  • 15
  • What do you mean by dynamically update intent confirmation response? – johndoe Sep 05 '18 at 17:23
  • Hey, so 'Intent Confirmation' is a boolean toggle you can set to on in the Alexa Skills Developer Console, and when turned on, you can supply 'prompts' that Alexa will say when confirming all of the slots for the given intent. I'm wanting to state a search result price either before on IN this message before Alexa confirms the user's intent, than calls into my 'completeHandler' in my AWS Lambda. – heartunicyclist Sep 06 '18 at 12:38
  • Why not confirm intent with a prompt including the price – johndoe Sep 06 '18 at 12:40
  • That's what I'm trying to do, I'm not sure how to programmatically define the prompt though. – heartunicyclist Sep 06 '18 at 14:05

1 Answers1

6

You can use Dialog.ConfirmIntent directive to send Alexa a command to confirm all the information the user has provided for the intent. You can also provide a prompt to ask the user for confirmation in an OutputSpeech object in the response.

In ask-nodejs-sdk v2, ConfirmIntent directive can be send through addConfirmIntentDirective().

Ex:

response = handlerInput.responseBuilder
  .speak('The price is 10 dollars, shall I confirm?')
  .reprompt('shall I confirm?')
  .addConfirmIntentDirective()
  .getResponse();

Check this answer for more info.
More on Dialog directives here.
Check out the documentation of ResponseBuilder.

johndoe
  • 4,387
  • 2
  • 25
  • 40