aws-solutions / qnabot-on-aws

AWS QnABot is a multi-channel, multi-language conversational interface (chatbot) that responds to your customer's questions, answers, and feedback. The solution allows you to deploy a fully functional chatbot across multiple channels including chat, voice, SMS and Amazon Alexa.
https://aws.amazon.com/solutions/implementations/aws-qnabot
Apache License 2.0
401 stars 253 forks source link

Lex and Connect client throw errors when buttons exceed response limits #593

Closed ihmaws closed 1 year ago

ihmaws commented 1 year ago

Describe the bug QnABot will automatically transform responses that include buttons into the appropriate format using either ResponseCards (for Lex) or InteractiveMessages (for Connect). The solution however, does not adequately defend against the different limits imposed by each of those services.

To Reproduce Create a new QID with a very long card title, or with 7 buttons. You will notice that asking that question through different clients will yield different responses, not utilize the true maximum provided by those services, and may error out.

Expected behavior Response should be returned without erroring out, a warning should be logged if response was truncated, and solution should utilize the maximum limits provided by each service.

Please complete the following information about the solution:

Invalid Lambda Response: Received invalid response from Lambda: Cannot construct instance of AutoValue_ImageResponseCard$Builder, problem: ImageResponseCard Title is not in range <1,250> at [Source: (String)"{"sessionState":{"sessionAttributes":{"qnabotcontext":"{\"previous\":{\"qid\":\"Button.Test\",\"q\":\"show buttons\"},\"navigation\":{\"next\":\"\",\"previous\":[],\"hasParent\":true}}","appContext":"{\"altMessages\":{},\"responseCard\":{\"version\":\"1\",\"contentType\":\"application/vnd.amazonaws.card.generic\",\"genericAttachments\":[{\"title\":\"https://interactive-msg.s3-us-west-2.amazonaws.com/fruit_34.3kb.jpghttps://interactive-msg.s3-us-west-2.amazonaws.com/fruit_34.3kb.jpghttps://intera"[truncated 5571 chars]; line: 1, column: 6068]

Screenshots

image
ihmaws commented 1 year ago

Fixed as of v5.3.2