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の処理中にこのようなエラーが発生しました...また、クラウドウォッチからログを取得してアップロードします –

答えて

0

AWSでホストしている場合、LambdaログはCloudWatchにあります。 AWSコンソールからcloudwatchを開き、左側のメニューの[Logs]リンクをクリックします。そこからあなたのラムダサービスを見つけることができるはずです。

あなたの問題は、状態ごとのインテント定義の問題であるようです。 すでに状態をSTARTに設定していますが、startStateHandlersにはSetSchoolインテントが定義されていません。

StartGameハンドラでレスポンスを送信する前に、SetSchoolインテントが含まれている状態にリセットするか、startStateHandlersにSetSchoolインテント定義を追加する必要があります。

+0

クラウドウォッチについては、それを使用するために特別なものを作成する必要がありますか?私はそこにある4つのラムダ関数のうちの1つのみを見ます。 –

関連する問題