从Node.js添加Alexa技能会话属性 [英] adding alexa skill session attributes from nodejs
本文介绍了从Node.js添加Alexa技能会话属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在nodejs代码中使用Alexa技能中的会话属性
using session attributes in alexa skill in nodejs code
但输出未定义。未定义应该是一种时尚。
But getting output undefined. Undefined should be a fashion.
。
请参考图片以获取代码
'expenseIntent': function () {
var updatedIntent=this.event.request.intent;
var category1 = this.event.request.intent.slots.category.value;
var expense;
if(category1=='fashion'){
expense = '1000';
}else if(category1=='travel'){
expense = '2000';
}else if(category1=='food'){
expense = '3000';
}else {
expense = '4000';
}
this.attributes.lastSpeech = this.event.request.intent.slots.category.value;
console.log(this.attributes);
if (this.event.request.dialogState === "STARTED") {
this.emit(":delegate", updatedIntent);
}else if(this.event.request.dialogState !== "COMPLETED"){
this.emit(":delegate", updatedIntent);
}else {
console.log("this.event.request.intent.slots.category.value"+this.event.request.intent.slots.category.value);
this.response.speak("Amount spent on "+category1+" is " + expense);
this.emit(':responseReady');
}
},
'intentTwo': function () {
var a = this.attributes.lastSpeech;
//var aa = this.event.request.intent.slots.categories.value;
this.response.speak("you query was about " + a);
this.emit(':responseReady');
},
推荐答案
尝试一下,
要向会话中添加属性,
Object.assign(this.attributes, {
"lastSpeech" = this.event.request.intent.slots.category.value;
});
要从会话中检索它,
var a = this.attributes.lastSpeech;
希望这对您有所帮助。祝一切顺利:)
Hope this helps you. All the best :)
这篇关于从Node.js添加Alexa技能会话属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文