Ошибка с Javascript при программировании лямбда-функции для Amazon Lex - PullRequest
0 голосов
/ 11 апреля 2020

Я работаю над простым чат-ботом для проекта класса, и у меня возникают проблемы с указанной ошибкой c:

"An error has occurred: Invalid Lambda Response: Received invalid response from Lambda: Can not construct instance of IntentResponse, problem: The validated object is null at [Source: {"dialogueAction":{"type":"Close","fulfillmentState":"Fulfilled","message":{"contentType":"PlainText","content":"They will take over repetitive tasks which will make the teacher's work more meaniningful."}}}; line: 1, column: 207]"

Я написал лямбда-функцию ниже (я знаю, если еще if может быть неэффективным):

exports.handler = (event, context, callback) => {
    var slotOne = event.currentIntent.slots.slotOne,
        answer = "";

    if(slotOne === "breakthrough") {
        answer = "Georgetown University and IBM"
    } else if(slotOne === "natural language") {
        answer = "Georgetown University and IBM"
    } else if(slotOne === "summit") {
        answer = "They engage in a dialogue with each student and determine the areas where they are falling behind. Then, chatbots use this data to compose an entirely personalized learning program that focuses on trouble subjects."
    } else if(slotOne === "learning program") {
        answer = "They engage in a dialogue with each student and determine the areas where they are falling behind. Then, chatbots use this data to compose an entirely personalized learning program that focuses on trouble subjects."
    } else if(slotOne === "jobs") {
        answer = "They will take over repetitive tasks which will make the teacher's work more meaniningful."
    } else if(slotOne === "classroom") {
        answer = "They will take over repetitive tasks which will make the teacher's work more meaniningful."
    } else if(slotOne === "essay") {
        answer = "Machine-learning agorithms will be able to assess and grade student's writing on a particular subject. This is under development at the Hewitt's Foundation."
    } else if(slotOne === "Hewitt") {
        answer = "Machine-learning agorithms will be able to assess and grade student's writing on a particular subject. This is under development at the Hewitt's Foundation."
    } else if(slotOne === "snatchbot") {
        answer = "There are dozens of platforms that allow the craetion of free chatbots for specific messaging apps. Snatchbot is a great example of an easy-to-use platform for creating your own chatbot."
    } else if(slotOne === "create") {
        answer = "There are dozens of platforms that allow the craetion of free chatbots for specific messaging apps. Snatchbot is a great example of an easy-to-use platform for creating your own chatbot."
    }

    callback(null, {
        "dialogueAction": {
            "type": "Close",
            "fulfillmentState": "Fulfilled",
            "message": {
                "contentType": "PlainText",
                "content": answer
            }
        }
    })
}

В качестве руководства мой профессор предлагает нам следовать учебному руководству, в котором я получил функцию обратного вызова, из которой, по-видимому, и происходит ошибка. Вы можете увидеть исходный код на видео с отметкой времени: https://youtu.be/Jg_SsZGYmr0?t=225

Этот класс на самом деле не класс программирования, а класс по теории и приложениям искусственного интеллекта. Я провел некоторое исследование о том, как используется функция обратного вызова, и попытался обойти «ноль», но мои знания о функциях обратного вызова (и JS в целом) мимолетны. Будем благодарны за любую помощь, которую вы можете оказать!

Спасибо!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...