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" } ], }

질문됨 일 년 전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
전문가
답변함 일 년 전
  • 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
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠