1

You can read here that you can invoke a skill with a specific request.

But my skill has a handler for new sessions and as soon as I try to invoke my skill with a specific request it still ends up in this new session 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;
        ...
    }
}

Is there a way to get the correct intent or will I have to do some if clauses in the newSession function to see what is coming in and which function should respond?

Jurik
  • 3,244
  • 1
  • 31
  • 52

1 Answers1

1

As you can read here on line 17:

Use LaunchRequest, instead of NewSession if you want to use the one-shot model Alexa, ask [my-skill-invocation-name] to (do something)...

So in my approach it would be:

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;
        ...
    }
}
Jurik
  • 3,244
  • 1
  • 31
  • 52