amazon-web-servicesaws-lambdaaws-lex

AWS Lex: An error has occurred: Invalid Lambda Response: Lambda response elicited for an invalid slot name ​


Using a validation hook for AWS lex. If i try to elicit slot, lex fails with:

An error has occurred: Invalid Lambda Response: Lambda response elicited for an invalid slot name ​

Below is my lex event and response from my lambda function. I have 2 slots, topping and crust. Topping was the first slot already given by client. Crust was the missing slot.

I have reviewed most of AWS documentation, stackoverflow and other tutorials but I can't seem to break past this..anyone have any idea?

LexEvent:

{
    "messageVersion": "1.0",
    "invocationSource": "DialogCodeHook",
    "userId": "cbzn2ql6dl59dro",
    "sessionAttributes": {},
    "outputDialogMode": "Text",
    "currentIntent": {
        "name": "Pizza",
        "slots": {
            "topping": "Chicken"
        },
        "confirmationStatus": "None"
    },
    "bot": {
        "name": "PizzaMaker",
        "alias": "$LATEST",
        "version": "$LATEST"
    }
}

Response from Lambda

{
    "sessionAttributes": {},
    "dialogAction": {
        "type": "ElicitSlot",
        "message": {
            "contentType": "PlainText",
            "content": "What type of crust do you want?"
        },
        "intentName": "Pizza",
        "slotToElicit": "​Curst",
        "slots": {
            "topping": "Chicken"
        }
    }
}

Solution

  • I tried validating your Lambda response structure using JSONLint and noticed that there is an additional symbol included in the value for the slotToElicit key which is otherwise invisible. This would point to why Lex is unable to find the slot name.