A comprehensive chatbot application designed to provide users with real-time information and assistance related to Catholic Charities USA's services, powered by Amazon Q Business and featuring a user-friendly interface for seamless interaction.
This application combines natural language processing with a knowledge base of Catholic Charities USA's services and programs, delivering accurate, context-aware responses to user queries. It includes a responsive chat interface, FAQ prompts, and source attribution for transparency. The project is built with a serverless architecture using AWS services, ensuring scalability and ease of deployment.
- AI-powered responses using Amazon Q Business
- Responsive React-based frontend with Material-UI components
- Predefined FAQ prompts for common queries
- Source attribution with clickable links to original content
- Serverless backend with AWS Lambda Function URLs (no API Gateway required)
- Automated deployment via AWS CodeBuild and CloudShell
- Multi-source indexing supporting web content and document uploads
- Anonymous access with CORS-enabled Lambda Function URLs
- Real-time chat interface with enhanced loading indicators
- Document support for PDF, DOCX, XLSX, and CSV files
The application uses a modern serverless architecture:
- Frontend: React application hosted on AWS Amplify
- Backend: AWS Lambda with Function URLs for direct HTTP access
- AI Engine: Amazon Q Business for natural language processing
- Data Sources: S3-based web crawler and document indexing
- Deployment: Automated via AWS CDK and CodeBuild
- Lambda Function URLs provide direct HTTP access with simple, cost-effective operation
- Built-in CORS handling in Lambda functions for seamless cross-origin requests
- Stateless chat operations for improved scalability and reliability
- Enhanced source attribution with support for both web and document sources
.
βββ Backend/ # AWS CDK infrastructure and backend logic
β βββ bin/ # CDK app entry point
β β βββ catholic-charities-cdk.ts
β βββ data-sources/ # Data source files for indexing
β β βββ urls1.txt # URLs for web crawling (Alaska, Alabama, etc.)
β β βββ urls2.txt # Additional URLs for web crawling (New Jersey, etc.)
β β βββ *.pdf, *.docx, *.xlsx, *.csv # Document files for indexing
β βββ lambda/ # Lambda function code
β β βββ lambda_function.py # Chat handler with Function URL support
β βββ lib/ # CDK stack definitions
β β βββ catholic-charities-stack.ts # Main CDK stack with Lambda Function URLs
β βββ buildspec.yml # AWS CodeBuild configuration
β βββ cdk.json # CDK configuration
β βββ deploy.sh # Deployment automation script
β βββ package.json # Backend dependencies and scripts
β βββ package-lock.json # Locked dependency versions
β βββ tsconfig.json # TypeScript configuration
β βββ .gitignore # Git ignore patterns
β βββ README.md # Backend-specific documentation
βββ Frontend/ # React-based web application
β βββ public/ # Static assets and images
β β βββ favicon.ico # Browser favicon
β β βββ index.html # Main HTML template
β β βββ manifest.json # PWA manifest
β β βββ robots.txt # Search engine robots file
β βββ src/ # React source code
β β βββ Components/ # React components
β β β βββ AppHeader.jsx # Application header component
β β β βββ BotReply.jsx # Bot message display component
β β β βββ ChatBody.jsx # Main chat interface with Function URL integration
β β β βββ ChatHeader.jsx # Chat section header
β β β βββ ChatInput.jsx # User input component
β β β βββ CatholicCharitiesLogo.jsx # Custom SVG logo component
β β β βββ FAQExamples.jsx # FAQ prompt buttons
β β β βββ LeftNav.jsx # Sidebar navigation
β β β βββ UserReply.jsx # User message display component
β β βββ utilities/ # Shared utilities and configuration
β β β βββ constants.js # API endpoints and theme constants
β β β βββ createMessageBlock.js # Message object creation utility
β β β βββ theme.js # Material-UI theme configuration
β β βββ App.js # Main React application component
β β βββ App.css # Application styles
β β βββ index.js # React application entry point
β β βββ index.css # Global styles
β βββ package.json # Frontend dependencies and scripts
β βββ package-lock.json # Locked dependency versions
β βββ .gitignore # Git ignore patterns
βββ docs/ # Documentation and assets
β βββ architecture.png # Architecture diagram
βββ LICENSE # Project license
βββ README.md # Project overview and deployment guide
For detailed information about each component:
- Backend: See Backend/README.md for architecture details, Lambda functions, and data source management
- Frontend: See Frontend/README.md for React components, styling, and local development
-
AWS Account with permissions for:
- Amazon Q Business
- AWS Lambda (including Function URLs)
- AWS Amplify
- Amazon S3
- AWS CodeBuild
- IAM role/policy management
-
Amazon Q Business Setup:
- Navigate to Amazon Q Business in AWS Console
- Create an application with anonymous access enabled
- Note the application ID for deployment
-
Open AWS CloudShell:
- Click the CloudShell icon in the AWS Console navigation bar
- Wait for the environment to initialize
-
Clone the Repository:
git clone https://github.com/YOUR-USERNAME/Catholic-Charity-Chatbot.git cd Catholic-Charity-Chatbot/Backend -
Run Deployment Script:
chmod +x deploy.sh ./deploy.sh
-
Provide Configuration:
- GitHub URL: Your forked repository URL
- Project Name: Custom name (default:
catholic-charities) - Other Parameters: Press Enter for defaults
-
Monitor Deployment:
- Check AWS CodeBuild Console for build progress (~15-20 minutes)
- Monitor CloudWatch logs for detailed information
-
Access Application:
- Go to AWS Amplify Console
- Find your application and access the provided URL
- Test with queries like "What does Catholic Charities do?"
-
AWS CLI:
- Install: AWS CLI Installation Guide
- Configure:
aws configure - Verify:
aws --versionandaws sts get-caller-identity
-
Node.js and npm:
- Install Node.js 18+ from nodejs.org
- Verify:
node --versionandnpm --version
-
AWS CDK:
- Install globally:
npm install -g aws-cdk@latest - Verify:
cdk --version
- Install globally:
-
Required AWS Permissions:
- Amazon Q Business (full access)
- AWS Lambda (including Function URLs)
- AWS Amplify
- Amazon S3
- IAM (role and policy management)
- CloudFormation
- EventBridge
Replace the placeholder values in the commands below with your actual values:
<PROJECT_NAME>: Your project name (e.g.,catholic-charities)<AWS_ACCOUNT_ID>: Your AWS account ID (get withaws sts get-caller-identity --query Account --output text)<AWS_REGION>: Your AWS region (e.g.,us-west-2)<AMPLIFY_APP_NAME>: Your Amplify app name (e.g.,<PROJECT_NAME>-frontend)
-
Clone and Setup Backend:
git clone https://github.com/YOUR-USERNAME/Catholic-Charity-Chatbot.git cd Catholic-Charity-Chatbot/Backend npm install npm run build -
Bootstrap CDK Environment:
cdk bootstrap \ --context projectName="<PROJECT_NAME>" \ --context urlFilesPath="data-sources" \ --context dataBucketName="<PROJECT_NAME>-data-<AWS_ACCOUNT_ID>-<AWS_REGION>" \ --context frontendBucketName="<PROJECT_NAME>-builds-<AWS_ACCOUNT_ID>-<AWS_REGION>"
-
Deploy Backend Infrastructure:
cdk deploy CatholicCharitiesStack \ --require-approval never \ --context projectName="<PROJECT_NAME>" \ --context urlFilesPath="data-sources" \ --context dataBucketName="<PROJECT_NAME>-data-<AWS_ACCOUNT_ID>-<AWS_REGION>" \ --context frontendBucketName="<PROJECT_NAME>-builds-<AWS_ACCOUNT_ID>-<AWS_REGION>" \ --outputs-file outputs.json
-
Extract Deployment Outputs:
# Get the Lambda Function URL from CDK outputs cat outputs.json | jq -r '.CatholicCharitiesStack.LambdaFunctionURL' cat outputs.json | jq -r '.CatholicCharitiesStack.FrontendBuildBucketName' # Note these values for the next steps
-
Test Backend Deployment:
# Test the Lambda Function URL health endpoint (replace <LAMBDA_FUNCTION_URL> with actual URL) curl -X GET "<LAMBDA_FUNCTION_URL>" # Test chat endpoint (optional) curl -X POST "<LAMBDA_FUNCTION_URL>" \ -H "Content-Type: application/json" \ -d '{"message": "Hello, what services do you provide?"}'
-
Create Amplify Application:
# Create Amplify app (replace placeholders with actual values) aws amplify create-app \ --name "<AMPLIFY_APP_NAME>" \ --platform WEB \ --environment-variables "REACT_APP_API_BASE_URL=<LAMBDA_FUNCTION_URL>,REACT_APP_CHAT_ENDPOINT=<LAMBDA_FUNCTION_URL>,REACT_APP_HEALTH_ENDPOINT=<LAMBDA_FUNCTION_URL>" \ --query 'app.appId' \ --output text # Note the returned App ID for next steps
-
Create Amplify Branch:
# Create main branch (replace <AMPLIFY_APP_ID> with actual App ID from previous step) aws amplify create-branch \ --app-id "<AMPLIFY_APP_ID>" \ --branch-name "main" \ --stage PRODUCTION \ --environment-variables "REACT_APP_API_BASE_URL=<LAMBDA_FUNCTION_URL>,REACT_APP_CHAT_ENDPOINT=<LAMBDA_FUNCTION_URL>,REACT_APP_HEALTH_ENDPOINT=<LAMBDA_FUNCTION_URL>"
-
Update Amplify Deployer Lambda:
# Get the Amplify Deployer function name from outputs and update it aws lambda update-function-configuration \ --function-name "$(cat outputs.json | jq -r '.CatholicCharitiesStack.AmplifyDeployerFunctionName')" \ --environment "Variables={AMPLIFY_APP_ID=<AMPLIFY_APP_ID>,AMPLIFY_BRANCH_NAME=main}"
-
Build and Deploy Frontend:
cd ../Frontend # Create production environment file (replace <LAMBDA_FUNCTION_URL> with actual URL) echo "REACT_APP_API_BASE_URL=<LAMBDA_FUNCTION_URL>" > .env.production echo "REACT_APP_CHAT_ENDPOINT=<LAMBDA_FUNCTION_URL>" >> .env.production echo "REACT_APP_HEALTH_ENDPOINT=<LAMBDA_FUNCTION_URL>" >> .env.production echo "PUBLIC_URL=" >> .env.production echo "GENERATE_SOURCEMAP=false" >> .env.production # Install dependencies and build npm install npm run build # Verify build if [ ! -f "build/index.html" ]; then echo "β ERROR: Build failed - index.html not found!" exit 1 fi # Create deployment package cd build zip -r ../build.zip . -x "*.DS_Store" "*.map" cd .. # Upload to S3 (replace <FRONTEND_BUILD_BUCKET> with actual bucket name) aws s3 cp build.zip "s3://<FRONTEND_BUILD_BUCKET>/builds/build-$(date +%s).zip" echo "β Build uploaded to S3. Amplify deployment will start automatically." echo "π± Amplify App URL: https://main.<AMPLIFY_APP_ID>.amplifyapp.com"
-
Verify Deployment:
# Check Amplify deployment status (replace <AMPLIFY_APP_ID> with actual App ID) aws amplify list-jobs \ --app-id "<AMPLIFY_APP_ID>" \ --branch-name "main" \ --max-results 1 # Test the application at: https://main.<AMPLIFY_APP_ID>.amplifyapp.com
For easy reference, here are the parameters you need to replace:
| Placeholder | Description | Example |
|---|---|---|
<PROJECT_NAME> |
Your project name | catholic-charities |
<AWS_ACCOUNT_ID> |
Your AWS account ID | 123456789012 |
<AWS_REGION> |
Your AWS region | us-west-2 |
<AMPLIFY_APP_NAME> |
Your Amplify app name | catholic-charities-frontend |
<LAMBDA_FUNCTION_URL> |
Lambda Function URL from step 4 | https://abc123.lambda-url.us-west-2.on.aws/ |
<AMPLIFY_APP_ID> |
Amplify App ID from step 6 | d1a2b3c4d5e6f7 |
<FRONTEND_BUILD_BUCKET> |
Frontend build bucket from step 4 | catholic-charities-builds-123456789012-us-west-2 |
-
Web Content Indexing:
- Add URLs to
Backend/data-sources/urls1.txt - Each URL on a new line
- Supports up to 100 URLs per file
- Add URLs to
-
Document Upload:
- Place PDF, DOCX, XLSX, or CSV files in
Backend/data-sources/ - Files are automatically indexed during deployment
- Supports various document formats
- Place PDF, DOCX, XLSX, or CSV files in
-
Sync Data Sources:
- Navigate to Amazon Q Business Console
- Select your application
- Trigger sync jobs for updated content
-
Chat Interface:
- Access via the Amplify-provided URL
- Use the chat input or click FAQ prompts
- View sources by clicking "Show Sources" under responses
-
API Endpoints:
- Chat:
POSTto Lambda Function URL with{"message": "your question"} - Health Check:
GETto Lambda Function URL for status
- Chat:
User Query β Amplify Frontend β Lambda Function URL β Amazon Q Business β Indexed Content
β β
βββββββββββββββββββββββ Response with Sources ββββββββββββββββ
- User Interface: React frontend hosted on AWS Amplify
- API Layer: Lambda Function URLs with built-in CORS support for direct HTTP access
- AI Processing: Amazon Q Business processes queries against indexed content
- Data Storage: S3 buckets store source documents and web crawler data
- Content Indexing: Automated data source creation and synchronization
- Amazon Q Business: AI-powered chat and content indexing
- AWS Lambda: Serverless compute with Function URLs
- AWS Amplify: Frontend hosting and deployment
- Amazon S3: Document storage and web crawler data
- AWS CodeBuild: Automated deployment pipeline
- EventBridge: Deployment automation triggers
- IAM: Security and access management
QBUSINESS_APPLICATION_ID: Amazon Q Business application identifierDEBUG: Enable detailed error logging (optional)
REACT_APP_API_BASE_URL: Lambda Function URLREACT_APP_CHAT_ENDPOINT: Chat endpoint (same as base URL)REACT_APP_HEALTH_ENDPOINT: Health check endpoint (same as base URL)
-
Lambda Function URL Errors:
- Error: "Function URL not accessible"
- Solution: Verify CORS configuration and Function URL permissions
- Check: Lambda Function URL is properly configured with anonymous access
-
Q Business Integration Issues:
- Error: "Access denied to Q Business"
- Solution: Verify IAM roles and Q Business application permissions
- Check:
QBUSINESS_APPLICATION_IDenvironment variable is set correctly
-
Data Source Sync Problems:
- Error: "Sync job failed"
- Solution: Check URL accessibility and document formats
- Monitor: Amazon Q Business Console for sync job status
-
Frontend Configuration Issues:
- Error: "API endpoints not configured"
- Solution: Ensure environment variables are set in Amplify
- Verify: Function URL is accessible and returns proper CORS headers
-
CDK Bootstrap Issues:
- Error: "CDK bootstrap failed"
- Solution: Ensure AWS credentials are configured and have sufficient permissions
- Check: Run
aws sts get-caller-identityto verify credentials
-
Missing Context Parameters:
- Error: "Context parameter not found"
- Solution: Ensure all required context parameters are passed to CDK commands
- Required:
projectName,urlFilesPath,dataBucketName,frontendBucketName
-
S3 Bucket Name Conflicts:
- Error: "Bucket already exists"
- Solution: Use unique bucket names by including account ID and region
- Format:
${PROJECT_NAME}-data-${AWS_ACCOUNT}-${AWS_REGION}
-
Amplify App Creation Issues:
- Error: "Failed to create Amplify app"
- Solution: Check IAM permissions for Amplify service
- Verify: Ensure the app name is unique in your account
-
Build Upload Issues:
- Error: "S3 upload failed"
- Solution: Verify S3 bucket exists and you have write permissions
- Check: Ensure the build.zip file was created successfully
-
Environment Variable Issues:
- Error: "jq: command not found"
- Solution: Install jq:
sudo apt-get install jq(Linux) orbrew install jq(macOS) - Alternative: Manually extract values from outputs.json
- Check CloudWatch Logs: Monitor Lambda function execution logs
- Verify Environment Variables: Ensure all required variables are set
- Test Function URL: Use curl or Postman to test Lambda Function URL directly
- Monitor Q Business: Check application status and data source sync jobs
- Edit
Backend/data-sources/urls1.txt - Add new URLs (one per line)
- Redeploy or trigger manual sync in Q Business Console
- Place files in
Backend/data-sources/directory - Supported formats: PDF, DOCX, XLSX, CSV
- Redeploy to create new data sources automatically
- Up to 50 data sources per Q Business application
- Up to 100 URLs per web crawler data source
- Document size limits apply per AWS Q Business quotas
- Anonymous Access: Application uses anonymous access for simplicity
- CORS Configuration: Properly configured for cross-origin requests
- IAM Roles: Least privilege access for all AWS services
- Public S3 Access: Data bucket allows public read for document sources
- HTTPS Only: All communications use HTTPS encryption
- Monitor Costs: Track usage of Q Business and Lambda Function URLs
- Update Dependencies: Regularly update Node.js and Python packages
- Review Logs: Monitor CloudWatch for errors and performance issues
- Content Updates: Keep data sources current with regular sync jobs
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Commit changes:
git commit -m "Add your feature" - Push and create a pull request:
git push origin feature/your-feature
This project is licensed under the MIT License.
For support, contact support@catholiccharitiesusa.org.
