代码之家  ›  专栏  ›  技术社区  ›  Amey

对话ElicitSlot在循环中运行如何在alexa中再次结束和开始对话?

  •  0
  • Amey  · 技术社区  · 6 年前
    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.slot”, “slotToElicit”:“项目” }],

    1 回复  |  直到 6 年前
        1
  •  0
  •   Amey    6 年前
    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;
       }
    }
    

    好的找到了这个解决方案