aws-samples/bedrock-chat

AWS-native chatbot using Bedrock

Bedrock Chat (BrChat) – What it is

Bedrock Chat is a ready‑to‑run, multi‑tenant chatbot platform built on top of Amazon Bedrock and other AWS managed services. It lets you:

  • Create and run chat bots that use foundation models (Claude, Amazon Nova, Llama 3, Mistral, etc.).
  • Add private knowledge to a bot with Retrieval‑Augmented Generation (RAG) – either by uploading documents or by importing an existing Bedrock Knowledge Base.
  • Publish bots to a bot store so other users in the same AWS account can discover and use them, or expose a bot as a stand‑alone API.
  • Run agents that can call external tools or break a request into multiple steps.
  • Control who can create bots via an Amazon Cognito group (CreatingBotAllowed).
  • Analyse usage and mark bots as “essential” for admin oversight.

Why it matters

  • All‑AWS stack – No need to manage servers; the solution wires together DynamoDB, API Gateway, Lambda (FastAPI), OpenSearch Serverless, Cognito, WAF, Step Functions, EventBridge Pipes, Athena, etc.
  • Multi‑tenant knowledge bases – A single shared Bedrock Knowledge Base can serve many bots, with each bot’s documents isolated by metadata, avoiding the 100‑KB limit per account.
  • Production‑ready security – Optional IP‑range restrictions, IPv6 toggle, self‑registration control, Lambda SnapStart for low latency, and fine‑grained IAM.
  • Extensible model list – You can limit the dropdown to a subset of Bedrock models (Claude, Nova, Llama 3, Mistral, DeepSeek) via configuration.
  • Easy deployment – One‑click CloudShell script (bin.sh) or full CDK deployment; supports multiple environments (dev, prod, etc.) with type‑safe parameter.ts.

Core components (high‑level architecture)

Component Role
Amazon Bedrock Provides the large language models used for chat and for generating embeddings for RAG.
Bedrock Knowledge Bases + OpenSearch Serverless Stores documents, runs vector and full‑text search for RAG.
DynamoDB Persists conversation history and bot metadata.
Lambda + API Gateway (FastAPI) Backend API that the React frontend talks to.
Cognito User sign‑up / sign‑in and group‑based permissions.
CloudFront + S3 Serves the React/Tailwind UI.
WAF Optional IP‑address allow‑list/deny‑list.
Step Functions Orchestrates document ingestion and embedding pipelines.
EventBridge Pipes Listens for bot‑deletion events and tears down related CloudFormation stacks.
Athena Lets admins run ad‑hoc queries on the S3 bucket that stores raw data.

Getting started (quick‑start steps)

  1. Enable Bedrock model access in the target region (e.g., us‑east‑1).
  2. Open CloudShell in that region and run:
    git clone https://github.com/aws-samples/bedrock-chat.git
    cd bedrock-chat
    chmod +x bin.sh
    ./bin.sh   # answer the prompts, optionally add flags like --disable-self-register
    
  3. After ~35 minutes the script prints a Frontend URL (CloudFront). Open it, sign up (or have an admin create the user), and you’ll see the chat UI.
  4. Use the UI to create a bot, upload documents or import a Knowledge Base, and start chatting. You can also publish the bot to the store or as an API.

Customisation knobs (optional parameters)

Flag What it does
--disable-self-register Turns off public sign‑up; only Cognito‑created users can log in.
--enable-lambda-snapstart Enables SnapStart for faster cold‑start Lambda responses.
--ipv4-ranges / --ipv6-ranges Restricts access to the UI/API to specific IP CIDR blocks.
--disable-ipv6 Disables IPv6 traffic entirely.
--allowed-signup-email-domains Limits sign‑up to particular email domains.
--bedrock-region Chooses the region where Bedrock models are called.
--globalAvailableModels Whitelists a subset of Bedrock model IDs for the whole deployment.
--cdk-json-override Direct JSON override of any CDK context value (e.g., enable RAG replicas, change logos).

Who should use it?

  • Enterprises that want an internal, secure chatbot platform without building the infra from scratch.
  • Developers looking for a reference implementation of a full‑stack LLM app on AWS.
  • Product teams that need a bot‑store where multiple teams can publish and share specialised assistants.
  • Data‑engineers who want to experiment with RAG pipelines using Bedrock Knowledge Bases.

Limitations & considerations

  • The solution only works in AWS regions where Bedrock, OpenSearch Serverless, and the other listed services are available.
  • By default anyone with the URL can self‑register; production deployments should lock this down with the provided flags.
  • Multi‑tenant Knowledge Bases rely on metadata filtering – ensure your document ingestion adds the correct Bot‑ID tag.
  • Upgrading from V2 to V3 requires following the migration guide; bots created with V2 become unusable otherwise.

Where to learn more

  • Workshop – A step‑by‑step hands‑on lab is provided (link in the README).
  • Architecture diagram – docs/imgs/arch.png visualises the AWS service graph.
  • Agent docs – docs/AGENT.md explains how to enable tool‑calling / multi‑step reasoning.
  • Admin guide – docs/ADMINISTRATOR.md covers bot analytics, essential‑bot flag, and API management.

TL;DR

Bedrock Chat is an AWS‑native, multi‑tenant chatbot platform with RAG, a bot marketplace, and optional agent capabilities. Deploy it with a single script, then customise security, model access, and environments via simple CLI flags or CDK context. It’s a practical, production‑grade example of building generative‑AI applications on Amazon Bedrock.

Related