是否可以让 RequestInterceptor 根据 RequestInterceptor 内部的某些逻辑中止会话?
我有一个验证用户有效性的例程编码。如果有效性检查失败,我想向用户播放一条消息并中止会话。
我看到发生的是,即使我尝试杀死 RequestInterceptor 中的 Seesion,LaunchRequest 仍然运行
简化版如下
const Alexa = require('ask-sdk-core');
const requestInterceptor = {
var isUserOk = false;
if(!isUserOk){
process(handlerInput) {
return handlerInput.responseBuilder
.speak("You are inside the Request Interceptor")
.withShouldEndSession(true)
.getResponse();
}
}
}
const launchRequestHandler = {
canHandle(handlerInput) {
return (handlerInput.requestEnvelope.session.new &&
handlerInput.requestEnvelope.request.type === 'LaunchRequest');
},
handle(handlerInput) {
return handlerInput.responseBuilder
.speak("Hi, welcome to the test skill. What is your name?")
.reprompt("You did not respond. Please tell me your name")
.getResponse();
}
};
const skillBuilder = Alexa.SkillBuilders.custom();
exports.handler = skillBuilder
.addRequestHandlers(
launchRequestHandler,
)
.addRequestInterceptors(
requestInterceptor
)
.lambda();
谁能告诉我是否可以让 RequestInterceptor 中的逻辑终止 Session 并阻止 LaunchRequest 处理程序运行?
谢谢
-公元前