An AI-powered customer support system designed to streamline ticket management and enhance user interactions through intelligent automation.
- User Management: Secure registration, authentication, and role-based access control.
- Ticketing System: Create, view, and manage support tickets efficiently.
- Messaging: Facilitate communication between users and support agents within tickets.
- AI Integration: Leverage Groq's LLaMA 3 model to generate context-aware responses.
- Token Management: Issue and revoke access tokens with expiration handling.
- Pagination: Efficient data retrieval with paginated endpoints for scalability.
- Feedback Loop: Reply to AI-generated messages with human responses and feed them back to the model.
- Backend: Python, FastAPI
- Database: PostgreSQL, SQLAlchemy
- ORM: SQLAlchemy with scoped sessions
- AI Model: Groq's LLaMA 3
- Authentication: JWT Tokens
- Environment Management: Poetry
-
Clone the repository:
git clone https://github.com/RusabKhan/customer_support_assistant.git cd customer_support_assistant -
Install Poetry (if not already installed):
curl -sSL https://install.python-poetry.org | python3 - -
Install dependencies:
poetry install
-
Activate the virtual environment:
poetry shell
-
Configure environment variables:
Create a
.envfile in the root directory:DB_DIALECT=postgresql DB_USER=your_db_username DB_PASSWORD=your_db_password DB_HOST=localhost DB_PORT=5432 DB_NAME=your_db_name GROQ_API_KEY=your_groq_api_key SECRET_KEY=your_secret_key
-
Run the application:
uvicorn main:app --reload
✅ Note: Alembic migrations are triggered automatically when you start the FastAPI app, so you don’t need to run them manually.
Database sessions are managed using a custom DB utility class found in src/utils/db.py. This class uses the with statement to ensure proper session management:
- Commits transactions on success.
- Rolls back transactions on exception.
- Automatically flushes and disposes the session on exit.
This ensures atomicity and clean handling of transactions without leaking sessions or failing silently.
-
User Endpoints:
POST /users/– Register a new user.POST /login/– Authenticate and receive a JWT token.
-
Ticket Endpoints:
POST /tickets/– Create a new support ticket.GET /tickets/– Retrieve a list of tickets with pagination.GET /tickets/{ticket_id}/– Retrieve a specific ticket.
-
Message Endpoints:
POST /tickets/{ticket_id}/messages/– Add a message to a ticket.GET /tickets/{ticket_id}/messages/– Retrieve messages for a ticket.
-
AI Integration:
GET /tickets/{ticket_id}/ai-response/– Generate an AI response for a ticket.POST /tickets/{ticket_id}/ai-feedback/– Submit feedback or a follow-up to the AI-generated response.
To run the project in Docker:
docker-compose up --buildThen go to http://localhost:8000
Contributions are welcome! Please fork the repository and submit a pull request for any enhancements or bug fixes.
This project is licensed under the MIT License.