I am trying to build a very basic EMI Calculator. I want to capture the Loan amount and Interest rate in separate intents and then do the maths part. However, after capturing the Loan amount and confirming the same the program doesn't move to capture the interest rate.
I can reach only to the point where Alexa confirms the value of the loan amount.
Please help me understand why?
const Alexa = require('ask-sdk-core');
//Launch request and welcome message.
const LaunchRequestHandler = {
canHandle(handlerInput) {
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'LaunchRequest';
},
handle(handlerInput) {
const speakOutput = 'Hello! Welcome to your E.M.I. Calculator. Please tell me the loan amount you want to calculate the E.M.I. for';
return handlerInput.responseBuilder
.speak(speakOutput)
.reprompt(speakOutput)
.getResponse();
}
};
//capture the loan amount, save it in local variable and confirm to user the amount.
const captureLoanAmountHandler = {
canHandle(handlerInput){
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
&& Alexa.getIntentName(handlerInput.requestEnvelope) === 'captureloanamount';
},
async handle(handlerInput){
const currencyName = handlerInput.requestEnvelope.request.intent.slots.currency.value;
const loanAmount = handlerInput.requestEnvelope.request.intent.slots.loanamount.value;
const speakOutput = `Ok, I have captured the loan amount as ${currencyName} ${loanAmount}.`;
// return handlerInput.responseBuilder.speak(speakOutput);
// return handlerInput.responseBuilder.speak(speakOutput).getResponse();
}
};
//Prompt user for interest rate and capture it
const captureInterestRateHandler = {
canHandle(handlerInput){
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
&& Alexa.getIntentName(handlerInput.requestEnvelope) === 'captureinterestrate';
},
async handle(handlerInput){
let interestRateCaptured = false;
while (!interestRateCaptured){
const speakOutput = 'Please tell me the interest rate';
interestRateCaptured = true;
return handlerInput.responseBuilder
.speak(speakOutput).getResponse();
}
const iRate = handlerInput.requestEnvelope.request.intent.slots.roi.value;
const speakOutput1 = `Ok, I have captured the interest rate as ${iRate}`;
return handlerInput.responseBuilder.speak(speakOutput1).getResponse();
}
}```