一种 Alexa 技能的不同调用
Different Invocations with one Alexa Skill
我有一项技能 SkillIntent
当你问它关于特定游戏的问题时,它会回复对该技能的描述。完美运行 - 然而,我现在想让它做的是,如果有不同的要求,我会回复 WHO has that Skill。
下面是我的工作代码:
'use strict';
var AlexaSkill = require('./AlexaSkill'),
descriptions = require('./descriptions');
var APP_ID = undefined;
var ZombicideSkills = function () {
AlexaSkill.call(this, APP_ID);
};
// Extend AlexaSkill
ZombicideSkills.prototype = Object.create(AlexaSkill.prototype);
ZombicideSkills.prototype.constructor = ZombicideSkills;
ZombicideSkills.prototype.eventHandlers.onLaunch = function (launchRequest, session, response) {
var speechText = "You can ask a question like, what does this skill do? ... Now, what can I help you with.";
var repromptText = "For instructions on what you can say, please say help me.";
response.ask(speechText, repromptText);
};
ZombicideSkills.prototype.intentHandlers = {
"SkillIntent": function (intent, session, response) {
var skillSlot = intent.slots.Skill,
skillName;
if (skillSlot && skillSlot.value){
skillName = skillSlot.value.toLowerCase();
}
var cardTitle = "Description for " + skillName,
description = descriptions[skillName],
speechOutput,
repromptOutput;
if (description) {
speechOutput = {
speech: description,
type: AlexaSkill.speechOutputType.PLAIN_TEXT
};
response.tellWithCard(speechOutput, cardTitle, description);
} else {
var speech;
if (skillName) {
speech = "I'm sorry, I don't know if I know " + skillName + ". What else can I help with?";
} else {
speech = "I'm sorry, I currently do not know that skill. What else can I help with?";
}
speechOutput = {
speech: speech,
type: AlexaSkill.speechOutputType.PLAIN_TEXT
};
repromptOutput = {
speech: "What else can I help with?",
type: AlexaSkill.speechOutputType.PLAIN_TEXT
};
response.ask(speechOutput, repromptOutput);
}
},
"AMAZON.StopIntent": function (intent, session, response) {
var speechOutput = "Goodbye";
response.tell(speechOutput);
},
"AMAZON.CancelIntent": function (intent, session, response) {
var speechOutput = "Goodbye";
response.tell(speechOutput);
},
"AMAZON.HelpIntent": function (intent, session, response) {
var speechText = "You can ask questions such as, what does this skill do, or, you can say exit... Now, what can I help you with?";
var repromptText = "You can say things like, what does this skill do, or you can say exit... Now, what can I help you with?";
var speechOutput = {
speech: speechText,
type: AlexaSkill.speechOutputType.PLAIN_TEXT
};
var repromptOutput = {
speech: repromptText,
type: AlexaSkill.speechOutputType.PLAIN_TEXT
};
response.ask(speechOutput, repromptOutput);
}
};
exports.handler = function (event, context) {
var zombicide = new ZombicideSkills();
zombicide.execute(event, context);
};
它的建模与 MC Helper 非常相似。我会只实现一个名为 'ActorIntent' 的额外 intentHandlers,然后在 Utterences 中指定 ActorIntent what {actors} have the {skill} skill?
我一直在研究这个想法,但我不太确定如何使用 Lambda 函数进行故障排除 - 有点 'upload and see if the endpoint is reachable'。
如果我必须为此拥有两种不同的技能,那会很烦人,但我不确定?这只是我的代码库的问题,我应该能够毫无问题地创建一个 ActorIntent
吗?
定义不同的 Intent,例如 SkillOwnerIntent
,并在 Alexa 开发人员门户的交互模型中,为该 Intent 定义话语。你绝对不需要为此制作其他技能。
具有良好用户体验的解决方案如下:
一位用户询问了触发您的 SkillIntent 的游戏技能
In your code: Save this skill in a variable (e.g. as a string)
Alexa 会告诉您技能的描述,并可能会询问更多问题。
网友可以问:哪些演员有这个技能?这会触发您的意图 ActorIntent。
Utterances: ActorIntent Which actors have this skill?
你知道用户说的是哪个技能(因为你把它存储在一个变量中)。现在 alexa 可以告诉具体的演员。
意图架构示例:
{
"intents": [
{
"intent": "ActorIntent"
},
{
"slots": [
{
"name": "skill",
"type": "SKILL"
}
],
"intent": "SkillIntent"
}
}
我有一项技能 SkillIntent
当你问它关于特定游戏的问题时,它会回复对该技能的描述。完美运行 - 然而,我现在想让它做的是,如果有不同的要求,我会回复 WHO has that Skill。
下面是我的工作代码:
'use strict';
var AlexaSkill = require('./AlexaSkill'),
descriptions = require('./descriptions');
var APP_ID = undefined;
var ZombicideSkills = function () {
AlexaSkill.call(this, APP_ID);
};
// Extend AlexaSkill
ZombicideSkills.prototype = Object.create(AlexaSkill.prototype);
ZombicideSkills.prototype.constructor = ZombicideSkills;
ZombicideSkills.prototype.eventHandlers.onLaunch = function (launchRequest, session, response) {
var speechText = "You can ask a question like, what does this skill do? ... Now, what can I help you with.";
var repromptText = "For instructions on what you can say, please say help me.";
response.ask(speechText, repromptText);
};
ZombicideSkills.prototype.intentHandlers = {
"SkillIntent": function (intent, session, response) {
var skillSlot = intent.slots.Skill,
skillName;
if (skillSlot && skillSlot.value){
skillName = skillSlot.value.toLowerCase();
}
var cardTitle = "Description for " + skillName,
description = descriptions[skillName],
speechOutput,
repromptOutput;
if (description) {
speechOutput = {
speech: description,
type: AlexaSkill.speechOutputType.PLAIN_TEXT
};
response.tellWithCard(speechOutput, cardTitle, description);
} else {
var speech;
if (skillName) {
speech = "I'm sorry, I don't know if I know " + skillName + ". What else can I help with?";
} else {
speech = "I'm sorry, I currently do not know that skill. What else can I help with?";
}
speechOutput = {
speech: speech,
type: AlexaSkill.speechOutputType.PLAIN_TEXT
};
repromptOutput = {
speech: "What else can I help with?",
type: AlexaSkill.speechOutputType.PLAIN_TEXT
};
response.ask(speechOutput, repromptOutput);
}
},
"AMAZON.StopIntent": function (intent, session, response) {
var speechOutput = "Goodbye";
response.tell(speechOutput);
},
"AMAZON.CancelIntent": function (intent, session, response) {
var speechOutput = "Goodbye";
response.tell(speechOutput);
},
"AMAZON.HelpIntent": function (intent, session, response) {
var speechText = "You can ask questions such as, what does this skill do, or, you can say exit... Now, what can I help you with?";
var repromptText = "You can say things like, what does this skill do, or you can say exit... Now, what can I help you with?";
var speechOutput = {
speech: speechText,
type: AlexaSkill.speechOutputType.PLAIN_TEXT
};
var repromptOutput = {
speech: repromptText,
type: AlexaSkill.speechOutputType.PLAIN_TEXT
};
response.ask(speechOutput, repromptOutput);
}
};
exports.handler = function (event, context) {
var zombicide = new ZombicideSkills();
zombicide.execute(event, context);
};
它的建模与 MC Helper 非常相似。我会只实现一个名为 'ActorIntent' 的额外 intentHandlers,然后在 Utterences 中指定 ActorIntent what {actors} have the {skill} skill?
我一直在研究这个想法,但我不太确定如何使用 Lambda 函数进行故障排除 - 有点 'upload and see if the endpoint is reachable'。
如果我必须为此拥有两种不同的技能,那会很烦人,但我不确定?这只是我的代码库的问题,我应该能够毫无问题地创建一个 ActorIntent
吗?
定义不同的 Intent,例如 SkillOwnerIntent
,并在 Alexa 开发人员门户的交互模型中,为该 Intent 定义话语。你绝对不需要为此制作其他技能。
具有良好用户体验的解决方案如下:
一位用户询问了触发您的 SkillIntent 的游戏技能
In your code: Save this skill in a variable (e.g. as a string)
Alexa 会告诉您技能的描述,并可能会询问更多问题。
网友可以问:哪些演员有这个技能?这会触发您的意图 ActorIntent。
Utterances: ActorIntent Which actors have this skill?
你知道用户说的是哪个技能(因为你把它存储在一个变量中)。现在 alexa 可以告诉具体的演员。
意图架构示例:
{
"intents": [
{
"intent": "ActorIntent"
},
{
"slots": [
{
"name": "skill",
"type": "SKILL"
}
],
"intent": "SkillIntent"
}
}