SergioArcos
SergioArcos

Reputation: 404

Amazon Alexa - Ask same slot more than twice

I have only 1 intent, which must ask for a pin code. If the pin code is not right, then ask it again, maximum 3 times.

What's the right way to implement it? (I use alexa-sdk with nodejs)

I tried to implement two approaches, but they failed with EXCEEDED_MAX_REPROMPTS:

if pin_is_correct
  emit(:tell, "cool")
else
  emit(:ask, "what is your pin?", "what is your pin?")

and

unless pin_is_correct
  let updatedIntent = this.event.request.intent
  delete updatedIntent.slots.MY_PIN_SLOT_NAME.value
  this.emit(':delegate', updatedIntent)

if this.event.request.dialogState !== 'COMPLETED'
  this.emit(':delegate')

emit(:tell, "cool")

any example solving this same problem?

Upvotes: 1

Views: 560

Answers (1)

chetan mekha
chetan mekha

Reputation: 685

You set your counter and keep it incremental for every wrong entry. When reach max retries you can call custom method (you need to make few changes in your sdk) e.g

stopAlexa: function (speechOutput) {
        this._context.succeed(buildSpeechletResponse({
            session: this._session,
            output: speechOutput,
            shouldEndSession: true
        }));
    }

Here shouldEndSession: true is play the role to stop the Alexa programatically.

Upvotes: 1

Related Questions