Serge_M
Serge_M

Reputation: 1

My Amazon lex does not send a proper event to my lambda function

enter image description hereWhen setting up my Amazon lex to build a bot, I wrote a lambda function so that I can integrate it with my code. I kept on getting a 'sessionstate' keyerror, I even tried creating a new bot and starting over but it did not change When I checked the log from lex this is what I got

{'key1': 'value1', 'key2': 'value2', 'key3': 'value3'}

It does not have the sessionState or currentIntent, nothing just the values above

[ERROR] KeyError: 'sessionstate'

Traceback (most recent call last):

  File "/var/task/lambda_function.py", line 5, in lambda_handler

    slots= event ['sessionstate']['intent']['slots']

Above is the log of the error

I've been stock here for days now.please how can I solve this problem?

I tried creating a new bot and new lambda function but nothing changed.

Upvotes: 0

Views: 271

Answers (1)

John Rotenstein
John Rotenstein

Reputation: 269500

The 'key1': 'value1' stuff is coming from the Test Event in your Lambda function. I presume you are running your code by pressing the Test button.

Lambda test event

If you wish to test your code against a typical Lex response, then you can change the Test values to match what your code is expecting. Alternatively, call your function through Lex and it will pass the appropriate values to your code.

See also: Interpreting the input event format - Amazon Lex

Upvotes: 1

Related Questions