Lambda response not being sent back to Lex

0

Hi, I have a lex bot that is calling a lambda function, the functionality works as expected and the lambda logs is displaying the response just fine but the response is not being sent back to Lex. There are no errors. What am I missing? response = { "sessionState":{ "sessionAttributes":session_attributes, "dialogAction":{ "type":"Close" }, "intent": { "name": intent_name, "state": "Fulfilled" } }, "messages":[ { "contentType":"PlainText", "content":"I have recorded your response" } ], }

已提問 1 年前檢視次數 509 次
2 個答案
0

Your response format seems to be incorrect, which might be the reason why it's not being sent back to Lex.

According to the Amazon Lex documentation, the dialogAction and intent fields should be at the same level in the sessionState object, not nested. The dialogAction field itself should contain the type, fulfillmentState, and message.

Here is an example of a correct response structure:

response = {
  "sessionState": {
    "sessionAttributes": session_attributes,
    "dialogAction": {
      "type": "Close",
      "fulfillmentState": "Fulfilled",
      "message": {
        "contentType": "PlainText",
        "content": "I have recorded your response"
      }
    },
    "intent": {
      "name": intent_name,
      "state": "Fulfilled"
    }
  }
}

Please adjust your response format accordingly and see if that resolves the issue. Note that in the above response format, the message field has been moved under the dialogAction field. The fulfillmentState field has also been added.

It's always important to carefully verify the response structure when working with AWS services, as incorrect structures can cause responses to be dropped without raising explicit errors. I've used the following documentation page as reference: DialogAction

Please try again with this updated response structure and let me know if the issue persists.

profile picture
專家
已回答 1 年前
  • Hi, thanks for your quick response. Is your response specific to Lex V1, I am following the V2 documentation. I am sorry I forgot to mention that my bot is V2.

0

I would recommend checking the permissions attached to the IAM role being used as the Lambda execution role. Amazon Lex defines the service-linked role with predefined permissions you should be using. You can read about what permissions you need in your role here under the Roles and permissions section: https://docs.aws.amazon.com/lambda/latest/dg/services-lex.html

Here is a link where you can read more about the response format if you want to double check that as well, as the response format being invalid will also cause issues: https://docs.aws.amazon.com/lexv2/latest/dg/lambda-response-format.html

profile pictureAWS
已回答 1 年前

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

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

回答問題指南