Welcome to the AI-Powered Ticket Management System! This course is a part of Chaicode youtube video series. This project is a web application that uses AI to automatically categorize, prioritize, and assign support tickets to the most appropriate moderators.
A smart ticket management system that uses AI to automatically categorize, prioritize, and assign support tickets to the most appropriate moderators.
-
AI-Powered Ticket Processing
- Automatic ticket categorization
- Smart priority assignment
- Skill-based moderator matching
- AI-generated helpful notes for moderators
-
Smart Moderator Assignment
- Automatic matching of tickets to moderators based on skills
- Fallback to admin assignment if no matching moderator found
- Skill-based routing system
-
User Management
- Role-based access control (User, Moderator, Admin)
- Skill management for moderators
- User authentication with JWT
-
Background Processing
- Event-driven architecture using Inngest
- Automated email notifications
- Asynchronous ticket processing
- Backend: Node.js with Express
- Database: MongoDB
- Authentication: JWT
- Background Jobs: Inngest
- AI Integration: Google Gemini API
- Email: Nodemailer with Mailtrap
- Development: Nodemon for hot reloading
- Node.js (v14 or higher)
- MongoDB
- Google Gemini API key
- Mailtrap account (for email testing)
-
Clone the repository
git clone <repository-url> cd ai-ticket-assistant
-
Install dependencies
npm install
-
Environment Setup Create a
.env
file in the root directory with the following variables:# MongoDB MONGO_URI=your_mongodb_uri # JWT JWT_SECRET=your_jwt_secret # Email (Mailtrap) MAILTRAP_SMTP_HOST=your_mailtrap_host MAILTRAP_SMTP_PORT=your_mailtrap_port MAILTRAP_SMTP_USER=your_mailtrap_user MAILTRAP_SMTP_PASS=your_mailtrap_password # AI (Gemini) GEMINI_API_KEY=your_gemini_api_key # Application APP_URL=http://localhost:3000
-
Start the main server
npm run dev
-
Start the Inngest dev server
npm run inngest-dev
POST /api/auth/signup
- Register a new userPOST /api/auth/login
- Login and get JWT token
POST /api/tickets
- Create a new ticketGET /api/tickets
- Get all tickets for logged-in userGET /api/tickets/:id
- Get ticket details
GET /api/auth/users
- Get all users (Admin only)POST /api/auth/update-user
- Update user role & skills (Admin only)
-
Ticket Creation
- User submits a ticket with title and description
- System creates initial ticket record
-
AI Processing
- Inngest triggers
on-ticket-created
event - AI analyzes ticket content
- Generates:
- Required skills
- Priority level
- Helpful notes
- Ticket type
- Inngest triggers
-
Moderator Assignment
- System searches for moderators with matching skills
- Uses regex-based skill matching
- Falls back to admin if no match found
- Updates ticket with assignment
-
Notification
- Sends email to assigned moderator
- Includes ticket details and AI-generated notes
-
Start the Inngest dev server
npm run inngest-dev
This will start the Inngest development server at http://localhost:8288
-
Test Ticket Creation
curl -X POST http://localhost:3000/api/tickets \ -H
"Content-Type: application/json" \ -H "Authorization: Bearer YOUR_JWT_TOKEN" \ -d '{ "title": "Database Connection Issue", "description": "Experiencing intermittent database connection timeouts" }'
-
Port Conflicts If you see "address already in use" error:
# Find process using port 8288 lsof -i :8288 # Kill the process kill -9 <PID>
-
AI Processing Errors
- Verify GEMINI_API_KEY in .env
- Check API quota and limits
- Validate request format
-
Email Issues
- Verify Mailtrap credentials
- Check SMTP settings
- Monitor email delivery logs
@inngest/agent-kit
: ^0.7.3bcrypt
: ^5.1.1cors
: ^2.8.5dotenv
: ^16.5.0express
: ^5.1.0inngest
: ^3.35.0jsonwebtoken
: ^9.0.2mongoose
: ^8.13.2nodemailer
: ^6.10.1
we don't accept contributions for this project, as this is a part of a video and code files needs to given as it is.
- Inngest for background job processing
- Google Gemini for AI capabilities
- Mailtrap for email testing
- MongoDB for database