问题描述
我从交互模型中获取输入 - {borrower,amount,date}
我想验证用户在后端给我的日期,即借用日期不能大于今天。
const addNewDebtIntentHandler = {
canHandle(handlerInput) {
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
&& Alexa.getIntentName(handlerInput.requestEnvelope) === 'newDebt';
},handle(handlerInput) {
const borrower = handlerInput.requestEnvelope.request.intent.slots.borrower.value;
const amount = handlerInput.requestEnvelope.request.intent.slots.amount.value;
var date = handlerInput.requestEnvelope.request.intent.slots.date.value;
// console.log(date);
const currTime = moment().format('YYYY-MM-DD');
if(date>currTime)
{
const futureError = 'Future is yet to come! What do you want me to do?';
return handlerInput.responseBuilder
.speak(futureError)
.reprompt('What do you want me to do?')
.getResponse();
}
const speakOutput = handlerInput.t('ADD_NEW_DEBT_MSG',{borrower,date});
return handlerInput.responseBuilder
.speak(speakOutput)
.reprompt(speakOutput)
.getResponse();
}
};
请帮助我 -
if(date>currTime)
部分。
我希望 alexa 接受另一个日期的输入并重新验证它。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)