1

您可以在此处阅读,您可以通过特定请求调用技能。

但是我的技能有一个新会话的处理程序,一旦我尝试使用特定请求调用我的技能,它仍然会在这个新的会话函数中结束。

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 子句来查看即将到来的内容以及哪个函数应该响应?

4

1 回答 1

1

正如您在第 17 行所读到的

如果您想使用一次性模型 Alexa,请使用 LaunchRequest,而不是 NewSession,要求 [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;
        ...
    }
}
于 2017-02-11T22:15:39.057 回答