gpt4 book ai didi

javascript - 一种 Alexa 技能的不同调用

转载 作者:行者123 更新时间:2023-11-30 11:39:29 32 4
gpt4 key购买 nike

我有一项技能 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”的额外 intentHandler,然后在 Utterences 中指定 ActorIntent 哪些 {actors} 具有 {skill} 技能?

我一直在研究这个想法,但我不太确定如何使用 Lambda 函数进行故障排除 - 有点像“上传并查看端点是否可达”。

如果我必须为此拥有两种不同的技能,那会很烦人,但我不确定?这只是我的代码库的问题,我应该能够毫无问题地创建一个 ActorIntent 吗?

最佳答案

定义一个不同的意图,例如,SkillOwnerIntent,并在 Alexa 开发者门户的交互模型中,为该意图定义话语。您绝对不需要为此制作其他技能。

关于javascript - 一种 Alexa 技能的不同调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43238619/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com