aws lex lambda currentIntent['slots'] value for slot name changes for some utterances

0

I am very new to lex.

I have a questionnaire workflow setup with lex and lambda, i have slot name answers which set as empty array '[]' on the first time lambda is fired to record the values (my questions state in it).

But i see something weird happening with sometimes for the few words for example i have 4 words (like a multiple choice) some words are "recognized" fine but for other they change/override my slots["answers"] value.

{'messageVersion': '1.0', 'invocationSource': 'DialogCodeHook', 'userId': 'XXXXX', 'sessionAttributes': {'assessmentState': '1', 'sessionId': 'XXXXX'}, 'requestAttributes': None, 'bot': {'name': 'XXXXX', 'alias': 'XXXXX', 'version': 'XXXXX'}, 'outputDialogMode': 'Text', 'currentIntent': {'name': 'XXXXX', 'slots': {'answers': '[]'}, 'slotDetails': {'answers': {'resolutions': [{'value': '[]'}], 'originalValue': '[]'}}, 'confirmationStatus': 'None', 'nluIntentConfidenceScore': 0.95}, 'alternativeIntents': [{'name': 'XXXXX1', 'slots': {}, 'slotDetails': {}, 'confirmationStatus': 'None', 'nluIntentConfidenceScore': None}], 'inputTranscript': 'Not at all', 'recentIntentSummaryView': [{'intentName': 'XXXXX', 'checkpointLabel': None, 'slots': {'answers': '[]'}, 'confirmationStatus': 'None', 'dialogActionType': 'ElicitSlot', 'fulfillmentState': None, 'slotToElicit': 'answers'}], 'sentimentResponse': None, 'kendraResponse': None, 'activeContexts': []} this is my first request (answer to my first question) if you see currentIntent['slots']['answers'] is an '[]' which i set when lambda is invoked first time even before this to render user my first question and for this question i answered 'Not at all' if you see the inputTranscript. which looks all fine but for the next question when i tried to answer with another utterance the event has changed a lot.

{'messageVersion': '1.0', 'invocationSource': 'DialogCodeHook', 'userId': 'XXXXX', 'sessionAttributes': {'assessmentState': '2', 'sessionId': 'XXXXX'}, 'requestAttributes': None, 'bot': {'name': 'XXXXX', 'alias': 'XXXXX', 'version': '23'}, 'outputDialogMode': 'Text', 'currentIntent': {'name': 'XXXXX', 'slots': {'answers': 'Several days'}, 'slotDetails': {'answers': {'resolutions': [], 'originalValue': 'Several days'}}, 'confirmationStatus': 'None', 'nluIntentConfidenceScore': 1.0}, 'alternativeIntents': [{'name': 'XXXXX1', 'slots': {}, 'slotDetails': {}, 'confirmationStatus': 'None', 'nluIntentConfidenceScore': None}, {'name': 'XXXXX2', 'slots': {'foodName': None, 'delayWhen': None, 'confirmation': None, 'barcode': None, 'food': None}, 'slotDetails': {'foodName': None, 'delayWhen': None, 'confirmation': None, 'barcode': None, 'food': None}, 'confirmationStatus': 'None', 'nluIntentConfidenceScore': 0.62}, {'name': 'XXXXX3', 'slots': {'answers': 'Several days'}, 'slotDetails': {'answers': {'resolutions': [], 'originalValue': 'Several days'}}, 'confirmationStatus': 'None', 'nluIntentConfidenceScore': 0.51}, {'name': 'XXXXX5', 'slots': {}, 'slotDetails': {}, 'confirmationStatus': 'None', 'nluIntentConfidenceScore': 0.48}], 'inputTranscript': 'Several days', 'recentIntentSummaryView': [{'intentName': 'XXXXX', 'checkpointLabel': None, 'slots': {'answers': '[{"id": 1, "value": 0}]'}, 'confirmationStatus': 'None', 'dialogActionType': 'ElicitSlot', 'fulfillmentState': None, 'slotToElicit': 'answers'}], 'sentimentResponse': None, 'kendraResponse': None, 'activeContexts': []} but here if you see currentIntent['slots']['answers'] it is supposed to have '[{"id": 1, "value": 0}]' which i set after my 1st question is answered but here it is 'Several days' and if you see recentIntentSummaryView array's element {'intentName': 'XXXXX', 'checkpointLabel': None, 'slots': {'answers': '[{"id": 1, "value": 0}]'},.... this has the value i set in my previous question. as far as my observation go i think it fails for some words and after a build and publish it starts to work which i dont know sometimes looks like magic and sometimes confuses what did i miss.

the slot configuration i used is name: answers, type: AMAZON.streetAddress, prompt: what assessment?

I used type as AMAZON.streetAddress because i had same issue on other intent and i found somewhere that AMAZON.alphaNumeric has some issue ... and change to AMAZON.streetAddress and that intent works fine, this intent also has similar config and lambda code as other but i am lost in what to do or whats happening.

Please help me out, Thanks in advance.

已提問 2 年前檢視次數 1210 次
1 個回答
0

Hello, thank you for reaching out with your query. Based on what I understand there are two concerns here:

  1. Your Lambda code is attempting to use the slots field as a storage variable to keep track of the answers of the questions you are asking the end-user.

  2. You seem to observing inconsistent slot resolution between different bot builds and also between different slot types.

Regarding (1) -> this is not a safe assumption as the slots field is something that is owned by the Lex service and has no guarantee to persist across multiple utterances & associated Lambda invocations depending on what slot value is being elicited. Specifically, if you ask for the same slot to be elicited twice the slot will be overwritten with the latest input from the end-customer.

I would recommend creating a field in the Session Attributes as that is owned by you the bot creator and Lex service will not modify. This will allow you to track the change in the slot.answers value over multiple invocations and execute business logic based on that.

Regarding (2) -> I will ask some SMEs from our team to reach out to you with further questions to help debug.

AWS
已回答 2 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南