async handle()

in lambda/src/index.ts [143:200]


    async handle(handlerInput) {
        const dialogState = Alexa.getDialogState(handlerInput.requestEnvelope)
        const confirmationStatus = (handlerInput.requestEnvelope.request as IntentRequest).intent.confirmationStatus
        console.log(handlerInput)

        if (dialogState !== 'COMPLETED') {
            // ダイアログモデルのスロット質問中の場合
            return handlerInput.responseBuilder
                .addDelegateDirective()
                .getResponse();
        } else {
            // ダイアログモデルのスロットが全て埋まった場合
            if (confirmationStatus !== 'CONFIRMED') {
                // 予約確認Alexa応答に対して「いいえ」発話時
                // 予定登録キャンセル
                return handlerInput.responseBuilder
                    .speak('予定の登録をキャンセルします')
                    .withShouldEndSession(true)
                    .getResponse();
            }
            const detail = {
                name: Alexa.getSlotValue(handlerInput.requestEnvelope, "Name"),
                date: Alexa.getSlotValue(handlerInput.requestEnvelope, "CheckInDate"),
                time: {
                    start: Alexa.getSlotValue(handlerInput.requestEnvelope, "TimeStart"),
                    end: Alexa.getSlotValue(handlerInput.requestEnvelope, "TimeEnd")
                }
            }

            const currentRegularSchedules = await garoxaController.getCurrentRegularSchedule(detail)
            if(currentRegularSchedules.length > 0){
                const speakFirst = `かぶっている予定が${currentRegularSchedules.length}件あります。`
                let speakSchedules = ""
                currentRegularSchedules.forEach((value)=>{
                    const speakSchedule = `${value.startTime}から${value.endTime}まで${value.subject}があります。\n`
                    speakSchedules += speakSchedule
                })

                garoxaController.detail = detail

                return handlerInput.responseBuilder
                    .speak(speakFirst + speakSchedules + "予定を登録しても大丈夫ですか?")
                    .addConfirmIntentDirective({
                        name: "ConfirmRegisterRegularScheduleIntent",
                        confirmationStatus: "NONE"
                    })
                    .getResponse();
            }

            await garoxaController.registerRegularSchedule(detail)

            // 予約確認Alexa応答に対して「はい」発話時
            return handlerInput.responseBuilder
                .speak('予定を登録しました')
                .withShouldEndSession(true)
                .getResponse();
        }
    }