save/remember Alexa 用户的意图确认响应?
save/remember an Alexa user's intent confirmation response?
我有一个关于我的 Alexa 技能的意图的确认提示,现在我需要它来“记住”用户的回答,而不是再次询问用户。从本质上讲,我们希望用户仅在他们第一次使用该技能时收到提示,然后再也不会收到提示。这可能吗?
我希望我不必重写全部代码,可以只更新我现有的代码。这是我的意图 javascript 技能的 lambda 函数代码(简化):
'myIntent': function() {
// there is a required prompt setup in the language interaction model (in the Alexa Skill Kit platform)
// To use it we "deligate" it to Alexa via the delegate dialoge directive.
if (this.event.request.dialogState === 'STARTED') {
// Pre-fill slots: update the intent object with slot values for which
// you have defaults, then emit :delegate with this updated intent.
this.emit(':delegate');
} else if (this.event.request.dialogState !== 'COMPLETED'){
this.emit(':delegate');
} else {
// completed
var intentObj = this.event.request.intent;
if (intentObj.confirmationStatus !== 'CONFIRMED') {
// not confirmed
if (intentObj.confirmationStatus !== 'DENIED') {
// Intent is completed, not confirmed but not denied
this.emit(':tell', "You have neither confirmed or denied. Please try again.");
} else {
// Intent is completed, denied and not confirmed
this.emit(':ask', 'I am sorry but you cannot continue.');
}
} else {
// intent is completed and confirmed. Success!
var words = "You have confirmed, thank you!";
this.response.speak(words);
this.emit(':responseReady');
}
}
},
感谢您的帮助!
更新: 我已经使用已接受答案的帮助成功实现了这个新功能。但是我不得不完全重写所有内容以适应新版本的 Alexa sdk。
您可以 persist/save/remember alexa 用户的数据使用 persistent attributes。
我建议您遵循 alexa 技能示例教程 zero to hero 它通过示例和视频总结了您需要了解的有关在 Alexa 上开发技能的所有信息。
而您需要从本教程中获得的是 Part 4 - Persistence
然后,就这么简单了:
attributesManager.setPersistentAttributes(sessionAttributes);
await attributesManager.savePersistentAttributes();
我有一个关于我的 Alexa 技能的意图的确认提示,现在我需要它来“记住”用户的回答,而不是再次询问用户。从本质上讲,我们希望用户仅在他们第一次使用该技能时收到提示,然后再也不会收到提示。这可能吗?
我希望我不必重写全部代码,可以只更新我现有的代码。这是我的意图 javascript 技能的 lambda 函数代码(简化):
'myIntent': function() {
// there is a required prompt setup in the language interaction model (in the Alexa Skill Kit platform)
// To use it we "deligate" it to Alexa via the delegate dialoge directive.
if (this.event.request.dialogState === 'STARTED') {
// Pre-fill slots: update the intent object with slot values for which
// you have defaults, then emit :delegate with this updated intent.
this.emit(':delegate');
} else if (this.event.request.dialogState !== 'COMPLETED'){
this.emit(':delegate');
} else {
// completed
var intentObj = this.event.request.intent;
if (intentObj.confirmationStatus !== 'CONFIRMED') {
// not confirmed
if (intentObj.confirmationStatus !== 'DENIED') {
// Intent is completed, not confirmed but not denied
this.emit(':tell', "You have neither confirmed or denied. Please try again.");
} else {
// Intent is completed, denied and not confirmed
this.emit(':ask', 'I am sorry but you cannot continue.');
}
} else {
// intent is completed and confirmed. Success!
var words = "You have confirmed, thank you!";
this.response.speak(words);
this.emit(':responseReady');
}
}
},
感谢您的帮助!
更新: 我已经使用已接受答案的帮助成功实现了这个新功能。但是我不得不完全重写所有内容以适应新版本的 Alexa sdk。
您可以 persist/save/remember alexa 用户的数据使用 persistent attributes。
我建议您遵循 alexa 技能示例教程 zero to hero 它通过示例和视频总结了您需要了解的有关在 Alexa 上开发技能的所有信息。
而您需要从本教程中获得的是 Part 4 - Persistence
然后,就这么简单了:
attributesManager.setPersistentAttributes(sessionAttributes);
await attributesManager.savePersistentAttributes();