What is the best way to determine how the skill was entered?


I have found that in almost all the Alexa skills that I’ve made using the Jovo framework, I have had to add logic to determine if the skill was entered without an intent (directly into the LAUNCH handler) or with an intent (coming in through ON_REQUEST). Depending on how the skill was entered, I either use this.ask calls (when LAUNCHed) or this.tell calls (called with intent). Essentially, when the user invokes the skill by opening it only with the Invocation phrase I want the session to remain open. Otherwise, I want the skill to respond to the intent and then exit.

My question is, what is the best way to do this? What I have done is to add a session variable called endAfterIntent. If the LAUNCH intent is called, I set this.$session.$data.endAfterIntent to false. In the ON_REQUEST handler, I have the following check:

if (typeof this.$session.$data.endAfterIntent === 'undefined') {
    this.$session.$data.endAfterIntent = true;

Then I have logic around all the speechBuilder calls:

if (this.$speech.$data.endAfterIntent) {
} else {
    this.ask(this.$speech, this.$reprompt);

This seems a bit clunky to me and I was wondering if there was a better way of determining how the skill was invoked rather than having to maintain my own session variable. Is there a method call that I can make to find out if the skill was entered with or without an intent?

I appreciate any tips or suggestions of better ways to do this.


Hi @Ben_Hartman, I’m not sure I fully understand:

  • You have a few intents like LAUNCH, IntentA, IntentB that are all in your handler, outside any states
  • A normal invocation would trigger LAUNCH, which has an ask (e.g. “Do you want to do either ‘A’ or ‘B’?” -> In the next request the person answers with IntentA oder IntentB, which would go into the respective stateless intents which have a tell (if I understand correctly)
  • A deep invocation would directly go into e.g. IntentA and go to that tell immediately

The way I understand it it wouldn’t be necessary to distinguish between a Launch request or a deep invocation. Or am I missing something?

For a deep invocation, you could also check inside an intent handler if it’s a new session, which would be this.$session.isNew()


Hi @jan, thanks for the response. I will try to clarify a bit further what I am asking, but I believe that your answer led me to a solution:

  • Case 1 (standard invocation): Yes, I have intents like LAUNCH, IntentA, IntentB that are in my handler outside any states. However. when I enter the skill through LAUNCH, I want to be able to go to IntentA or IntentB, but then I want to leave the skill open to allow the user to go to the other intent. I only exit the skill after asking the user if they are finished. Therefore, IntentA and IntentB must have an ask to leave the skill open in this case.

  • Case 2 (deep invocation): I call IntentA or IntentB directly. In this case I want to exit after executing the Intent. Therefore, IntentA and IntentB must also have a tell to close the session if entered via deep invocation.

  • Several of my skills have a similar framework - there is a “home” intent where the user can hear (or see if they have an Echo Show) the list of possible intents. The user can then go to one of the intents and then go back to the home intent, leaving the skill open. Or, the user can execute an individual intent through deep invocation.

This is the reason I have logic in IntentA and IntentB to figure out how the skill was entered and determine which route to take: ask or tell. I could not find the method you mentioned (this.$session.isNew()); however, I was able to use this.isNewSession() which is a lot cleaner than the method I was using which I described in my first post. Many thanks for pointing me in this direction.


Ah yes! Now that you mention it I think it’s a variable instead of a method this.$session.isNew, but if this.isNewSession() works, that’s great.