Amazon Lex v2 Chatbot session not updating

1

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:

  1. User inputs "Hi"
  2. Bot asks for slot "firstName"
  3. User inputs his first name
  4. Lambda validates "firstName"
  5. Valid input -> bot asks for slot "surname", otherwise -> go back to step 2
  6. User inputs his surname (but now slot "firstName" has lost its value in lambda input json)
  7. Lambda validates input for "surname"
  8. 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)
  9. User input his phone number
  10. ...

Any help would be greatly appreciated, thank you very much!

질문됨 2년 전690회 조회
1개 답변
1

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

AWS
답변함 2년 전
  • 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.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠