I am using the Fact skill template and I am modifying it so after reading out a random fact, it asks the user if they would like another. I've searched around on here, but similar problems seem to have a different syntax.
I don't know if I should be implementing this a different way, but I am unsure of what is going wrong in my code. I believe my issue is with .listen and if I should be using a .emit somewhere. (That was the way it was implemented in other examples)
I could be wrong, but as I understand it, my code is using the response builder whereas other people are doing it a different way.
Any help would be appreciated, If anyone could point me in the right direction to implementing it using this response buildier, it would help me out a lot.
I also have the built-in yes/no intents, but they aren't really doing anything right now.
const GetNewFactHandler = {
canHandle(handlerInput) {
const request = handlerInput.requestEnvelope.request;
return request.type === 'LaunchRequest'
|| (request.type === 'IntentRequest'
&& request.intent.name === 'GetNewFactIntent');
},
handle(handlerInput) {
const randomFact = data[i];
const speechOutput = (GET_FACT_MESSAGE + randomFact + NEXT_MESSAGE)
return handlerInput.responseBuilder
.speak(speechOutput)
.listen(REPROMPT_MESSAGE);
.withSimpleCard(SKILL_NAME, randomFact)
.getResponse();
},
};
Change .listen() to .reprompt()