- π€ AI-Powered Conversations - Intelligent responses using Amazon Bedrock Titan models
- β‘ Serverless Architecture - Scalable and cost-effective AWS infrastructure
- π RESTful API - Clean API Gateway integration with CORS support
- π± Responsive Web Interface - Modern HTML/CSS/JavaScript frontend
- π Secure Access - IAM roles and permissions for secure operations
- π¬ Real-time Chat - Interactive conversational interface
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β AWS Amplify β β Amazon S3 β β API Gateway β
β (CI/CD + β β (Static β β (REST API + β
β Hosting) β β Assets) β β CORS) β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β β
βββββββββββββββββββββββββΌββββββββββββββββββββββββ
β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β AWS Lambda β β Amazon Bedrock β β IAM β
β (Python 3.14) βββββΆβ (Titan LLM) β β (Roles & β
β Function β β β β Permissions) β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
The chatbot follows a serverless architecture pattern using AWS managed services:
- User Interface - Static web frontend hosted on S3/Amplify
- API Gateway - Handles HTTPS requests with CORS configuration
- Lambda Function - Processes requests and manages Bedrock integration
- Amazon Bedrock - Provides AI inference using Titan models
- IAM Roles - Ensures secure service-to-service communication
- Serverless - No infrastructure management required
- Scalable - Automatically handles traffic spikes
- Cost-Effective - Pay only for actual usage
- Secure - IAM-based access control
- Reliable - Built on AWS managed services
| AWS Service | Purpose |
|---|---|
| π IAM | Role-based access control and security |
| β‘ Lambda | Serverless backend processing (Python 3.12) |
| π API Gateway | RESTful API with CORS support |
| π€ Bedrock | AI inference using Titan Text model |
| π¦ S3 | Static website hosting and asset storage |
| π Amplify | CI/CD deployment and hosting |
Frontend: HTML5, CSS3, JavaScript ES6+, Web Speech API
- AWS Account with appropriate permissions
- Modern web browser
-
Clone Repository
git clone https://github.com/julien-muke/bedrock-chatbot.git cd bedrock-chatbot -
Set Up IAM Role
- Create execution role for Lambda
- Attach policies:
AmazonBedrockFullAccess,CloudWatchLogsFullAccess
-
Deploy Lambda Function
- Runtime: Python 3.12
- Handler:
lambda_function.lambda_handler - Timeout: 30 seconds
- Attach IAM role from step 2
-
Configure API Gateway
- Create REST API
- Add
/chatresource with POST method - Enable CORS for all origins
- Deploy to
devstage
-
Enable Amazon Bedrock
- Request access to
amazon.titan-text-express-v1model - Ensure your region supports Bedrock
- Request access to
-
Deploy Frontend
- Option A: Upload
index.htmlto S3 with static hosting - Option B: Deploy with AWS Amplify for CI/CD
- Option A: Upload
-
Update API Endpoint
// In index.html, replace with your API Gateway URL const API_URL = 'https://your-api-id.execute-api.region.amazonaws.com/dev/chat';
The chatbot can handle various types of conversations and queries:
// General Conversations
"Hello, how are you today?"
"Tell me about artificial intelligence"
"What's the weather like?"
// Technical Questions
"Explain machine learning basics"
"How does cloud computing work?"
"What are the benefits of serverless architecture?"
// Creative Tasks
"Write a short story about robots"
"Help me brainstorm project ideas"
"Create a simple poem about technology"import os
BEDROCK_REGION = os.environ.get('AWS_REGION', 'us-east-1')
MODEL_ID = 'amazon.titan-text-express-v1'
MAX_TOKENS = 500
TEMPERATURE = 0.7- Method: POST
- Resource:
/chat - CORS: Enabled for
* - Integration: Lambda Function
- Stage:
dev
const CONFIG = {
API_ENDPOINT: 'https://your-api-gateway.amazonaws.com/dev/chat',
BEDROCK_MODEL: 'amazon.titan-text-express-v1',
MAX_TOKENS: 500,
TEMPERATURE: 0.7
};AI-Chatbot/
βββ index.html # Frontend web interface
βββ lambda_function.py # AWS Lambda backend function
βββ s3-bucket-policy.json # S3 bucket policy configuration
βββ METRICS.md # Performance metrics and analytics
βββ README.md # Project documentation
| Feature | Chrome | Safari | Firefox | Edge |
|---|---|---|---|---|
| Modern JavaScript | β | β | β | β |
| CSS Grid/Flexbox | β | β | β | β |
| Fetch API | β | β | β | β |
| Mobile Responsive | β | β | β | β |
# Serve locally
python -m http.server 8080
# Test API endpoint
curl -X POST https://your-api-gateway.amazonaws.com/dev/chat \
-H "Content-Type: application/json" \
-d '{"message": "Hello", "history": []}'- Lambda: Pay per request (~$0.20 per 1M requests)
- API Gateway: Pay per API call (~$3.50 per 1M calls)
- Bedrock: Pay per token (~$0.0008 per 1K tokens)
- S3: Pay per storage (~$0.023 per GB/month)
- Amplify: Free tier available
- β IAM Roles: Least privilege access
- β CORS Protection: Configured for secure cross-origin requests
- β Input Validation: Sanitized user inputs
- β HTTPS Only: All communications encrypted
- β No Data Persistence: User conversations not stored server-side
- β‘ Response Time: < 2 seconds average
- π± Mobile Score: 95+ Lighthouse performance
- π Availability: 99.9% (AWS SLA)
- π° Cost Efficiency: Serverless pay-per-use model
- Fork the repository
- Create feature branch:
git checkout -b feature/name - Commit changes:
git commit -m 'Add feature' - Push to branch:
git push origin feature/name - Submit pull request
MIT License - see LICENSE file for details.
β Star this repo if it helped you learn programming!
Built with β€οΈ using AWS serverless technologies
Copyright Β© 2025 Dev Anand Jayaraman. All rights reserved.