Skip to content

Lex + Bedrock: fail to log the correct intent in Cloudwatch

0

i follow the instructions from aws webpage(https://docs.aws.amazon.com/lexv2/latest/dg/built-in-intent-qna.html) to set the QnA intent in Lex bot. the Lex bot show every user question log as missed utterance, even bedrock KB able to return the answer correctly. i go to cloudwatch and discover the resolved.intent always show fallbackintent. i believe that's why the Lex report never work.

aws specialist told me to use cloudwatch custom attributes in bot fulfilment session to log it is a 'QnA intent'. but that particular intent cannot allow custom prompt, which he claimed it is a good practice not using custom prompt in lex and the same time use custom attribute in cloudwatch log.

i find something not right in my mind, why add a cloudwatch custom attribute in Lex need to give up using prompt!? is the lex product not support custom prompt , but prompt is very important to give AI instructions.

1 Answer
0

The issue you're experiencing with Lex and Bedrock integration is a known behavior with the BedrockAgentIntent and QnAIntent. When these intents are fulfilled, they are automatically marked as "Fulfilled" and subsequent interactions often default to the FallbackIntent, which explains why your CloudWatch logs show FallbackIntent instead of the QnAIntent.

This behavior occurs because of how Lex handles intent fulfillment and context management when working with Bedrock integrations. Even though Bedrock is correctly providing answers, Lex's intent resolution system is not maintaining the context properly.

There are several approaches to address this issue:

  1. Use context management in your Lex bot to maintain conversation state by setting output contexts when the BedrockAgentIntent/QnAIntent is fulfilled.

  2. Implement session attributes in Lex to maintain state information between turns. You can set specific attributes when the intent is invoked to track that it's a QnA interaction.

  3. Consider using a Lambda function as a code hook for your intent to help manage the conversation flow and properly log the intent type.

  4. Adjust confidence thresholds for intent recognition to make the QnA intent more likely to be triggered in follow-up utterances.

Regarding your concern about custom prompts and CloudWatch logging: There is indeed a limitation with certain built-in intents like QnAIntent where custom prompts aren't fully supported in the same way as with custom intents. This is a design constraint in the current implementation of these specialized intents that leverage Bedrock's capabilities.

If custom prompts are critical for your use case, you might consider creating a custom intent with Lambda fulfillment that calls Bedrock services directly, giving you more control over both the prompts and the logging, though this requires more implementation work.
Sources
Lex BedrockAgentIntent controlling Fulfilled | AWS re:Post
AWS Lex Bot QnAIntent available in German? | AWS re:Post
Amazon Lex API Call Fails: "Invalid Bot Configuration: Amazon Lex could not access your Amazon Bedrock Agent" | AWS re:Post

answered a year ago

  • but it is an issue that Lex not allow prompt when using build in intent. any bypass?

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.