- Newest
- Most votes
- Most comments
The error you're encountering suggests that your Lambda function is returning a response in an incorrect format for Amazon Lex V2. This typically happens when the response structure doesn't match what Lex V2 expects.
To resolve this issue, you need to ensure your Lambda function returns a properly formatted response. Here's what you should do:
-
Make sure your response includes a "sessionState" object and a "messages" array.
-
In the "sessionState" object, include:
- A "dialogAction" with "type" set to an appropriate value (e.g., "Close" or "ElicitIntent")
- An "intent" object with "name" (matching your intent name), "state", and "confirmationState"
-
In the "messages" array, include at least one message with both "contentType" and "content" fields properly filled.
Here's an example of a correctly formatted response:
{ "sessionState": { "dialogAction": { "type": "Close" }, "intent": { "confirmationState": "Confirmed", "name": "YourIntentName", "state": "Fulfilled" } }, "messages": [ { "contentType": "PlainText", "content": "Your message here" } ] }
Ensure that you're not returning null or empty values for the "content" field in your messages. Always provide a valid content for each message in your response.
By structuring your Lambda response in this format and ensuring all required fields are properly filled, you should resolve the "Invalid Lambda Response" error and successfully integrate your Lambda function with your Lex V2 bot.
Sources
[Invalid Lambda Response: Received invalid response from Lambda: Cannot construct instance of IntentResponse, problem: The validated object is null at Source: (String)" | AWS re:Post
Lex chatbot response for Polly speech file | AWS re:Post
How to add/Method for adding Session Attribute in Amazon Lex bot Event towards Lambda Function | AWS re:Post
