0
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:-

“指令”:[{“类型”:“Dialog.ElicitSlot”,“slotToElicit”:“项目”}],

4

1 回答 1

0
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;
   }
}

好的,发现这个解决方案有效

于 2018-05-16T10:15:31.383 回答