2017-04-05 88 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" 
        } 
    }