Skip to content

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?

asked 10 months ago254 views
1 Answer
1
Accepted Answer

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

answered 10 months ago
EXPERT
reviewed 10 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.