Skip to content

Amazon connect cant invoke amazon lexv2

0

I have a test amazon connect configuration where, amazon connect invokes a lexv2 bot and the lex bot returns a quick reply custom payload. The issue is connect logs show this error:

"ErrorDetails": {
 "ErrorCode": "com.amazonaws.deepsense.runtimeservice.v2.DependencyFailedException",
 "Message": "Unable to write to callback destination."
 },

I have no idea what this means.

Things that I have looked at:

  • Adding the correct bot alias in connect
  • Testing just the lex bot independently from the lexv2 console
  • Checking if lambda has the correct resource based permissions to be invoked from lexv2
  • Checking if i have created everything in the same region
  • If my answer was helpful, I would appreciate it if you could mark it as the accepted answer.

2 Answers
1

The error "Unable to write to callback destination" typically indicates that Amazon Lex is having trouble sending the response back to Amazon Connect. This is often related to permissions or configuration issues between the services.

Here are some key areas to investigate:

Service-Linked Role Permissions: Verify that Amazon Connect has the necessary service-linked role with permissions to interact with Amazon Lex V2. The Connect service needs proper IAM permissions to invoke Lex and receive responses back.

Bot Alias Association: Double-check that you've associated the correct Lex V2 bot alias with your Amazon Connect instance through the Connect console (not just added it to the contact flow). The bot must be explicitly added to your Connect instance under "Contact flows" > "Amazon Lex" settings.

Custom Payload Format: Since you mentioned using quick reply custom payloads, ensure the payload format is compatible with Amazon Connect. Connect has specific requirements for custom payloads, and malformed responses can cause callback failures. Verify that your custom payload structure follows Connect's expected format.

Lambda Function Response: If your Lex bot uses Lambda for fulfillment, ensure the Lambda function is returning responses in the correct format that Lex expects. Even though Lambda has the right permissions to be invoked by Lex, an improperly formatted response could cause issues when Lex tries to relay it back to Connect.

Contact Flow Configuration: Review your contact flow to ensure the "Get customer input" block is properly configured with the correct Lex V2 bot and that error handling branches are set up to capture any failures.

Try testing with a simpler Lex response (without custom payloads) to isolate whether the issue is specifically related to the custom payload format or a more fundamental connectivity problem.

answered a month ago

EXPERT

reviewed a month ago

    • I have some name capture lex bots at the beginning of the flow, they work
    • Tested with a simple plain text response from lambda, still does not work
    • I am using the correct bot alias in the get customer input block and the same alias is added in the connect instance
1

Regarding your last comment: Since the first name capture bots in your flow work, we can completely rule out general IAM/permission issues between Connect and Lex.

Based on your tests, the issue almost certainly lies in one of two areas:

1. The Lambda Response Format (Most Likely) You mentioned testing with a "simple plain text response from lambda". This is a common trap. Amazon Lex V2 strictly requires your Lambda function to return a very specific JSON structure. It cannot process a plain string or generic text return. If the JSON does not contain the required sessionState and a valid dialogAction (such as Close, Delegate, or ElicitSlot), Lex fails to parse it and Connect throws the exact Unable to write to callback destination error you are seeing.

👉 Action: Double-check your Lambda return payload. Ensure it perfectly matches the Lex V2 Lambda response format.

2. Missing Language/Locale Attribute in the Flow Sometimes, earlier bots in a flow work because they ride on the default system language, but subsequent bots fail if the locale isn't explicitly passed. Lex V2 is extremely strict about locale matching (e.g., en-US vs en-GB).

👉 Action: Right before your failing Get customer input block, add a Set voice block and check the "Set language attribute" box. Alternatively, use a Set contact attributes block to explicitly set the LanguageCode system attribute to match your Lex bot's exact locale.

If you are still stuck after checking the locale, could you share a sanitized JSON snippet of exactly what your Lambda function is returning to Lex?

EXPERT

answered a month 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.