2017-08-16 112 views
0

我只有1个意图,它必须要求密码。如果PIN码不正确,则再次提问,最多3次。亚马逊Alexa - 询问相同的插槽超过两次

什么是实施它的正确方法? (我用的alexa-SDK用的NodeJS)

我试图实现两个方法,但他们失败EXCEEDED_MAX_REPROMPTS:

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

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") 

任何例如解决同样的问题?

回答

1

您设置您的计数器并为每个错误的条目保持增量。 当达到最大重试可以调用自定义方法(你需要在你的SDK一些变化)e.g

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

这里shouldEndSession:真的是扮演的角色以编程方式停止Alexa的。

+0

谢谢!但是我的解决方案是避免使用Dialog。例如:'if(!slot或pinIsIncorrect()){this.emit(':ask','pin again?'); }'。您不需要更改SDK。 – SergioArcos