question

r-j-b avatar image
r-j-b asked

Sometimes the LaunchRequest is skipped and skills start with an intent? How to solve this?

Hello. I am still learning and currently I am working on using the SDK2 instead of version 1. The problem I have is that even when I use the default samples, skills do not behave the way they should or at least how I am used to and expect them to work (ons SDK1).

At the moment I am not using the CLI, but instead serverless applications repositories for the SDK2 (precisely the NodeJS fact skill repository) as a basis to work with.

Even the simplest skill with only one Intent (besides the standard intents) gives me headaches.

exports.handler = skillBuilder 
  .addRequestHandlers(
    LaunchRequestHandler,
    HelloIntentHandler,
    NextHandler,
    HelpHandler,
    ExitHandler,
    SessionEndedRequestHandler
  )
  .addErrorHandlers(ErrorHandler)
  .lambda();

So these are all the Handlers I use. The skill uses exactly the default code (nothing added by me), but for some strange reason the LaunchRequest is sometimes skipped. This is what happens: The user opens the skill and the LaunchRequest is placed. The user could interact with the skill or stop it. When he reopens the skill immediately the LaunchRequest is now skipped and the HelloIntentHandler is used. In the simulator I could just go back to the build tab and return to the test tab - then the skill will open with the LaunchRequest again.
On an Echo device this doesn't work obviously - here only waiting a couple of minutes somehow resets the skill.

Is this a know issue?
Is this because I am not using the CLI, but instead the serverless application repository? I could code a skill from scratch and the same problems occur although it works fine. Only on SDK1 the skill will always open with the LaunchRequest.

Thanks for reading so far. I know this might just be a basic problem, but I am still learning and I enjoy every tip you might have.

Rene

alexa skills kitintentshow-tolaunch
5 comments
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Rokas avatar image Rokas commented ·

Can you share some of your code? Especially what is inside canHandle() functions, because by them code decides which handler to call, so there might be problem. I wrote more about, how canHandle() works here: link.

0 Likes 0 ·
r-j-b avatar image r-j-b Rokas commented ·

I have stored the LaunchRequest into a separate function and not like in your link, because I wanted to make sure that a different code runs for the skills launch:

const LaunchRequestHandler = {
  canHandle(handlerInput) {
    return handlerInput.requestEnvelope.request.type === 'LaunchRequest';
  },
....

As I have written in another reply, the strange thing is that in the JSON output the new session is never set to true, even for the first invocation (which never happened with the SDK1).

The handlers are registered in the right order (LaunchRequest first) and now I am kinda sure that this has to do with the JSON output:

"session":
   {
    "new":false,
    ...

But I have no idea why the session is always false, even for the first invocation?

0 Likes 0 ·
Rokas avatar image Rokas r-j-b commented ·

Try adding to your response builder on stop and any other intents that end the game this call to the function .withShouldEndSession(true)

1 Like 1 ·
Show more comments
adamderann avatar image
adamderann answered

Hi r-j-b, I have had trouble in the past remembering to type in 'exit' into the simulator to start a new session after launching the previous one - even typing the same invocation phrase while in a session triggers an intent when there's 1 or 2 in your lang model, I've found.
You could check if new: true, in the session object of the Alexa request JSON, to see if the session was actually kept open for some reason with the actual device - and is imitating the test simulator behaviour of mapping to some random intent.

1 comment
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

r-j-b avatar image r-j-b commented ·

Hi adamderann.

Thanks for the reply. In fact the session is never set to "new: true". The JSON output is even for the first time always false!

"session":
  {
    "new":false,
    ...

Which is a strange behavior I have never encountered with the SDK1.

Is there a way to make sure that the session, new is always set to true? Or to make sure that when the AMAZON.CancelIntent, AMAZON.StopIntent or the SessionEndedRequest is called that the session is somehow reset?

With best regards!

0 Likes 0 ·
newuser-20e01d76-abb3-48fb-a758-e55c1b3d4901 avatar image
newuser-20e01d76-abb3-48fb-a758-e55c1b3d4901 answered

I have the same issues. After triggering AudioPlayer in one of my intents, going back to my Skill always returns to that intent instead of the LaunchRequest. I added `withShouldEndSession` all RequestHandlers and IntentHandlers and it's still having the same behaviour.

1 comment
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Amazon_Bernardo Bezerra avatar image Amazon_Bernardo Bezerra ♦♦ commented ·

Hello and sorry it took so long to get to your question.

Can you please share your skill ID as well as the steps/utterances to reproduce the issue you described?

Cheers,
Barry

0 Likes 0 ·