Alexa 没有调用 Intent
Alexa not invoking the Intent
我正在尝试制作一个alexa技能,它是基于alexa蓝图的事实技能。我制作了一个名为 "myIntent" 的自定义 Intent,它有一个变量“{myName}”或插槽类型 "myNameSlot"。我添加了多个值,例如 "Dhruv,User,My User"(都是单独的值)。
因此,我尝试通过模拟器在测试中启动我的 Alexa 技能。它可以很好地启动所有内置意图。但是,当我尝试启动我的自定义 Intent 时,它没有 launch.I 写出相同的语句,但是,它没有被调用。
这是我的 Lambda 函数的代码:https://pastebin.com/7CrdMffW
/* eslint-disable func-names */
/* eslint quote-props: ["error", "consistent"]*/
/**
* This sample demonstrates a simple skill built with the Amazon Alexa Skills
* nodejs skill development kit.
* This sample supports multiple lauguages. (en-US, en-GB, de-DE).
* The Intent Schema, Custom Slots and Sample Utterances for this skill, as well
* as testing instructions are located at https://github.com/alexa/skill-sample-nodejs-fact
**/
'use strict';
const Alexa = require('alexa-sdk');
//=========================================================================================================================================
//TODO: The items below this comment need your attention.
//=========================================================================================================================================
//Replace with your app ID (OPTIONAL). You can find this value at the top of your skill's page on http://developer.amazon.com.
//Make sure to enclose your value in quotes, like this: const APP_ID = 'amzn1.ask.skill.bb4045e6-b3e8-4133-b650-72923c5980f1';
const APP_ID = undefined;
const SKILL_NAME = 'Space Facts';
const GET_FACT_MESSAGE = "Here's your fact: ";
const HELP_MESSAGE = 'You can say tell me a space fact, or, you can say exit... What can I help you with?';
const HELP_REPROMPT = 'What can I help you with?';
const STOP_MESSAGE = 'Goodbye!';
//=========================================================================================================================================
//TODO: Replace this data with your own. You can find translations of this data at http://github.com/alexa/skill-sample-node-js-fact/data
//=========================================================================================================================================
const data = [
'A year on Mercury is just 88 days long.',
'Despite being farther from the Sun, Venus experiences higher temperatures than Mercury.',
'Venus rotates counter-clockwise, possibly because of a collision in the past with an asteroid.',
'On Mars, the Sun appears about half the size as it does on Earth.',
'Earth is the only planet not named after a god.',
'Jupiter has the shortest day of all the planets.',
'The Milky Way galaxy will collide with the Andromeda Galaxy in about 5 billion years.',
'The Sun contains 99.86% of the mass in the Solar System.',
'The Sun is an almost perfect sphere.',
'A total solar eclipse can happen once every 1 to 2 years. This makes them a rare event.',
'Saturn radiates two and a half times more energy into space than it receives from the sun.',
'The temperature inside the Sun can reach 15 million degrees Celsius.',
'The Moon is moving approximately 3.8 cm away from our planet every year.',
];
//=========================================================================================================================================
//Editing anything below this line might break your skill.
//=========================================================================================================================================
const handlers = {
'LaunchRequest': function () {
// this.emit('myIntent');
this.emit(':tell', '2 Hello, what would you like to do?');
},
'myIntent': function () {
const factArr = data;
const factIndex = Math.floor(Math.random() * factArr.length);
const randomFact = factArr[factIndex];
const speechOutput = GET_FACT_MESSAGE + randomFact;
this.response.cardRenderer(SKILL_NAME, randomFact);
this.response.speak('Halo ' + speechOutput);
this.emit(':responseReady');
},
'AMAZON.HelpIntent': function () {
const speechOutput = HELP_MESSAGE;
const reprompt = HELP_REPROMPT;
this.response.speak(speechOutput).listen(reprompt);
this.emit(':responseReady');
},
'AMAZON.CancelIntent': function () {
this.response.speak(STOP_MESSAGE);
this.emit(':responseReady');
},
'AMAZON.StopIntent': function () {
this.response.speak(STOP_MESSAGE);
this.emit(':responseReady');
},
};
exports.handler = function (event, context, callback) {
const alexa = Alexa.handler(event, context, callback);
alexa.APP_ID = APP_ID;
alexa.registerHandlers(handlers);
alexa.execute();
};
我不确定这里发生了什么。
编辑: 这是关于我的 Intent 和自定义插槽的信息:
意向名称: myIntent
。
话语数:
1.) 告诉我{data_of_intent}
2.) {data_of_intent}
的概要是什么
意图槽 (1) : data_of_intent
类型 my_custom_type
.
自定义插槽类型值:
1.) 一张
2.)花梦
3.) 金井君
4.) 雨停了吗?
我仔细检查了我在第一个 hit.The 问题上收到的 JSON 是 shouldEndSession
设置为 true,那是因为在 NodeJS 中,shouldEndSession
是在 :tell
中设置为 true 并且不能被覆盖。
我正在使用:
this.emit(':tell', '2 Hello, what would you like to do?');
.
我改成:
this.emit(':ask', '2 Hello, what would you like to do?');
成功了。
同样有一个 Github 线程:https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs/issues/64
我正在尝试制作一个alexa技能,它是基于alexa蓝图的事实技能。我制作了一个名为 "myIntent" 的自定义 Intent,它有一个变量“{myName}”或插槽类型 "myNameSlot"。我添加了多个值,例如 "Dhruv,User,My User"(都是单独的值)。
因此,我尝试通过模拟器在测试中启动我的 Alexa 技能。它可以很好地启动所有内置意图。但是,当我尝试启动我的自定义 Intent 时,它没有 launch.I 写出相同的语句,但是,它没有被调用。
这是我的 Lambda 函数的代码:https://pastebin.com/7CrdMffW
/* eslint-disable func-names */
/* eslint quote-props: ["error", "consistent"]*/
/**
* This sample demonstrates a simple skill built with the Amazon Alexa Skills
* nodejs skill development kit.
* This sample supports multiple lauguages. (en-US, en-GB, de-DE).
* The Intent Schema, Custom Slots and Sample Utterances for this skill, as well
* as testing instructions are located at https://github.com/alexa/skill-sample-nodejs-fact
**/
'use strict';
const Alexa = require('alexa-sdk');
//=========================================================================================================================================
//TODO: The items below this comment need your attention.
//=========================================================================================================================================
//Replace with your app ID (OPTIONAL). You can find this value at the top of your skill's page on http://developer.amazon.com.
//Make sure to enclose your value in quotes, like this: const APP_ID = 'amzn1.ask.skill.bb4045e6-b3e8-4133-b650-72923c5980f1';
const APP_ID = undefined;
const SKILL_NAME = 'Space Facts';
const GET_FACT_MESSAGE = "Here's your fact: ";
const HELP_MESSAGE = 'You can say tell me a space fact, or, you can say exit... What can I help you with?';
const HELP_REPROMPT = 'What can I help you with?';
const STOP_MESSAGE = 'Goodbye!';
//=========================================================================================================================================
//TODO: Replace this data with your own. You can find translations of this data at http://github.com/alexa/skill-sample-node-js-fact/data
//=========================================================================================================================================
const data = [
'A year on Mercury is just 88 days long.',
'Despite being farther from the Sun, Venus experiences higher temperatures than Mercury.',
'Venus rotates counter-clockwise, possibly because of a collision in the past with an asteroid.',
'On Mars, the Sun appears about half the size as it does on Earth.',
'Earth is the only planet not named after a god.',
'Jupiter has the shortest day of all the planets.',
'The Milky Way galaxy will collide with the Andromeda Galaxy in about 5 billion years.',
'The Sun contains 99.86% of the mass in the Solar System.',
'The Sun is an almost perfect sphere.',
'A total solar eclipse can happen once every 1 to 2 years. This makes them a rare event.',
'Saturn radiates two and a half times more energy into space than it receives from the sun.',
'The temperature inside the Sun can reach 15 million degrees Celsius.',
'The Moon is moving approximately 3.8 cm away from our planet every year.',
];
//=========================================================================================================================================
//Editing anything below this line might break your skill.
//=========================================================================================================================================
const handlers = {
'LaunchRequest': function () {
// this.emit('myIntent');
this.emit(':tell', '2 Hello, what would you like to do?');
},
'myIntent': function () {
const factArr = data;
const factIndex = Math.floor(Math.random() * factArr.length);
const randomFact = factArr[factIndex];
const speechOutput = GET_FACT_MESSAGE + randomFact;
this.response.cardRenderer(SKILL_NAME, randomFact);
this.response.speak('Halo ' + speechOutput);
this.emit(':responseReady');
},
'AMAZON.HelpIntent': function () {
const speechOutput = HELP_MESSAGE;
const reprompt = HELP_REPROMPT;
this.response.speak(speechOutput).listen(reprompt);
this.emit(':responseReady');
},
'AMAZON.CancelIntent': function () {
this.response.speak(STOP_MESSAGE);
this.emit(':responseReady');
},
'AMAZON.StopIntent': function () {
this.response.speak(STOP_MESSAGE);
this.emit(':responseReady');
},
};
exports.handler = function (event, context, callback) {
const alexa = Alexa.handler(event, context, callback);
alexa.APP_ID = APP_ID;
alexa.registerHandlers(handlers);
alexa.execute();
};
我不确定这里发生了什么。
编辑: 这是关于我的 Intent 和自定义插槽的信息:
意向名称: myIntent
。
话语数:
1.) 告诉我{data_of_intent}
2.) {data_of_intent}
的概要是什么意图槽 (1) : data_of_intent
类型 my_custom_type
.
自定义插槽类型值:
1.) 一张
2.)花梦
3.) 金井君
4.) 雨停了吗?
我仔细检查了我在第一个 hit.The 问题上收到的 JSON 是 shouldEndSession
设置为 true,那是因为在 NodeJS 中,shouldEndSession
是在 :tell
中设置为 true 并且不能被覆盖。
我正在使用:
this.emit(':tell', '2 Hello, what would you like to do?');
.
我改成:
this.emit(':ask', '2 Hello, what would you like to do?');
成功了。
同样有一个 Github 线程:https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs/issues/64