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!
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.