How to Build an AI-Powered RAG Chatbot with Amazon Lex, Bedrock, and S3: Complete Guide
By Braincuber Team
Published on March 3, 2026
A D2C brand we work with was spending $2,100/month on a third-party chatbot SaaS that answered customer questions wrong 38% of the time. Wrong return policies. Wrong shipping timelines. Wrong product specs. The chatbot was hallucinating because it wasn't pulling from the company's actual documents — it was guessing based on generic training data. We replaced it with a RAG chatbot running on Amazon Lex + Bedrock + S3 for $47/month. Accuracy went to 94.3%. No coding required. This complete tutorial walks you through building the same thing, step by step.
What You'll Learn:
- How Retrieval-Augmented Generation (RAG) fixes LLM hallucination problems
- Uploading policy documents to an S3 bucket for your knowledge base
- Creating a Bedrock knowledge base with Titan Embeddings G1 and OpenSearch Serverless
- Building an Amazon Lex chatbot with welcome intents and utterances
- Wiring Claude 3.5 Sonnet to Lex via QnAIntent for AI-powered answers
- Testing the chatbot and cleaning up resources to avoid surprise charges
Why RAG Matters (And Why Your Current Chatbot Is Lying)
Large Language Models like GPT-4 and Claude are everywhere. They get some things amazingly right and others very interestingly wrong — hallucinations, where the model generates factually incorrect or fabricated information. Your customer asks "What's your return policy?" and the LLM invents one that sounds plausible but doesn't match your actual policy document.
RAG fixes this. Instead of the LLM guessing from pre-trained data, it retrieves answers directly from your documents — PDFs, Word files, policy pages stored in S3. The generated answers are sourced, accurate, and up-to-date. Think of it like this: instead of your chatbot guessing the answer from a magazine it read 4 years ago, it looks up the answer from your actual company docs in real-time.
Retrieval = Fact-Checked Answers
Instead of generating answers from memory, the RAG system searches your actual documents first. It finds the relevant paragraphs, then generates a response based on what it found. No more invented return policies or made-up shipping times.
Amazon Lex = Conversation Engine
Lex handles the chatbot interface — intents, utterances, voice support with customizable voices, and a pre-built testing UI. It's the same tech behind Alexa. You define what the user says, Lex figures out what they want.
Bedrock = AI Brain
Amazon Bedrock gives you access to foundation models like Claude 3.5 Sonnet and Titan Embeddings without provisioning GPUs or setting up model pipelines. Pick a model, connect it to your knowledge base, done. No ML engineering required.
S3 = Document Storage
Your policy documents, product specs, FAQs, and any reference material lives in S3. Bedrock's knowledge base syncs with this bucket. Update a document in S3, re-sync, and your chatbot immediately knows the latest information. No retraining needed.
Prerequisites Before You Start
| Requirement | Details |
|---|---|
| AWS Account | Logged in as IAM user with admin privileges |
| Bedrock Model Access | Titan Embeddings G1 - Text and Anthropic Claude 3.5 Sonnet |
| Documents | PDF files to serve as your knowledge base (policy docs, FAQs, etc.) |
| Coding Required | None — this is entirely console-based |
The 10-Step RAG Chatbot Build
No coding. No infrastructure setup. Just clicking through AWS consoles in the right order. We've deployed 6 of these for D2C brands handling customer support, product inquiries, and internal HR questions.
Enable Model Access in Amazon Bedrock
Log in to your AWS IAM account with root privileges. Navigate to Amazon Bedrock > Model catalog. Locate Titan Embeddings G1 - Text and Claude 3.5 Sonnet. Click on each model to review details. You need access to both — Titan for converting documents into vector embeddings, Claude for generating natural language answers.
Create an S3 Bucket and Upload Documents
Navigate to Amazon S3 in the AWS console. Create a new bucket with a unique name. Upload your PDF documents — policy files, product specs, FAQ sheets, whatever you want the chatbot to know. If files are zipped, unzip them before uploading. S3 stores the raw documents; Bedrock will index them in the next step.
Create a Knowledge Base in Amazon Bedrock
Go to Bedrock > Build > Knowledge Bases. Click Create. Select "Knowledge base with vector store". Leave IAM permissions as "Create and use a new service role". Choose Amazon S3 as the data source type. Click Next, browse and select your S3 bucket, click Next again. Select Titan Embeddings G1 - Text as the embedding model, choose Amazon OpenSearch Serverless, and click Create Knowledge Base. This takes a few minutes.
Sync the Knowledge Base with Your Documents
After creation, you'll see a message telling you to sync with data sources. Scroll down to the Data source section, select the data source, then click Sync. Wait for completion — a few seconds for small document sets, longer for hundreds of PDFs. This step converts your documents into vector embeddings that the AI model can search through at query time.
Create an Amazon Lex Chatbot
Navigate to Amazon Lex in the AWS console. Click Create bot. Select Create a blank bot under the Traditional creation method. Name your bot (e.g., "support-bot"). Under IAM permissions, select "Create a role with basic Amazon Lex permissions." Under COPPA, select No. Click Next. Add a description, select a voice for text-to-speech (you can play samples), and click Done.
Add a Welcome Intent with Sample Utterances
On the intent creation page, change the Intent name to "WelcomeIntent". Scroll to Sample utterances and add what users might say: "Hi", "Hey", "hello", "Help me". In the Initial response section, type a welcome message like "Hi! Welcome! How can I help you today?" Click Advanced options, check "Wait for users input", and click Update options.
Build and Test the Basic Chatbot
Click Build at the top-right of the screen. Wait for the build to complete. Then click Test. Type "Hi" in the chat window — you should see your welcome response. Click Inspect to verify the WelcomeIntent was triggered. At this point the chatbot only handles greetings — it doesn't have AI capabilities yet. That's the next step.
Add QnAIntent to Enable RAG-Powered AI Answers
Navigate to Add intent > Use built-in intent. Select QnAIntent and give it a name. On the intent page, under QnA configuration, select Claude 3.5 Sonnet as the model. Go to Amazon Bedrock > Knowledge Bases, copy your Knowledge Base ID, and paste it into the "Knowledge base for Amazon Bedrock Id" field. Click Save intent, then click Build again to rebuild the bot with AI capabilities.
Test the AI-Powered Chatbot with Real Questions
Click Test again. Start with a greeting to trigger the WelcomeIntent. Then ask a question that relates to your uploaded documents — e.g., "What items can I expense?" or "What's the return policy?" The chatbot should pull the answer directly from your S3 documents via the Bedrock knowledge base. Try multiple questions. Verify the answers match your actual documents.
Clean Up Resources to Avoid Charges
When you're done testing, delete: the Bedrock knowledge base, the S3 bucket with your documents, and the OpenSearch Serverless vector collection (navigate to Amazon OpenSearch Service > Serverless > Dashboard). These services incur charges even when idle. OpenSearch Serverless alone can cost $23.40/month for a minimum collection. Delete what you don't need in production.
How RAG Architecture Works Under the Hood
Here's the data flow when a user asks your chatbot a question. Understanding this helps you debug when answers aren't accurate.
1. User Query → "What's the return window?" 2. Amazon Lex → Routes to QnAIntent 3. Bedrock KB → Converts query to vector embedding (Titan) 4. OpenSearch → Finds most relevant document chunks 5. Claude 3.5 → Generates answer from retrieved chunks 6. Lex Response → "Returns are accepted within 30 days..."
Adding a Web UI to Your Chatbot
The built-in Lex test console works for development, but for production you'll want a proper web interface. AWS provides an open-source Lex Web UI that you can deploy with CloudFormation. Check the aws-samples/aws-lex-web-ui GitHub repo for step-by-step deployment instructions. It gives you an embeddable chat widget that works on any website.
OpenSearch Serverless Minimum Cost
OpenSearch Serverless collections have a minimum charge of ~$23.40/month even with zero queries. If you're just experimenting, delete the vector collection after testing. For production, the cost is justified — but for a tutorial walkthrough, don't leave it running. We've seen devs get a $147 surprise bill from forgotten OpenSearch collections.
Knowledge Base Sync Gotcha
When you update documents in S3, the chatbot won't automatically know. You must manually re-sync the knowledge base in Bedrock every time you add, update, or remove documents. Forget this step and your bot will keep answering based on old data. We set a calendar reminder for every document update cycle.
Frequently Asked Questions
How much does a RAG chatbot on AWS cost per month?
For a low-traffic D2C support bot handling 500-1,000 queries/month, expect $40-80/month. The major costs are OpenSearch Serverless (~$23/month minimum), Bedrock model invocations (Claude 3.5 at ~$3/1K queries), and S3 storage (negligible for document PDFs).
Can I use my own documents instead of travel policies?
Absolutely. Upload any PDFs, Word documents, or text files to your S3 bucket. Product catalogs, return policies, shipping guidelines, HR handbooks — the chatbot will answer questions from whatever you feed it. The more structured the documents, the better the answers.
Does the chatbot support multiple languages?
Amazon Lex supports multiple languages including English, Spanish, French, German, Italian, Japanese, and more. Claude 3.5 Sonnet can generate responses in almost any language. However, your source documents should match the expected query language for best accuracy.
Can I embed this chatbot on my Shopify store?
Yes. Deploy the AWS Lex Web UI using CloudFormation, then embed the chat widget JavaScript snippet in your Shopify theme's code. It works like any third-party chat widget — sits in the corner of your site and pops up when customers click it.
What happens when the chatbot can't find an answer?
Lex has a built-in FallbackIntent that triggers when no other intent matches. You can configure it to say "I don't have that information, let me connect you with support" and route the conversation to a live agent or email. The chatbot won't make up an answer if RAG has no relevant documents.
Tired of Chatbots That Make Up Answers?
Your customers deserve accurate answers from your actual documents — not hallucinated responses from a generic model. We've deployed RAG chatbots for 6 D2C brands, cutting support ticket volume by 43% on average while improving answer accuracy from ~60% to 94%. If your current chatbot is costing you customers, let us build one that actually works.
