1

나는 LaunchRequest 후에 초기 환영 메시지가 StartGame 함수에서 재생되어 사용자에게 학교를 요청한 다음 SetSchool 인 텐트에 자신의 학교를 말합니다. 그 기술은 메시지를 말합니다. 바로 지금 마지막 부분에 버그가 있으며 디버깅하는 방법을 모르겠습니다.Alexa ASK 람다 버그

오류 : enter image description here

내 코드 : 그것은 여기에 딱 맞는 있도록

/* eslint-disable func-names */ 
/* eslint-disable dot-notation */ 
/* eslint-disable new-cap */ 
/* eslint quote-props: ['error', 'consistent']*/ 
/** 
* This sample demonstrates a simple skill built with the Amazon Alexa Skills 
* nodejs skill development kit. 
* This sample supports en-US lauguage. 
* The Intent Schema, Custom Slots and Sample Utterances for this skill, as well 
* as testing instructions are located at https://github.com/alexa/skill-sample-nodejs-trivia 
**/ 

'use strict'; 

const Alexa = require('alexa-sdk'); 
const questions = require('./question'); 

const ANSWER_COUNT = 4; // The number of possible answers per trivia question. 
const GAME_LENGTH = 10; // The number of questions per trivia game. 
const GAME_STATES = { 
    TRIVIA: '_TRIVIAMODE', // Asking trivia questions. 
    START: '_STARTMODE', // Entry point, start the game. 
    HELP: '_HELPMODE', // The user is asking for help. 
}; 
const APP_ID = undefined; // TODO replace with your app ID (OPTIONAL) 

const languageString = { 
    'en': { 
     'translation': { 
      'QUESTIONS': questions['HS_QUESTIONS_EN_US'], 
      'GAME_NAME': 'Science Bowl', 
      'HELP_MESSAGE': 'I will ask you %s multiple choice questions. Respond with the number of the answer. ' + 
       'For example, say one, two, three, or four. To start a new game at any time, say, start game. ', 
      'REPEAT_QUESTION_MESSAGE': 'To repeat the last question, say, repeat. ', 
      'ASK_MESSAGE_START': 'Would you like to start playing?', 
      ... 
     }, 
    }, 
}; 

const newSessionHandlers = { 
    'LaunchRequest': function() { 
     this.handler.state = GAME_STATES.START; 
     this.emitWithState('StartGame', true); 
    }, 
    'SetSchool': function() { 
     this.handler.state = GAME_STATES.START; 
     this.emitWithState('School', true); 
    }, 
    'AMAZON.StartOverIntent': function() { 
     this.handler.state = GAME_STATES.START; 
     this.emitWithState('StartGame', true); 
    }, 
    'AMAZON.HelpIntent': function() { 
     this.handler.state = GAME_STATES.HELP; 
     this.emitWithState('helpTheUser', true); 
    }, 
    'Unhandled': function() { 
     const speechOutput = this.t('START_UNHANDLED'); 
     this.emit(':ask', speechOutput, speechOutput); 
    }, 
}; 

... 

const startStateHandlers = Alexa.CreateStateHandler(GAME_STATES.START, { 
    'StartGame': function (newGame) { 
     let speechOutput = newGame ? this.t('NEW_GAME_MESSAGE', this.t('GAME_NAME')) + this.t('WELCOME_MESSAGE', GAME_LENGTH.toString()) : ''; 

     this.handler.state = GAME_STATES.START; 
     this.emit(':ask', speechOutput, speechOutput); 
    }, 
    'School': function(newGame) {   
     this.handler.state = GAME_STATES.START; 
     this.response.speak('test'); 
     this.emit(':responseReady'); 
    } 
}); 

exports.handler = function (event, context) { 
    const alexa = Alexa.handler(event, context); 
    alexa.appId = APP_ID; 
    // To enable string internationalization (i18n) features, set a resources object. 
    alexa.resources = languageString; 
    alexa.registerHandlers(newSessionHandlers, startStateHandlers, triviaStateHandlers, helpStateHandlers); // these were defined earlier 
    alexa.execute(); 
}; 

나는 대부분의 코드를 제외. 시도하고 디버깅하고 싶지만 오류 메시지를 보는 방법조차 모릅니다. 나는 무엇을해야합니까?

+0

질문을 확인하십시오 .js. 귀하의 질문 중 하나가 있습니다. 끝? json을 처리하는 동안 이러한 오류가 발생했습니다 ... 또한 cloudwatch에서 로그를 캡처하고 업로드하십시오. –

답변

0

AWS에서 호스팅하는 경우 람다 로그는 CloudWatch에서 찾을 수 있습니다. AWS console open cloudwatch에서 왼쪽 메뉴의 Logs 링크를 클릭하십시오. 거기에서 람다 서비스를 찾을 수 있어야합니다.

귀하의 문제는 상태 별 의도 정의의 문제로 보입니다. 이미 상태를 START로 설정했지만 startStateHandlers에는 SetSchool 의도가 정의되어 있지 않습니다.

StartGame 핸들러에서 응답을 내기 전에 SetSchool 의도가 포함 된 상태로 상태를 재설정하거나 SetSchool 인 텐트 정의를 startStateHandlers에 추가해야 할 수도 있습니다.

+0

Cloudwatch의 경우, 사용하기 위해 특별한 것을 만들어야합니까? 나는 거기에있는 4 개의 람다 함수 중 1 개만을 봅니다. –