Amazon LEX 在与 Lambda 通信时抛出错误

问题描述 投票:0回答:1

过去 3 天以来,我一直在努力使用 lambda 将逻辑集成到 LEX 中,但它不断向我抛出同样的错误。我已阅读 Lex V2 的 AWS 文档,并(尽我所能)在我的响应逻辑中实现了相同的内容。 错误信息如下:

Invalid Lambda Response: Received invalid response from Lambda: Cannot construct instance of `IntentResponse`, problem: The validated object is null at [Source: (String)"{"dialogAction": {"type": "Close", "fulfillmentState": "Fulfilled"}, "intent": {"name": "Number_Route", "confirmationState": "Confirmed", "state": "Fulfilled"}, "messages": [{"contentType": "PlainText", "content": "Your number is: 123-456-7890"}]}"; line: 1, column: 245]

我尝试了这个,因为我的回复格式是:

answer = {
      "dialogAction": {
        "type": "Close",
        "fulfillmentState": "Fulfilled",
      },
      "intent": {
        "name": intent,
        "confirmationState": "Confirmed",
        "state": "Fulfilled",
      },
      "messages": [
        {
          "contentType": "PlainText",
          "content": f"Your number is: {formatted_number}",
        }
      ],
    }
    return answer

提前致谢

amazon-web-services aws-lambda amazon-lex
1个回答
0
投票

您似乎正在以 Lex V1 格式返回响应。 Lex V2 期望 Lambda 响应采用不同的格式。

请参阅此处Lex V2 开发人员指南以了解适当的响应格式。

© www.soinside.com 2019 - 2024. All rights reserved.