question

ice911 avatar image
ice911 asked

Using speak in SessionEndedRequest - custom exit message via "Exit" utterance

Hi guys,


I can't seem to get my skill to speak inside of an SessionEndedRequest. I'm calling SessionEndedRequest by using the utterance "Exit"

The SessionEndedRequest is called. The Console.Log is printed.


JSON Request:

    "request": {
        "type": "SessionEndedRequest",
        "requestId": "amzn1.echo-api.request.34125568-37fb-4911-b119-7acfc08ade50",
        "timestamp": "2019-07-29T19:08:09Z",
        "locale": "en-US",
        "reason": "USER_INITIATED"
    }


Code:

const SessionEndedRequestHandler = {
  canHandle(handlerInput) {
    console.log('Inside SessionEndedRequestHandler');
    return handlerInput.requestEnvelope.request.type === 'SessionEndedRequest';
  },
  handle(handlerInput) {
    console.log('Session ended with reason: ' + handlerInput.requestEnvelope.request.reason);

    return handlerInput.responseBuilder
    .speak(config.exit_message)
    .getResponse();
  },
};


JSON Response:

{
    "body": {
        "version": "1.0",
        "response": {
            "outputSpeech": {
                "type": "SSML",
                "ssml": "<speak>Thank you for accessing our skill. See you next time!</speak>"
            },
            "type": "_DEFAULT_RESPONSE"
        },
        "sessionAttributes": {
            "lastResponse": "last response entered here",
            "lastHandler": "Launch"
        },
        "userAgent": "ask-node/2.6.0 Node/v8.10.0"
    }
}


I've read in the documentation that "Your skill cannot return a response to SessionEndedRequest" which probably answers my question, but has anyone found a way to respond to users with a custom exit message using the "exit" utterance?


Thanks

Dj

alexa
10 |5000

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

0 Answers