SessionEndedRequest handler doesn't get invoked


#1

Hello,

I have a problem. I added SessionEndedRequest handler to my alexa skill, but it never gets invoked.

I just added it like this:

app.setHandler({
    LAUNCH() {
        this.ask('Hello World! What\'s your name?', 'Please tell me your name.');
    },

    SessionEndedRequest() {
        console.log('SessionEndedRequest');
    },
});

And it never gets invoked. I add console log on request and I see request coming in.

Is there a special way to catch this request? Do I need to add it to intent map or something?

Any help would be appreciated, because I searched for examples which would use SER handler, but I was unable to find any.


#2

Hi @Rokas_Vaitkevicius ,

in this handler example, when you launch your skill, you call this.ask(). This won’t end the session, but rather ask the user for more input. If you want the session to end, simply use this.tell() instead.


#3

I don’t want my session to end, I know how to do that. All I want is to handle SessionEndedRequest.

When user doesn’t talk, when there is an error either on amazon or skill side, when user says ‘exit’ a special request SessionEndedRequest is sent. It is really important to know why did it happen, especially if there was an error.

But the problem is, even if I add handler it never goes to it. I know that it comes, because I printed it out in onRequest.


#4

Got it! In this case, I would suggest using END.


#5

Thanks, that was exactly what I was looking for. I thought END is only used for stop intents, but apparently it handles SessionEndedRequests too.


#6

Hi, will it work for google assistant as well, if the session ends abruptly ?