Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. const LaunchIntentHandler = {
  2. canHandle(handlerInput) {
  3. return handlerInput.requestEnvelope.request.type === 'LaunchRequest';
  4. },
  5. handle(handlerInput) {
  6. const speech = `Bienvenido al cuestionario Factly. Se te harán 3 preguntas.
  7. Trata de responder correctamente. Sólo di el número de la respuesta.
  8. Comencemos. ${buildQuestions(0)} . Las posibles respuestas son las siguientes:
  9. ${buildAnswers(0)}`;
  10.  
  11. handlerInput.attributesManager.setSessionAttributes({ question: 0 });
  12. return handlerInput.responseBuilder.speak(speech).reprompt(speech).getResponse();
  13. }};
  14.  
  15. const AnswerIntentHandler = {
  16. canHandle(handlerInput) {
  17. const request = handlerInput.requestEnvelope.request;
  18.  
  19. return request.type === 'IntentRequest' && request.intent.name === 'Answer';
  20. },
  21. handle(handlerInput) {
  22. const choice = getSlotValue(handlerInput.requestEnvelope, 'choice');
  23. const { question } = handlerInput.attributesManager.getSessionAttributes();
  24. const responseResult = isCorrectAnswer(question + 1, choice);
  25. let result = 'Tu respuesta es incorrecta';
  26.  
  27. if (responseResult) {
  28. result = 'Tu respuesta es correcta';
  29. }
  30.  
  31. const speech = `${result}. La siguiente pregunta es ${buildQuestions(question + 1)}. Y
  32. sus posibles respuestas son ${buildAnswers(question + 1)}`;
  33.  
  34. handlerInput.attributesManager.setSessionAttributes({ question: question + 1 });
  35. return handlerInput.responseBuilder.speak(speech).getResponse();
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement