Is there a way to check the contents of an Amazon Lex V2 event object that is being passed to a lambda function in AWS?

0

To further elaborate, I received this error message while testing a chatbot that uses a lambda function for validation.

Enter image description here

Next, I went to the Cloudwatch logs for the lambda function to view the log which had this error. Error from lambda function's Cloudwatch log

Here is the pertinent line from my code.

if(event.currentIntent.slots.city_str){

My objective is to figure out the details of the event object being passed to the validation lambda function so I can correctly access the parameters and build validation logic for the Lex chatbot. What is the best way to go about this?

1 Answer
1
Accepted Answer

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.

profile pictureAWS
answered a year 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.

Guidelines for Answering Questions