Skip to content

Internal service error when calling Lex/Lambda bot from AWS Connect flow

0

Dear experts, I keep getting errors like below: { "Results": "Error", "ContactId": "REDACTED", "ContactFlowId": "REDACTED", "ContactFlowName": "Gen-AI dialog", "ContactFlowModuleType": "GetUserInput", "Identifier": "INTENTION FROM LEX", "Timestamp": "2025-07-24T07:43:14.878Z", "ErrorDetails": { "ErrorCode": "InternalFailure", "Message": "Internal service error occurred" }, "ModuleExecutionStack": [ "REDACTED", "REDACTED" ] }

It occurs only if there were no calls for some time (cold start problem?). I have the impression it started occurring after we have configured all lambdas to use SnapStart with PublishedVersions. We did it in order to decrease the warm-up delay. Unfortunately turning this option back to None didnt eliminate the error, so it might come from other reason. Thank you in advance for any suggestions. Full logs are available if they might help.

2 Answers
0

The "Internal service error" you're experiencing when calling a Lex/Lambda bot from your AWS Connect flow could be due to several integration issues. Based on the error details, here are some potential causes and solutions:

  1. Lambda Response Format Issues: Your Lambda function might be returning a response that doesn't match what Amazon Lex V2 expects. Ensure your Lambda function returns a properly formatted response with a "sessionState" object and a "messages" array. Each message must have both "contentType" and "content" fields properly filled with non-empty values.

  2. Cross-Account Access: Verify that your Amazon Lex bot and Amazon Connect instance are in the same AWS account. While they can be in different AWS Regions, they must be within the same AWS account for the integration to work properly.

  3. Permissions Issues: The IAM role associated with your Connect instance might not have the necessary permissions to invoke the Lex V2 bot. Check that all required permissions are in place.

  4. Cold Start Problems: As you mentioned, this could be related to cold starts. Even though you've tried configuring SnapStart, there might still be initialization issues. Consider implementing a "warming" mechanism that periodically invokes your Lambda function to keep it warm.

  5. Language Configuration: If you're using multiple languages in your bot, ensure that the language attribute is correctly set in your Connect flow and that your Lex bot properly supports all languages you're using.

To troubleshoot further:

  • Examine CloudWatch logs for both Connect and Lex to look for more detailed error messages
  • Test your Lambda function independently to ensure it returns valid responses
  • Implement error handling in your Lambda function to return meaningful error messages to Lex
  • Verify that resource quotas haven't been exceeded

If the issue persists after checking these points, you may need to contact AWS Support for more in-depth troubleshooting.
Sources
Lex and Connect | AWS re:Post
Amazon Lex language integration failures in my Amazon Connect instance. | AWS re:Post
Invalid Lambda Response: Received invalid response from Lambda: Cannot construct instance of IntentResponse | AWS re:Post
Invalid Lambda Response: Received invalid response from Lambda: Cannot construct instance of IntentResponse | AWS re:Post

answered a year ago

0

We have checked CloudWatch logs and tested Lambda separately. Lambda works fine. Lex with connect as well with one exception: if it was idle too long it fails wgen called for the first time

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.