- Newest
- Most votes
- Most comments
I would recommend printing out the entire event object in in your lambda so you can see the exact structure of the incoming data and match that to your code. You can do this by adding console.log(event) to your code and then running a test event and viewing the logs in the cloudwatch logs.
Also note, you can use a test event in the AWS Lambda console by selecting Test, Configure test event, create new event, and then search for Lex under event name and select one of the sample event objects. This can help you narrow down if your issue is with your code itself, or perhaps there was something misconfigured with Lex.
If your code works with a sample event, I would recommend checking if you have configured slots with Lex or ensure that the permissions between the two services are configured correctly. Either way, printing and viewing the event object from your lambda function will tell you if the way you're trying to access the data is correct or not. I spun up a little test lambda and the line of code you posted seems okay as I was able to use a similar syntax for a test payload and get it selecting values from slots. This leads me to believe something with Lex may not be configured.
Relevant content
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 3 months ago
- AWS OFFICIALUpdated 3 months ago
- AWS OFFICIALUpdated 8 months ago
From adding a console.log(event) to my code, I figured out that the input event object from LexV2 is different from LexV1; therefore, I was getting the "Unhandled" error from my lambda function and the subsequent "TypeError" in the Cloudwatch logs.
After referring to the AWS links at the end of this comment, I was able to fix the error by changing my code to:
https://docs.aws.amazon.com/lexv2/latest/dg/lambda-input-format.html https://docs.aws.amazon.com/lexv2/latest/dg/lambda-response-format.html