question

newuser-f737ddd4-762e-42cf-8f2a-490802c0f555 avatar image

[ISP] changing skill-sample-nodejs-fact-in-skill-purchases template

Hi,


I used this template to build my own ISP skill. I simplified it, however, to 10 free facts and one entitlement for paid facts only. Here's the problem:

Actual behaviour: When the skills ask "Do you want another fact?", the skill only returns facts from the free tier, even when ISP products earlier have been purchased.

Desired behaviour: When the skills ask "Do you want another fact?", the skill randomly returns facts from the free tier and the payed category (when ISP products earlier have been purchased).

From my limited understanding, this code part is the clue and it should trigger the desired behaviour:

// IF THE USER SAYS YES, THEY WANT ANOTHER FACT.
const YesHandler = {
  canHandle(handlerInput) {
    return handlerInput.requestEnvelope.request.type === 'IntentRequest' &&
      (handlerInput.requestEnvelope.request.intent.name === 'AMAZON.YesIntent' ||
        handlerInput.requestEnvelope.request.intent.name === 'GetRandomFactIntent');
  },
  handle(handlerInput) {
    console.log('In YesHandler');

    // reduce fact list to those purchased
    const filteredFacts = getFilteredFacts(ALL_FACTS, handlerInput);

    const speakOutput = `Here's your handpicked fact: ${getRandomFact(filteredFacts)} ${getRandomYesNoQuestion()}`;
    const repromptOutput = getRandomYesNoQuestion();

    return handlerInput.responseBuilder
      .speak(speakOutput)
      .reprompt(repromptOutput)
      .getResponse();
  },
};


I'm new to Alexa and coding and wonder what part I need to change to get the template JSON to perform the desired (see above) behaviour.


Thanks!


- Malte

isp
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