0
votes

I've started making a simple Alexa skill with CodeStar and Nodejs, my skill can inform the user about whether a Web system is currently still available, if there are any current incidents or service outtages. I get all the data in the form of a JSON API from http://statuspage.io.

The issue I'm having is that, my LaunchRequestHandler works correctly and also so does the first Intent that I ask, however when I ask a second intent (immediately after the first intent) this is where my Skill breaks and outputs (inside the Alexa Developer Console): <Audio only response>.

Alexa Developer Console Screenshot

Below I've pasted the code I have within my Skill.

// model/en-GB.json

"intents": [{
    "name": "QuickStatusIntent",
    "slots": [],
    "samples": [
        "quick status",
        "current status",
        "tell me the current status",
        "what's the current status",
        "tell me the quick status",
        "what's the quick status"
    ]
},
{
    "name": "CurrentIncidentIntent",
    "slots": [],
    "samples": [
        "incidents",
        "current incident",
        "is there a current incident",
        "tell me the current incidents",
        "what are the current incidents",
        "are there any current incidents"
    ]
}]


// lambda/custom/index.js

const QuickStatusIntentHandler = {
    canHandle(handlerInput) {
      return handlerInput.requestEnvelope.request.type === 'IntentRequest'
        && handlerInput.requestEnvelope.request.intent.name === 'QuickStatusIntent';
    },
    async handle(handlerInput) {
      let speechText = await getNetlifyStatus();
      return handlerInput.responseBuilder
        .speak(speechText)
        .getResponse();
    }
};

const CurrentIncidentIntentHandler = {
  canHandle(handlerInput) {
    return handlerInput.requestEnvelope.request.type === 'IntentRequest'
      && handlerInput.requestEnvelope.request.intent.name === 'CurrentIncidentIntent';
  },
  async handle(handlerInput) {
    const result = await getSummary();
    const speechText = `There are currently ${result.incidents.length} system incidents`;
    return handlerInput.responseBuilder
      .speak(speechText)
      .getResponse();
  }
}

My initial thought was to remove the .getResponse() as that might have been waiting for a response, however, that didn't seem to work correctly.

1

1 Answers

0
votes

The problem is your CurrentIncidentIntentHandler closes the session right after delivering the response to user.

If you want to keep the session open and let user to carry on the conversation Use .withShouldEndSession(false) or .repeat(speechText) in your CurrentIncidentIntentHandler to make Alexa wait for the user's next response.

const CurrentIncidentIntentHandler = {
  canHandle(handlerInput) {
    return handlerInput.requestEnvelope.request.type === 'IntentRequest'
      && handlerInput.requestEnvelope.request.intent.name === 'CurrentIncidentIntent';
  },
  async handle(handlerInput) {
    const result = await getSummary();
    const speechText = `There are currently ${result.incidents.length} system incidents`;
    return handlerInput.responseBuilder
      .speak(speechText)
      .withShouldEndSession(false) //you can also use .repeat(speachText) at this line
      .getResponse();
  }
}