我有一项技能SkillIntent
,当你问一个关于特定游戏的问题时,它会回复该技能的描述。工作完美 - 但我现在要做的就是回答世卫组织的技巧,如果提出不同的要求。
以下是我的工作代码:
'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函数进行故障排除 - 只需上传并查看端点可以到达'。
如果我必须拥有两种不同的技能,那会很烦人,但我不确定?这只是我的代码库的一个问题,我应该可以创建一个ActorIntent
而不会出问题吗?
答案 0 :(得分:3)
定义不同的Intent,例如Update slots
SET locked = false
WHERE `datetime`> NOW() - INTERVAL 15 MINUTE;
SELECT *
FROM slots
WHERE locked = false;
,并在Alexa Developer Portal的交互模型中,定义该意图的话语。你绝对不需要为此做另一项技能。
答案 1 :(得分:0)
具有良好用户体验的解决方案如下:
用户询问触发SkillIntent的游戏技能
在您的代码中:将此技能保存在变量中(例如,作为字符串)
Alexa会告诉您的技能说明,并可能会提出进一步的问题。
用户现在可以问:哪些演员有此技能?这会触发你的意图ActorIntent。
话语:ActorIntent哪些演员有这种技能?
您知道用户正在谈论的技能(因为您将其存储在变量中)。现在alexa可以告诉具体的演员。
意图架构示例:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int n = 0;
srand(time(NULL)); // seed for rand
for (int c = 1; c <= 10; c++)
{
n = rand() % 25 + 97; // rand() gives you a number between 0 and 24 and then add 98 to get a number between 97 and 122
printf("%d\n", n);
}
}