跳至內容

Invalid Lambda Response: Received invalid response from Lambda: Cannot construct instance of `IntentResponse`, problem: The validated object is null at [Source: (String)"

0

I have added a lambda fulfillment function to my lexv2 bot. the fulfillment function gets the response for the user query from the AWS Qna bot depending on which intent does the user query belong to in the lex v2 bot. But, Im getting an error like this: Invalid Lambda Response: Received invalid response from Lambda: Cannot construct instance of IntentResponse, problem: The validated object is null at [Source: (String)"{"sessionId":"2c422d54eaaf3c9f940361a88ce0147c","dialogAction":{"type":"Close","fulfillmentState":"Fulfilled","message":{"contentType":"PlainText","content":"This is I_qna_intent response from qna"}}}"; line: 1, column: 200] How to fix this?

已提問 1 年前檢視次數 277 次
1 個回答
1
已接受的答案

The error you're encountering suggests that your Lambda function is returning a response in an incorrect format for Lex V2. It appears you're using the older Lex V1 response format, which is not compatible with Lex V2.

To fix this issue, you need to update your Lambda function to return the response in the correct Lex V2 format. Here's how you should structure your response:

  1. The top-level of the response should contain a "sessionState" object and a "messages" array.

  2. Inside "sessionState", include:

    • "dialogAction" with "type" set to "Close"
    • "intent" object with "name" (matching your intent name), "state" set to "Fulfilled", and "confirmationState"
  3. Put your message content in the "messages" array.

Here's an example of how your response should look:

{
  "sessionState": {
    "dialogAction": {
      "type": "Close"
    },
    "intent": {
      "confirmationState": "Confirmed",
      "name": "I_qna_intent",
      "state": "Fulfilled"
    }
  },
  "messages": [
    {
      "contentType": "PlainText",
      "content": "This is I_qna_intent response from qna"
    }
  ]
}

Make sure to adjust the intent name and other details as necessary for your specific bot configuration. By structuring your Lambda response in this format, you should resolve the "Invalid Lambda Response" error and successfully integrate your QnA bot responses with your Lex V2 bot.

Sources
Trouble with Fulfillment response from Lambda for Lex V2 Bot | AWS re:Post
How to add/Method for adding Session Attribute in Amazon Lex bot Event towards Lambda Function | AWS re:Post

已回答 1 年前
專家
已審閱 1 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。