Architecture overview - QnABot on AWS

Architecture overview

This section provides a reference implementation architecture diagram for the components deployed with this solution.

Architecture diagram

Deploying this solution with the default parameters deploys the following components in your AWS account (components with dotted line border are optional).

QnABot on AWS architecture on AWS

QnABot on AWS architecture on AWS

The high-level process flow for the solution components deployed with the AWS CloudFormation template is as follows:

  1. The admin deploys the solution into their AWS account, opens the content designer UI or Amazon Lex web client, and uses Amazon Cognito to authenticate.

  2. After authentication, Amazon API Gateway and Amazon S3 deliver the contents of the content designer UI.

  3. The admin configures questions and answers in the content designer and the UI sends requests to Amazon API Gateway to save the questions and answers.

  4. The Content designer AWS Lambda function saves the input in Amazon OpenSearch Service in a question bank index. If using text embeddings, these request pass through LLMs hosted on Amazon SageMaker or Amazon Bedrock to generate embeddings before being saved into the question bank on OpenSearch.

  5. Chatbot users interact with Amazon Lex via the web client UI, Amazon Alexa, or Amazon Connect.

  6. Amazon Lex forwards requests to the Bot fulfillment Lambda function. Users can also send requests to this Lambda function via Amazon Alexa devices.

  7. The user and chat information is stored in Amazon DynamoDB to disambiguate follow-up questions from previous question and answer context.

  8. The Bot fulfillment AWS Lambda function takes the user’s input and uses Amazon Comprehend and Amazon Translate (if necessary) to translate non-native language requests to the native language selected during the deployment, and then looks up the answer in OpenSearch Service. If using LLM features such as text generation and text embeddings, these requests first pass through various LLMs hosted on SageMaker or Amazon Bedrock to generate the search query and embeddings to compare with those saved in the question bank on OpenSearch.

  9. If no match is returned from the OpenSearch question bank, then the Bot fulfillment Lambda function forwards the request as follows:

    1. If an Amazon Kendra index is configured for fallback, then the Bot fulfillment Lambda function forwards the request to Amazon Kendra if no match is returned from the OpenSearch question bank. The text generation LLM can optionally be used to create the search query and to synthesize a response from the returned document excerpts.

    2. If an Amazon Bedrock Knowledge Base ID is configured, then the Bot fulfillment Lambda function forwards the request to the Amazon Bedrock knowledge base. The Bot Fulfillment Lambda function leverages the RetrieveAndGenerate API Gateway API to fetch the relevant results for a user query, augment the foundational model's prompt, and return the response.

  10. User interactions with the Bot fulfillment Lambda function generate logs and metrics data, which is sent to Amazon Data Firehose and then to Amazon S3 for later data analysis.

  11. The OpenSearch Dashboards can be used to view usage history, logged utterances, no hits utterances, positive user feedback, and negative user feedback, and also provides the ability to create custom reports.