【问题标题】:Alexa skill doesn't execute intentAlexa 技能不执行意图
【发布时间】:2019-08-12 07:15:28
【问题描述】:

我有一项技能,我正在尝试使用 Alexa 开发人员控制台中的“测试”功能对其进行测试。如果我给出调用名称,它会被识别为特定意图,但响应不匹配。 (这可能是显而易见的事情,我再也无法注意到了。)

我有一个 LaunchRequest 类型,它与调用名称一起使用。

const LaunchRequestHandler = {
  canHandle(handlerInput) {
    return handlerInput.requestEnvelope.request.type === 'LaunchRequest';
  },
  handle(handlerInput) {


    welcomeMessage = `updated welcome`;
    return handlerInput.responseBuilder
      .speak(welcomeMessage)
      .reprompt(helpMessage)
      .getResponse();
  },
};

(welcomeMessage 在外面声明,这只是测试问题是否赋予了它新的价值)

但是,当涉及到基于用户输入的意图时(在本例中为 TestIntent,用户输入是“技能是否有效”),它就是行不通的。 TestIntent的代码和LaunchRequest一样,除了intent type&name检查

const request = handlerInput.requestEnvelope.request;
return (request.type === "IntentRequest" &&
request.intent.name === "TestIntent");

alexa 技能的 json 输入将输入识别为 TestIntent

"request": {
    "type": "IntentRequest",
    "requestId": "amzn1.echo-api.request.601d2e89-71c1-417e-b878-790afc6f79f4",
    "timestamp": "2019-08-12T07:01:38Z",
    "locale": "en-US",
    "intent": {
        "name": "TestIntent",
        "confirmationStatus": "NONE"
    },
    "dialogState": "STARTED"
}

但回应只是“对不起,但我不知道。你能重复一遍吗?”

【问题讨论】:

    标签: aws-lambda alexa-skill


    【解决方案1】:

    您需要使用话语创建自定义意图。

    示例:

    {
        "interactionModel": {
            "languageModel": {
                "invocationName": "mySkill",
                "intents": [
                    {
                        "name": "TestIntent",
                        "slots": [
                            {
                                "name": "name",
                                "type": ""
                            }
                        ],
                        "samples": [
                            "test me", // This would be your utterance to identify intent
                            "testing you" // You can have multiple
                        ]
                    },
                    {
                        "name": "AMAZON.FallbackIntent",
                        "samples": []
                    },
                    {
                        "name": "AMAZON.HelpIntent",
                        "samples": []
                    },
                    {
                        "name": "AMAZON.NoIntent",
                        "samples": []
                    }
                ]
            }
        }
    }
    

    以下是开发者帐户的演练

    1) 创建您的意图

    2) 创建您的话语

    然后构建你的模态。您的技能需要与您的 lambda 函数相关联。

    希望对您有所帮助!

    ======更新=====

    需要回卡回复

    response = {
          outputSpeech: {
            type: "PlainText",
            text: output
          },
          card: {
            type: "Simple",
            title: title,
            content: output
          },
          shouldEndSession: shouldEndSession
        };
    

    使用aw-sdk:(示例)

    return handlerInput.responseBuilder
          .speak(speechText)
          .reprompt(speechText)
          .withSimpleCard('Hello World', speechText)
          .getResponse();
      }
    

    【讨论】:

    • 对不起,我应该澄清一下我已经为它做了{ "name": "TestIntent", "slots": [], "samples": [ "is there a problem with the skill", "is the skill working", "is it working" ] },是我从alexa响应中得到的代码我认为它识别出我的话语是“TestIntent”话语,但是由于某种原因,它似乎没有执行 handle() 函数
    • 你需要先用你的技能invocation name唤醒Alexa,然后用utterancesTestIntent才能完美调用Test Intent。
    • 你:Alexa ask {InvocationName} Alexa:欢迎信息。你:Alexa "is it working?"这样的事情
    • picture of test 调用名称和响应包含公司名称所以删除它,重要部分可见,我不知道为什么它不工作
    • 你确定你有,build model successfullysave model 之后?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-12
    • 2017-02-01
    相关资源
    最近更新 更多