AI-Powered Gmail Inbox Triage built with Next.js, MongoDB, GPT-4o, and the Gmail API.
SortMail is an AI-powered Gmail inbox management application that intelligently organizes emails using Large Language Models. After securely authenticating with Google OAuth, users can grant access to their Gmail inbox. The application retrieves emails using the Gmail API, analyzes their content through GPT-4o via Mesh API, and automatically classifies them into meaningful categories such as Urgent, Needs Reply, Finance, Work, Personal, and Promotions.
Instead of manually searching through hundreds of emails, SortMail helps users prioritize important conversations and maintain a clean, organized inbox.
- Secure Google OAuth Authentication
- Gmail API Integration
- AI-powered Email Classification
- Intelligent Inbox Triage
- Automatic Smart Tagging
- Priority Detection
- Responsive Dashboard
- MongoDB Data Persistence
- GPT-4o Integration through Mesh API
SortMail automatically classifies emails into categories including:
- Urgent
- Needs Reply
- Early Reply
- Finance
- Work
- Personal
- Promotions
- Newsletters
- Social
- Spam
- Next.js 15
- TypeScript
- Tailwind CSS
- MongoDB
- Google OAuth 2.0
- GPT-4o
- Mesh API
- Gmail API
+------------------+
| User |
+------------------+
|
v
+------------------+
| Next.js App |
| Frontend + APIs |
+------------------+
| |
| |
v v
+-------------+ +-------------+
| Gmail API | | MongoDB |
+-------------+ +-------------+
|
v
+---------------+
| Mesh API |
+---------------+
|
v
+---------------+
| GPT-4o |
+---------------+
|
v
AI Email Classification & Smart Tagging
- Users sign in securely using Google OAuth.
- Gmail API retrieves the user's emails after permission is granted.
- Next.js processes email metadata and content.
- Email content is sent to GPT-4o through Mesh API.
- GPT-4o analyzes and classifies each email.
- Classification results are stored in MongoDB.
- Users can browse their inbox with AI-generated categories and priorities.
sortmail/
│
├── app/
│ ├── (auth)/
│ ├── dashboard/
│ ├── api/
│ └── layout.tsx
│
├── components/
├── lib/
├── hooks/
├── actions/
├── types/
├── public/
├── styles/
├── middleware.ts
├── package.json
├── tsconfig.json
└── README.md
Clone the repository.
git clone https://github.com/your-username/sortmail.gitNavigate to the project directory.
cd sortmailInstall dependencies.
npm installCreate an environment file.
cp .env.example .env.localConfigure your environment variables.
MONGODB_URI=
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
NEXTAUTH_SECRET=
NEXTAUTH_URL=
OPENAI_API_KEY=
MESH_API_KEY=
GMAIL_REDIRECT_URI=Run the development server.
npm run devVisit:
http://localhost:3000
| Variable | Description |
|---|---|
MONGODB_URI |
MongoDB connection string |
GOOGLE_CLIENT_ID |
Google OAuth Client ID |
GOOGLE_CLIENT_SECRET |
Google OAuth Client Secret |
NEXTAUTH_SECRET |
NextAuth secret |
NEXTAUTH_URL |
Application URL |
OPENAI_API_KEY |
GPT-4o API Key |
MESH_API_KEY |
Mesh API Key |
GMAIL_REDIRECT_URI |
Google OAuth Redirect URL |
- AI-generated email replies
- One-click smart reply suggestions
- AI-powered email summaries
- Calendar integration
- Natural language inbox search
- Background synchronization
- Multi-account Gmail support
- User-defined AI labels
- Real-time notifications
- Inbox analytics and productivity insights
Add screenshots for:
- Login Page
- Dashboard
- AI Email Classification
- Tagged Inbox
- Email Details
- Analytics (optional)
Harsh Kharwar
Project: SortMail
Project ID: WK02 – Inbox Triage
This project is licensed under the MIT License.