gpt4 book ai didi

node.js - 从 Nodejs 添加 Alexa Skill session 属性

转载 作者:太空宇宙 更新时间:2023-11-03 23:19:34 24 4
gpt4 key购买 nike

在nodejs代码中使用alexa技能中的 session 属性

code

但是输出未定义。未定义应该成为一种时尚。

undefined should be 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');
},

最佳答案

试试这个,

用于向 session 添加属性,

Object.assign(this.attributes, {
"lastSpeech" = this.event.request.intent.slots.category.value;
});

为了从 session 中检索它,

var a = this.attributes.lastSpeech;

希望这对您有帮助。祝一切顺利:)

关于node.js - 从 Nodejs 添加 Alexa Skill session 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51414507/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com