Amazon Lex v2 Chatbot session not updating
Hello,
I am trying to make a Lex Chatbot with lambda validations in .NET, if the slot input is valid it should ask for the "slotToElitict" in "proposedNextState" by the bot itself otherwise I re-elicit the slot.
My problem comes when the user input is valid, I pass a json response with no problem but when the next user input is received, all the values from the previous session are lost, so it keeps asking for the same two slots every time. I have tried storing the values from the previous slots and passing them to the json response if the input is valid but it doesn't work, I have also tried using "AmazonLexRuntimeV2Client.PutSessionAsync" to update the session but I couldn't get it to work either because session ID doesn't exist, even though it's appearing in CloudWatch Logs.
Example Conversation flow:
- User inputs "Hi"
- Bot asks for slot "firstName"
- User inputs his first name
- Lambda validates "firstName"
- Valid input -> bot asks for slot "surname", otherwise -> go back to step 2
- User inputs his surname (but now slot "firstName" has lost its value in lambda input json)
- Lambda validates input for "surname"
- Valid input -> ask for "phoneNumber" , otherwise -> re-ask step 5 (never pass this stage, input json next state proposed is to re-elicit "firstName" because it has no value)
- User input his phone number
- ...
Any help would be greatly appreciated, thank you very much!
Hello,
When using Lamnda code hook, you are expected to have the relevant slot values set in the session state in the Lambda response (post validation). I.e., in step 5 of your flow, ensure value of "firstName" slot is set. Otherwise, Lex bot will assume the first name is not set (perhaps because it didn't pass business validation), and reprompt the user.
Thanks
Relevant questions
How can we validate date in Amazon Lex?
asked 3 months agoHow to make Agent Handoff in AWS Connect using Lex chatbot?
asked 4 months agoHow to disable the Lex error handling for sending contents length higher than 1024 from Slack
asked 2 months ago[Issue] Lambda LexEvent returns "null" values from Lex v2 Request
asked 5 months agoAmazon Lex ChatBot V2 Console Adding new intents with Import failure
asked 3 months agoAmazon Lex v2 Chatbot session not updating
asked 3 months agoV2 Lex OrderFlowers Blueprint Lambda Error
asked 2 months agoWhat's the best way to monitor Amazon Lex chatbot conversation statistics?
Accepted Answerasked 2 years agoAmazon Connect & Lex V2 Voice
asked 2 months agoscheduling a AWS lex intent as push notification.
asked 6 months ago
The issue is that I already tried to set the slot values in the Lambda response, but on the next user input, those values I already set disappear, even if Lex accepted the JSON correctly or even if the slot value was encoded. For example: in step 5, I set an encoded "firstName" value, Lambda accepts it correctly, but when step 6 is triggered, the "firstName" slot goes back to null if I check CloudWatch logs.
I'm returning a JObject (Newtonsoft.JSON) that represents a JSON rather than a direct string representation of a JSON as I've seen elsewhere. could this be a problem? Apparently Lambda accepts it just fine and the JSON it produces is valid.
Maybe I'm doing something wrong or just Lex doesn't store session state and I have to track and validate everything myself but that doesn't seem to be the case as I've seen Python-JavaScript examples without this problem.