2017-08-16 85 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