alexa技能中的错误“所请求的技能的响应存在问题”

时间:2020-04-10 10:47:24

标签: alexa alexa-skill alexa-slot

我正在使用Alexa托管的(node.js)方法

用户:与测试机器人进行对话

alexa:欢迎光临!您可以更新名称或订购食物。你想做什么?

用户:点餐

alexa:您可以点汉堡,汤和奶昔。你想吃什么?

用户:汉堡

alexa:您想要哪个素食者,土耳其,牛肉或经典汉堡?

用户:蔬菜

alexa:您的素食汉堡订单已经下达。

但是每当用户说menutype(burger)alexa时都会摆姿势,例如“所请求的技能的响应有问题”

这是我的代码

const StartedInProgressOrderFoodIntentHandler = {
  canHandle(handlerInput) {
    return handlerInput.requestEnvelope.request.type === "IntentRequest"
      && handlerInput.requestEnvelope.request.intent.name === "OrderFoodIntent"
      && handlerInput.requestEnvelope.request.dialogState !== 'COMPLETED';
  },
  handle(handlerInput) {
    return handlerInput.responseBuilder
      .addDelegateDirective()
        .getResponse();
  }
};

const BurgerGivenOrderFoodIntentHandler = {
  canHandle(handlerInput) {
    return handlerInput.requestEnvelope.request.type === "IntentRequest"
      && handlerInput.requestEnvelope.request.intent.name === "OrderFoodIntent"
      && handlerInput.requestEnvelope.request.intent.slots.menu.value 
      && handlerInput.requestEnvelope.request.intent.slots.menu.value === 'Burger'
      && !handlerInput.requestEnvelope.request.intent.slots.burgerType.value
  },
  handle(handlerInput) {
    return handlerInput.responseBuilder
      .speak('Which burger would you like Veggie, Turkey, Beef, or Classic burger?')
      .reprompt('Would you like a Veggie, Turkey, Beef, or Classic burger?')
      .addElicitSlotDirective('burgerType')
      .getResponse();
  }
};

const SoupGivenOrderFoodIntentHandler = {
  canHandle(handlerInput) {
    return handlerInput.requestEnvelope.request.type === "IntentRequest"
      && handlerInput.requestEnvelope.request.intent.name === "OrderFoodIntent"
      && handlerInput.requestEnvelope.request.intent.slots.menu.value
      && handlerInput.requestEnvelope.request.intent.slots.menu.value === 'Soup'
      && !handlerInput.requestEnvelope.request.intent.slots.soupType.value
  },
  handle(handlerInput) {
    return handlerInput.responseBuilder
      .speak("Which would you like tomato, manchow, onion, or corn soup?")
      .reprompt("Would you like a tomato, manchow, onion, or corn soup?")
      .addElicitSlotDirective('soupType')
      .getResponse();
  }
};

const ShakeGivenOrderFoodIntentHandler = {
  canHandle(handlerInput) {
    return handlerInput.requestEnvelope.request.type === "IntentRequest"
      && handlerInput.requestEnvelope.request.intent.name === "OrderFoodIntent"
      && handlerInput.requestEnvelope.request.intent.slots.menu.value
      && handlerInput.requestEnvelope.request.intent.slots.menu.value === 'Shake'
      && !handlerInput.requestEnvelope.request.intent.slots.shakeType.value
  },
  handle(handlerInput) {
    return handlerInput.responseBuilder
      .speak("Which would you like banana, chocolate, vanilla, milk, strawberry, or mango shake?")
      .reprompt("Would you like a banana, chocolate, vanilla, milk, strawberry, or mango shake?")
      .addElicitSlotDirective('shakeType')
      .getResponse();
  }
};

const CompletedOrderFoodIntentHandler = {
  canHandle(handlerInput) {
    return handlerInput.requestEnvelope.request.type === "IntentRequest"
        && handlerInput.requestEnvelope.request.intent.name === "OrderFoodIntent"
        && handlerInput.requestEnvelope.request.dialogState === "COMPLETED";
  },
  handle(handlerInput){

    const menu = handlerInput.requestEnvelope.request.intent.slots.menu.value;
    let type; 

    if (menu === 'Burger') {
        type = handlerInput.requestEnvelope.request.intent.slots.burgerType.value;
    } else if (menu === 'Soup') {
        type = handlerInput.requestEnvelope.request.intent.slots.soupType.value;
    } else if (menu === 'Shake') {
        type = handlerInput.requestEnvelope.request.intent.slots.shakeType.value;
    }

    const speechText = `Your order for ${type} ${menu} has been placed.`;
    return handlerInput.responseBuilder
        .speak(speechText)
        .getResponse();
  }
};

JSON输入状态响应

"status": {
            "code": "ER_SUCCESS_MATCH"
         },

JSON输出响应

{
    "body": {
        "version": "1.0",
        "response": {
            "directives": [
                {
                    "type": "Dialog.Delegate"
                }
            ],
            "type": "_DEFAULT_RESPONSE"
        },
        "sessionAttributes": {},
        "userAgent": "ask-node/2.7.0 Node/v10.19.0"
    }
}

1 个答案:

答案 0 :(得分:0)

错误太大。也许当您在 class_text 0 auction-results high-bid has-price 部分签入控制台时,会发现更多错误信息。请参阅图片作为参考:enter image description here 也许关闭对话框委托。