取消意图未调用 Alexa

Cancel intent not invoked Alexa

我正在编写 Alexa 技能,但 AMAZON.CancelIntent 意图有问题。

如果我说 "quit" 或 "help" 其他意图会相应地被调用。但是,如果我说 "cancel" 我的自定义意图 NutriFactsIntent 会被调用,当然会出现问题,因为插槽未填充。

为什么会这样?

意图架构

"intents": [
{
  "name": "AMAZON.CancelIntent",
  "samples": [
    "Cancel",
    "Never mind",
    "forget it"
  ]
},
{
  "name": "AMAZON.HelpIntent",
  "samples": [
    "Open",
    "Start",
    "what can I say",
    "help me"
  ]
},
{
  "name": "AMAZON.StopIntent",
  "samples": [
    "Quit",
    "Exit",
    "Leave",
    "Off",
    "Stop"
  ]
},
{
  "name": "NutriFactsIntent",
  "samples": [
    "give me the facts on a {Food}",
    "give me the facts on an {Food}",
    "give me the facts for a {Food}",
    "give me the facts for an {Food}",
    "give me the facts of a {Food}",
    "give me the facts of an {Food}",
    "give me the facts for {Food}",
    "give me the facts of {Food}",
    ...

}

捕捉意图

function onIntent(intentRequest, session, callback) {
    //console.log(`onIntent requestId=${intentRequest.requestId}, sessionId=${session.sessionId}`);

    const intent = intentRequest.intent;
    const intentName = intentRequest.intent.name;

    // Dispatch to your skill's intent handlers
    if (intentName === 'NutriFactsIntent') {
        getFactsFromSession(intent, session, callback);
    } else if (intentName === 'AMAZON.HelpIntent') {
        getWelcomeResponse(callback);
    } else if (intentName === 'AMAZON.StopIntent' || intentName === 'AMAZON.CancelIntent') {
        handleSessionEndRequest(callback);
    } else {
        throw new Error('Invalid intent');
    }
}

我选择退出 Alexa 可用于交互模型的 Launch Skill Builder 测试版。

我点击它进入了 BETA,然后在苦苦挣扎了几个小时后我去了仪表板并离开了 BETA。

现在一切正常。