An AI-powered customer support query classifier using AWS Bedrock and DynamoDB. This application automatically categorizes customer support queries into predefined categories using AWS Bedrock's AI capabilities and stores the classification history in DynamoDB.
graph TD
A[API Gateway] --> B[Lambda Function]
B --> C[AWS Bedrock]
B --> D[DynamoDB]
B --> E[CloudWatch Logs]
-
API Gateway
- REST API endpoints for query analysis, history retrieval, and statistics
- Endpoints:
- POST /analyze - Analyze customer support queries
- GET /history - Retrieve classification history
- GET /stats - Get classification statistics
-
Lambda Function
- Node.js 18.x runtime
- Handles request processing and business logic
- Integrates with AWS Bedrock and DynamoDB
- Memory: 256MB
- Timeout: 30 seconds
-
AWS Bedrock
- AI model for query classification
- Used for natural language processing and categorization
- Requires appropriate IAM permissions
-
DynamoDB
- Table:
support-classifications - Schema:
- Partition Key:
query_id(String)
- Partition Key:
- Billing Mode: PAY_PER_REQUEST
- Stores classification history and results
- Table:
-
CloudWatch
- Logs Lambda function execution
- Monitors application performance
- Tracks errors and debugging information
- Node.js 18.x or later
- AWS CLI configured with appropriate credentials
- Docker Desktop (for local development)
- AWS SAM CLI
- AWS Account with access to:
- AWS Bedrock
- DynamoDB
- Lambda
- API Gateway
- CloudWatch
-
Install dependencies:
npm install
-
Build the TypeScript code:
npm run build
-
Build the SAM application:
npm run sam:build
-
Start the local API server:
sam local start-api -
Test the endpoints:
# Analyze a query curl -X POST http://127.0.0.1:3000/analyze \ -H "Content-Type: application/json" \ -d '{"query": "I cannot log in to my account"}' # Get classification history curl http://127.0.0.1:3000/history # Get classification statistics curl http://127.0.0.1:3000/stats
-
Deploy to AWS:
npm run sam:deploy
-
Follow the guided deployment process in the SAM CLI
DYNAMODB_TABLE: DynamoDB table name for storing classifications
The Lambda function requires the following permissions:
- DynamoDB CRUD operations on the
support-classificationstable - AWS Bedrock
InvokeModelpermission - CloudWatch Logs permissions
.
├── src/
│ ├── handlers/ # Lambda function handlers
│ ├── services/ # Business logic services
│ ├── utils/ # Utility functions
│ └── index.ts # Main entry point
├── template.yaml # SAM template
├── package.json # Project dependencies
└── tsconfig.json # TypeScript configuration
Run the test suite:
npm test- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.