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年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ