Dialog.ElicitSlot 是 运行 在循环中如何在 alexa 中结束和再次开始对话?
Dialog.ElicitSlot is running in a loop how to end and start dialogue again in alexa ?
function delegateSlotCollection(){
console.log("current dialogState: "+this.event.request.dialogState);
if (this.event.request.dialogState === "STARTED") {
var updatedIntent=this.event.request.intent;
this.emit(":delegate", updatedIntent);
} else if (this.event.request.dialogState !== "COMPLETED") {
console.log("in not completed");
if(this.event.request.intent.slots.customername.value) {
let prompt = "Please Tell Me your Item name ";
let reprompt = "";
console.log("Printed");
this.emit(':elicitSlot', 'item', prompt, reprompt);
}
} else {
return this.event.request.intent;
}
}
在 运行 这段代码之后,它会询问客户名称,然后它会得出项目值,然后当我输入项目值时,它会进入一个循环,并一次又一次地询问项目值如何打破这个?
输出json :-
"directives": [
{
"type": "Dialog.ElicitSlot",
"slotToElicit": "item"
} ],
function delegateSlotCollection(){
console.log("current dialogState: "+this.event.request.dialogState);
if (this.event.request.dialogState === "STARTED") {
var updatedIntent=this.event.request.intent;
this.emit(":delegate", updatedIntent);
} else if (this.event.request.dialogState !== "COMPLETED") {
console.log("in not completed");
if (this.event.request.intent.slots.item.value) {
this.emit(":delegate");
}
else if(this.event.request.intent.slots.customername.value) {
let prompt = "Please Tell Me your Item name HELLO ";
let reprompt = "";
console.log("Printed");
this.emit(':elicitSlot', 'item', prompt, reprompt);
}
} else {
return this.event.request.intent;
}
}
好的,找到了这个有效的解决方案
function delegateSlotCollection(){
console.log("current dialogState: "+this.event.request.dialogState);
if (this.event.request.dialogState === "STARTED") {
var updatedIntent=this.event.request.intent;
this.emit(":delegate", updatedIntent);
} else if (this.event.request.dialogState !== "COMPLETED") {
console.log("in not completed");
if(this.event.request.intent.slots.customername.value) {
let prompt = "Please Tell Me your Item name ";
let reprompt = "";
console.log("Printed");
this.emit(':elicitSlot', 'item', prompt, reprompt);
}
} else {
return this.event.request.intent;
}
}
在 运行 这段代码之后,它会询问客户名称,然后它会得出项目值,然后当我输入项目值时,它会进入一个循环,并一次又一次地询问项目值如何打破这个?
输出json :-
"directives": [ { "type": "Dialog.ElicitSlot", "slotToElicit": "item" } ],
function delegateSlotCollection(){
console.log("current dialogState: "+this.event.request.dialogState);
if (this.event.request.dialogState === "STARTED") {
var updatedIntent=this.event.request.intent;
this.emit(":delegate", updatedIntent);
} else if (this.event.request.dialogState !== "COMPLETED") {
console.log("in not completed");
if (this.event.request.intent.slots.item.value) {
this.emit(":delegate");
}
else if(this.event.request.intent.slots.customername.value) {
let prompt = "Please Tell Me your Item name HELLO ";
let reprompt = "";
console.log("Printed");
this.emit(':elicitSlot', 'item', prompt, reprompt);
}
} else {
return this.event.request.intent;
}
}
好的,找到了这个有效的解决方案