2017-04-05 91 views
0

我有一个技能SkillIntent,当你问它一个特定的游戏问题,它回答该技能的描述。完美的工作 - 然而,我现在要做的是,如果有不同的询问,那么回复世卫组织就有这个技能。不同的调用与一个Alexa技巧

下面是我的工作代码:

'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助手的。我是否会实现一个名为'ActorIntent'的附加intent处理程序,然后在Utterences中指定ActorIntent what {actors} have the {skill} skill?

我一直在玩这个想法,只需'上传并查看端点是否可达'。

如果我必须具备两个不同的技能,这会很烦人,但我不确定吗?这只是我的代码库的一个问题,我应该可以去创建一个没有问题的ActorIntent

回答

3

定义一个不同的意图,例如SkillOwnerIntent,并在Alexa Developer Portal的交互模型中定义该意图的话语。你绝对不需要为此做出另一项技巧。

+0

感激 - 我不知道,如果我的次要目的是打破了功能,或别的东西。谢谢。 – DNorthrup

0

具有良好用户体验的解决方案将是如下:关于游戏技能触发你的SkillIntent

在你的代码

  1. 用户AKS:在一个变量保存这个技能(例如作为一个字符串)

  • Alexa告诉你的技能的描述,并可能要求进一步的问题。

  • 用户现在可以问:哪些演员有这个技能?这会触发你的意图ActorIntent。

    言论:ActorIntent哪些演员有此技能?

  • 您知道用户正在谈论哪种技能(因为您将其存储在变量中)。现在,alexa可以告诉具体的演员。

  • 意向架构例如:

    { 
    "intents": [ 
        { 
        "intent": "ActorIntent" 
        }, 
        { 
        "slots": [ 
         { 
         "name": "skill", 
         "type": "SKILL" 
         } 
        ], 
        "intent": "SkillIntent" 
        } 
    }