Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const LaunchIntentHandler = {
- canHandle(handlerInput) {
- return handlerInput.requestEnvelope.request.type === 'LaunchRequest';
- },
- handle(handlerInput) {
- const speech = `Bienvenido al cuestionario Factly. Se te harán 3 preguntas.
- Trata de responder correctamente. Sólo di el número de la respuesta.
- Comencemos. ${buildQuestions(0)} . Las posibles respuestas son las siguientes:
- ${buildAnswers(0)}`;
- handlerInput.attributesManager.setSessionAttributes({ question: 0 });
- return handlerInput.responseBuilder.speak(speech).reprompt(speech).getResponse();
- }};
- const AnswerIntentHandler = {
- canHandle(handlerInput) {
- const request = handlerInput.requestEnvelope.request;
- return request.type === 'IntentRequest' && request.intent.name === 'Answer';
- },
- handle(handlerInput) {
- const choice = getSlotValue(handlerInput.requestEnvelope, 'choice');
- const { question } = handlerInput.attributesManager.getSessionAttributes();
- const responseResult = isCorrectAnswer(question + 1, choice);
- let result = 'Tu respuesta es incorrecta';
- if (responseResult) {
- result = 'Tu respuesta es correcta';
- }
- const speech = `${result}. La siguiente pregunta es ${buildQuestions(question + 1)}. Y
- sus posibles respuestas son ${buildAnswers(question + 1)}`;
- handlerInput.attributesManager.setSessionAttributes({ question: question + 1 });
- return handlerInput.responseBuilder.speak(speech).getResponse();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement