I'm writing an Alexa application in node.js to answer product spec questions. For example, I'd like to be able to ask "What is the maximum capacity of (product)?" Currently, I have separate intents for each question for each product, which is resulting in incredibly messy code with a ton of handlers. What I'd like to do is just have one MaxCapacity intent for example, that uses slots (containing the different products) to assign the fact. I'm still relatively new at node.js, so I apologize if this is really sloppy. I know how to make new slots on the developer console, I just don't know how to code it on the backend. This is one of the handlers:
const GetNewFactHandler1 = {
canHandle(handlerInput) {
const request = handlerInput.requestEnvelope.request;
return request.type === 'LaunchRequest'
|| (request.type === 'IntentRequest'
&& request.intent.name === 'UMaxCapacityIntent');
*/ And if slot type == *product*, then: */
},
handle(handlerInput) {
const factArr = data;
const randomFact = factArr[1]; //Array with all the answers
const speechOutput = GET_FACT_MESSAGE + randomFact;
return handlerInput.responseBuilder
.speak(speechOutput)
.withSimpleCard(SKILL_NAME, randomFact)
.getResponse();
},
};
I hope that makes sense, but I'd be happy to explain further. Thank you!