如何调用具有特定请求的技能与newSession处理程序一起工作?

你可以在这里阅读,你可以调用具有特定请求的技能。

但我的技能有一个新的会话处理程序,只要我尝试调用我的技能与一个特定的请求,它仍然结束在这个新的会话function。

const handlers = { 'NewSession': function () { this.attributes.speechOutput = this.t('WELCOME_MESSAGE', this.t('SKILL_NAME')); this.attributes.repromptSpeech = this.t('WELCOME_REPROMT'); this.emit(':ask', this.attributes.speechOutput, this.attributes.repromptSpeech); }, 'RankIntent': function () { const rank1raw = this.event.request.intent.slots.RankOne; const rank2raw = this.event.request.intent.slots.RankTwo; ... } } 

有没有一种方法来获得正确的意图,或者我将不得不在newSession函数中做一些if子句来查看将要发生什么以及哪个函数应该响应?

正如你可以在这里阅读第17行 :

使用LaunchRequest,而不是NewSession,如果你想使用一次性模型的Alexa,问[my-skill-invocation-name](做某事)…

所以在我看来,这将是:

 const handlers = { 'LaunchRequest': function () { this.attributes.speechOutput = this.t('WELCOME_MESSAGE', this.t('SKILL_NAME')); this.attributes.repromptSpeech = this.t('WELCOME_REPROMT'); this.emit(':ask', this.attributes.speechOutput, this.attributes.repromptSpeech); }, 'RankIntent': function () { const rank1raw = this.event.request.intent.slots.RankOne; const rank2raw = this.event.request.intent.slots.RankTwo; ... } }