Skip to content

This repo contains a CloudFormation template that sets up the infrastructure for a Bedrock-Powered Chatbot. It includes parameters for S3 bucket, DynamoDB table, Bedrock model ID, and Lex bot name. The resources defined include an Amazon Lex bot, IAM roles, a Lambda function for processing user input, and an API Gateway to expose the chatbot

Notifications You must be signed in to change notification settings

tukue/AIBasedChatBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bedrock-Powered Chatbot

Overview
--------
This project implements a chatbot interface that leverages AWS Bedrock for natural language processing and knowledge retrieval. The chatbot is built using various AWS services including Amazon S3, AWS Bedrock, Amazon DynamoDB, Amazon Lex, AWS Lambda, and Amazon API Gateway.

Architecture
------------
The chatbot system consists of the following components:
1. S3 Bucket: Stores the training data for the Bedrock model.
2. AWS Bedrock: Provides the foundation model for natural language understanding and generation.
3. DynamoDB Table: Stores chat interactions and serves as a knowledge base.
4. Amazon Lex: Handles natural language understanding and manages conversation flow.
5. Lambda Function: Processes user input, interacts with Bedrock, and manages data storage.
6. API Gateway: Exposes the chatbot interface via a RESTful API.

Prerequisites
-------------
- AWS Account with appropriate permissions
- AWS CLI installed and configured
- Basic understanding of AWS services and CloudFormation

Deployment
----------
1. Clone this repository to your local machine.

2. Navigate to the project directory:
   cd bedrock-powered-chatbot

3. Update the CloudFormation template (template.yaml) with your specific parameters:
   - Replace YOUR_BEDROCK_MODEL_ID with your actual Bedrock model ID.
   - Modify any other parameters as needed (e.g., S3 bucket name, DynamoDB table name).

4. Deploy the CloudFormation stack:
   aws cloudformation create-stack --stack-name bedrock-chatbot --template-body file://template.yaml --capabilities CAPABILITY_IAM

5. Wait for the stack creation to complete. You can monitor the progress in the AWS CloudFormation console.

Usage
-----
Once the deployment is complete, you can interact with the chatbot using the API Gateway endpoint.

1. Retrieve the API endpoint URL from the CloudFormation outputs:
   aws cloudformation describe-stacks --stack-name bedrock-chatbot --query "Stacks[0].Outputs[?OutputKey=='ChatbotApiUrl'].OutputValue" --output text

2. Send a POST request to the API endpoint with your query:
   curl -X POST https://your-api-endpoint.execute-api.region.amazonaws.com/prod/chat \
   -H "Content-Type: application/json" \
   -d '{"inputTranscript": "What is the capital of France?"}'

3. The API will return the chatbot's response based on the Bedrock model's output.

Customization
-------------
- To modify the chatbot's behavior, update the Lambda function code in the CloudFormation template.
- To add more intents or improve natural language understanding, modify the Lex bot configuration.
- To change the data storage structure, update the DynamoDB table schema and Lambda function accordingly.

Monitoring and Maintenance
--------------------------
- Monitor the Lambda function logs in CloudWatch for any errors or issues.
- Regularly review and update the Bedrock model and training data in S3 to improve the chatbot's performance.
- Check the DynamoDB table to ensure data is being stored correctly and to analyze chat interactions.

Security Considerations
-----------------------
- The current setup uses no authentication for simplicity. For production use, implement appropriate authentication and authorization mechanisms.
- Ensure that all sensitive data (e.g., API keys, model IDs) are stored securely and not hardcoded in the template or Lambda function.
- Regularly review and update IAM roles and policies to adhere to the principle of least privilege.

Contributing
------------
Contributions to improve the chatbot are welcome. Please follow these steps:
1. Fork the repository
2. Create a new branch (git checkout -b feature/AmazingFeature)
3. Commit your changes (git commit -m 'Add some AmazingFeature')
4. Push to the branch (git push origin feature/AmazingFeature)
5. Open a Pull Request

About

This repo contains a CloudFormation template that sets up the infrastructure for a Bedrock-Powered Chatbot. It includes parameters for S3 bucket, DynamoDB table, Bedrock model ID, and Lex bot name. The resources defined include an Amazon Lex bot, IAM roles, a Lambda function for processing user input, and an API Gateway to expose the chatbot

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published