Amazon Lex v2 Chatbot session not updating
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!
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.
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.
How can we validate date in Amazon Lex?asked 3 months ago
How to make Agent Handoff in AWS Connect using Lex chatbot?asked 4 months ago
How to disable the Lex error handling for sending contents length higher than 1024 from Slackasked 2 months ago
[Issue] Lambda LexEvent returns "null" values from Lex v2 Requestasked 5 months ago
Amazon Lex ChatBot V2 Console Adding new intents with Import failureasked 3 months ago
Amazon Lex v2 Chatbot session not updatingasked 3 months ago
V2 Lex OrderFlowers Blueprint Lambda Errorasked 2 months ago
What's the best way to monitor Amazon Lex chatbot conversation statistics?Accepted Answerasked 2 years ago
Amazon Connect & Lex V2 Voiceasked 2 months ago
scheduling a AWS lex intent as push notification.asked 6 months ago