【发布时间】: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"
}
但回应只是“对不起,但我不知道。你能重复一遍吗?”
【问题讨论】: