5

I am receiving the error:

An error has occurred: Invalid Lambda Response: Received error response from Lambda: Handled. 

from lex from my lambda function, I am trying out the code in https://github.com/awslabs/amz-ai-building-better-bots,

The Lambda function when tried with the test event returns the expected output below, directing lex to elicit the next slot, but lex throws the above error.

Lambda test output:

{
  "sessionAttributes": {},
  "dialogAction": {
    "type": "ElicitSlot",
    "intentName": "cafeOrderBeverageIntent",
    "slots": {
      "BeverageType": "mocha",
      "BeverageStrength": null,
      "Creamer": null,
      "BeverageSize": null,
      "BeverageTemp": null,
      "BeverageExtras": null
    },
    "slotToElicit": "BeverageSize"
  }
}

Looked into the lex developer guide and this response has all the expected fields for the output format,

Should the "fulfillmentState" be sent with the dialogaction elicitslot as well? Currently this is not being sent.

Test event input:

{
  "messageVersion": "1.0",
  "invocationSource": "DialogCodeHook",
  "userId": "test-1",
  "sessionAttributes": {},
  "bot": {
    "name": "CoffeeBot",
    "alias": null,
    "version": "$LATEST"
  },
  "outputDialogMode": "Text",
  "currentIntent": {
    "name": "cafeOrderBeverageIntent",
    "slots": {
      "BeverageType": "mocha",
      "BeverageStrength": null,
      "Creamer": null,
      "BeverageSize": null,
      "BeverageTemp": null,
      "BeverageExtras": null
    },
    "confirmationStatus": "None"
  }
}

enter image description here

Inian
  • 80,270
  • 14
  • 142
  • 161
Harun
  • 51
  • 3
  • 1
    can you log the response that your lambda is sending? – Atul Kumar Apr 22 '19 at 08:24
  • 1
    You do not need fulfillmentState. And what you posted here looks fine, assuming you haven't changed the Lambda function code you linked to. So you should double check the compatibility of that response to your Lex Console. (1) Are all the slots listed and named exactly as they are in the response? No more, no less? (2) Do all of the slots have a "prompt" message filled in? (3) Is the bot named "CoffeeBot", no initials? (4) Did you save intent, build, and then use the test chat in the Lex Console? If all those check out, then view CloudWatch logs for any Lambda errors. – Jay A. Little Apr 22 '19 at 16:15
  • 1
    @AtulKumar The lambda output is the only response I could get from providing the test input. no other output / errors are logged even in cloudwatch – Harun Apr 23 '19 at 05:08
  • 1
    @JayA.Little No, I have not changed anything in the Lambda code. 1. All slots are exactly the same. I pasted all fieldnames side to side and confirmed this. 2. No I did not notice a 'prompt' message in the response. 3. Yes its Coffeebot with no spaces and initials. 4. Yes. yes and Yes and No errors are logged in cloudwatch for the lambda function. Can you point out where does that prompt message come in here. Thanks – Harun Apr 23 '19 at 05:12
  • 1
    The prompts are in the Lex Console, not in the response. [Slot Prompts](https://imgur.com/a/xtDzUMr). Since you don't return a `message` field in the response, then Lex will try to use the prompt matching the slot you are trying to Elicit. If those prompts are not set correctly, it could cause this error. It may be helpful if you screenshot your Console set up. – Jay A. Little Apr 23 '19 at 07:29
  • the elicitslot method does contain messagecontent text that should get sent along with the slot to elicit. You can view the Lex Slot settings in the screenshot here: https://s3.amazonaws.com/querybackup/LexSettings.JPG – Harun Apr 24 '19 at 19:08
  • You may need to add a "message" key & value to the dialogAction object, you can pass ',,,' if you don't want to speak anything, othwerwise add the message you want to prompt the user. And one other thing to check, make sure you return a callback(null, response) where response is your lambda output object. – Dylan Apr 24 '19 at 20:24
  • "Coffeebot" is different from "CoffeeBot" so double check that. Also, the test event input you posted in the question is the one provided with this bot tutorial and only for testing the Lambda function. I'm wondering if what is being sent to your Lambda is not the same. You pasted the slots and those look good, can you show what you have set up in the section just above slots called "Lambda initialization and validation". – Jay A. Little Apr 27 '19 at 06:55
  • The Lambda code you are using logs the actual event with the line `console.log(JSON.stringify(event));` so you should grab that from Cloudwatch and post the real input event. To make it more obvious in Cloudwatch you can change that line to `console.log("EVENT RECEIVED= "+JSON.stringify(event));` – Jay A. Little Apr 27 '19 at 07:03

0 Answers0