Intelligent Email-to-CRM Automation Platform
NextEdge is an advanced AI-powered CRM integration platform that seamlessly connects Gmail with Salesforce and HubSpot, using Google's Gemini AI to intelligently analyze, classify, and route emails to the appropriate CRM system. Built for sales teams, support agents, and businesses that want to automate their email-to-CRM workflow.
NextEdge eliminates manual CRM data entry by:
- Automatically syncing emails from Gmail
- Analyzing email content using Google Gemini AI
- Classifying emails by intent (sales lead, support case, contact update, etc.)
- Routing emails to the right CRM (Salesforce or HubSpot)
- Creating appropriate CRM records (Leads, Cases, Contacts, Opportunities)
- Maintaining full email context and conversation threads in your CRM
Result: Your sales and support teams never miss a customer interaction, and every email is automatically logged where it belongs.
- Gemini AI Analysis: Advanced email classification using Google's Gemini 1.5 Flash
- Intent Detection: Identifies sales leads, support requests, general inquiries, and more
- Urgency Detection: Automatically prioritizes critical emails for immediate attention
- Sentiment Analysis: Understands customer tone and emotion in communications
- Smart Routing: Routes emails to the correct CRM system based on content and context
- OAuth 2.0 Authentication: Secure, authorized access to Gmail accounts
- Real-time Sync: Automatic polling and webhook support for instant email processing
- Full Email Access: Reads email body, attachments, threads, and metadata
- Thread Tracking: Maintains conversation context across multiple emails
- Label Support: Sync specific Gmail folders and labels
- Multi-Object Support: Creates Leads, Cases, Contacts, and Opportunities
- Custom Fields: Maps email data to custom Salesforce fields
- Thread Management: Updates existing Cases when replies are detected
- Priority Mapping: Sets Case priority based on AI urgency detection
- Rich Descriptions: Includes AI summary + full email content in records
- Contact Management: Creates and updates HubSpot contacts automatically
- Deal Tracking: Generates deals from sales-related emails
- Property Mapping: Syncs email metadata to HubSpot properties
- Activity Logging: Records all email interactions in contact timeline
- Custom Properties: Supports custom HubSpot fields and pipelines
- Guided Onboarding: Step-by-step connection flow for Gmail, Salesforce, and HubSpot
- Live Status Dashboard: Real-time connection status with visual indicators
- OAuth Management: Easy token refresh and re-authorization flows
- Multi-Workspace: Support for multiple organizations and teams
- Access Control: User authentication via Supabase Auth
- Processing Status: Track emails as new, processing, processed, or error
- Inbox Explorer: Browse and search all synced emails
- AI Insights Panel: View classification results and confidence scores
- Quick Actions: Open emails in Gmail or view CRM records directly
- Filters & Search: Find emails by status, sender, date, or content
- Automated Polling: Continuous background sync every 5 minutes
- Webhook Support: Real-time processing via Gmail push notifications
- Queue Management: Reliable job processing with retry logic
- Error Handling: Graceful degradation with detailed error logging
- Rate Limiting: Respects API limits for Salesforce and HubSpot
┌─────────────────────────────────────────────────────────────┐
│ Frontend (React) │
│ - TypeScript, Tailwind CSS, Vite │
│ - OAuth Flows, Dashboard, Email Inbox UI │
└─────────────────┬───────────────────────────────────────────┘
│ REST API / WebSocket
┌─────────────────▼───────────────────────────────────────────┐
│ Backend (FastAPI) │
│ - Python 3.11+, Async/Await │
│ - OAuth Handlers, Email Processing, CRM Sync │
└──┬────────┬─────────┬────────────┬──────────────────────────┘
│ │ │ │
▼ ▼ ▼ ▼
┌──────┐ ┌──────┐ ┌────────┐ ┌──────────┐
│Gmail │ │Gemini│ │Salesf. │ │ HubSpot │
│ API │ │ AI │ │ API │ │ API │
└──────┘ └──────┘ └────────┘ └──────────┘
│
▼
┌─────────────────────────────────────┐
│ Supabase (PostgreSQL) │
│ - Users, Workspaces, Emails │
│ - OAuth Tokens, Processing Logs │
└─────────────────────────────────────┘
- Framework: FastAPI 0.115+
- Language: Python 3.11+
- Database ORM: SQLAlchemy (async)
- Authentication: Supabase Auth + OAuth 2.0
- AI: Google Gemini 1.5 Flash API
- External APIs: Gmail, Salesforce, HubSpot, Zoho
- Framework: React 18+ with TypeScript
- Build Tool: Vite
- Styling: Tailwind CSS + shadcn/ui components
- State Management: Zustand
- HTTP Client: Axios
- Routing: React Router v6
- Primary Database: Supabase (PostgreSQL 15+)
- Caching: Redis (for rate limiting and queues)
- File Storage: Supabase Storage (email attachments)
- Search: PostgreSQL Full-Text Search
- Deployment: Vercel (Frontend), Railway/Render (Backend)
- CI/CD: GitHub Actions
- Monitoring: Sentry (error tracking)
- Secrets Management: Environment variables
- Python 3.11+ (for backend)
- Node.js 18+ and npm (for frontend)
- Git for version control
- Supabase Account (free tier available)
- Google Cloud Project (for Gmail + Gemini APIs)
- Salesforce Developer Account (optional)
- HubSpot Developer Account (optional)
git clone https://github.com/kowsik11/Nextedge_AI.git
cd Nextedge_AIcd backend
python -m venv .venv
# Windows
.\.venv\Scripts\activate
# macOS/Linux
source .venv/bin/activate
pip install -r requirements.txtCreate backend/.env with the following:
# Supabase Configuration
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_KEY=your-supabase-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key
# Google OAuth & APIs
GOOGLE_CLIENT_ID=your-google-client-id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=your-google-client-secret
GOOGLE_REDIRECT_URI=http://localhost:8000/auth/google/callback
# Gemini AI
GEMINI_API_KEY=your-gemini-api-key
# Salesforce OAuth
SALESFORCE_CLIENT_ID=your-salesforce-client-id
SALESFORCE_CLIENT_SECRET=your-salesforce-client-secret
SALESFORCE_REDIRECT_URI=http://localhost:8000/auth/salesforce/callback
# HubSpot OAuth
HUBSPOT_CLIENT_ID=your-hubspot-client-id
HUBSPOT_CLIENT_SECRET=your-hubspot-client-secret
HUBSPOT_REDIRECT_URI=http://localhost:8000/auth/hubspot/callback
# Frontend URL (for CORS)
FRONTEND_URL=http://localhost:5173
# Server Configuration
ENVIRONMENT=development# Initialize Alembic (if needed)
alembic upgrade headpython -m uvicorn app.main:app --reload --port 8000Backend will be available at http://localhost:8000
📖 API Documentation: http://localhost:8000/docs (Swagger UI)
cd frontend
npm installCreate frontend/.env:
VITE_BACKEND_URL=http://localhost:8000
VITE_SUPABASE_URL=https://your-project.supabase.co
VITE_SUPABASE_ANON_KEY=your-supabase-anon-keynpm run devFrontend will be available at http://localhost:5173
NextEdge-dev/
├── backend/
│ ├── app/
│ │ ├── routers/
│ │ │ ├── gmail.py # Gmail API integration
│ │ │ ├── salesforce.py # Salesforce API integration
│ │ │ ├── hubspot.py # HubSpot API integration
│ │ │ ├── google_oauth.py # Gmail OAuth flow
│ │ │ ├── oauth.py # Generic OAuth utilities
│ │ │ ├── pipeline.py # Email processing pipeline
│ │ │ ├── inbox.py # Inbox management
│ │ │ ├── messages.py # Email message handling
│ │ │ ├── gmail_poll.py # Background polling worker
│ │ │ └── hubspot_contact_sync.py
│ │ ├── services/
│ │ │ ├── ai_service.py # Gemini AI integration
│ │ │ ├── token_service.py # OAuth token management
│ │ │ └── email_processor.py # Email analysis logic
│ │ ├── models/ # SQLAlchemy models
│ │ ├── schemas/ # Pydantic schemas
│ │ ├── main.py # FastAPI app entry point
│ │ ├── config.py # Settings and configuration
│ │ └── auth.py # Authentication middleware
│ ├── requirements.txt
│ └── .env
│
├── frontend/
│ ├── src/
│ │ ├── components/
│ │ │ ├── Navigation.tsx
│ │ │ ├── ConnectionCard.tsx
│ │ │ ├── EmailList.tsx
│ │ │ └── StatusBadge.tsx
│ │ ├── pages/
│ │ │ ├── Home.tsx
│ │ │ ├── Workspace.tsx
│ │ │ ├── Inbox.tsx
│ │ │ └── Settings.tsx
│ │ ├── lib/
│ │ │ ├── api.ts # API client
│ │ │ ├── supabase.ts # Supabase client
│ │ │ └── types.ts # TypeScript types
│ │ ├── hooks/ # Custom React hooks
│ │ ├── App.tsx
│ │ └── main.tsx
│ ├── package.json
│ └── .env
│
├── docs/ # Documentation
│ ├── API_integration.md
│ ├── Salesforce_integration.md
│ └── FLOWS.md
│
├── ISSUES_RESOLVED.md # Complete bug fix log
├── EXCLUDED_FILES_SUMMARY.md # Git exclusion list
├── salesforce_integration_plan.md
└── README.md
GET /auth/google- Initiate Gmail OAuthGET /auth/google/callback- Gmail OAuth callbackGET /auth/salesforce- Initiate Salesforce OAuthGET /auth/salesforce/callback- Salesforce OAuth callbackGET /auth/hubspot- Initiate HubSpot OAuthGET /auth/hubspot/callback- HubSpot OAuth callback
GET /gmail/messages- Fetch Gmail messagesPOST /gmail/sync- Trigger manual syncGET /gmail/status- Get Gmail connection status
POST /salesforce/sync- Sync email to SalesforceGET /salesforce/status- Get connection statusPOST /salesforce/create-lead- Create Salesforce LeadPOST /salesforce/create-case- Create Salesforce Case
POST /hubspot/sync- Sync email to HubSpotGET /hubspot/status- Get connection statusPOST /hubspot/create-contact- Create HubSpot contact
GET /pipeline/emails- List processed emailsGET /pipeline/status- Processing statisticsPOST /pipeline/reprocess/{email_id}- Reprocess failed email
GET /inbox/messages- Get inbox messagesGET /inbox/message/{id}- Get message detailsPUT /inbox/message/{id}/status- Update message status
- User signs up via Supabase Auth
- Creates a workspace
- Connects Gmail via OAuth
- Connects Salesforce and/or HubSpot (optional)
Gmail → Fetch Email → Gemini AI Analysis → Classification Decision
↓
┌───────────────┴───────────────┐
▼ ▼
Salesforce Sync HubSpot Sync
(Lead/Case/Contact) (Contact/Deal)
- Lead: Sales inquiries, demo requests, pricing questions
- Case: Support issues, bug reports, complaints
- Contact: General information, follow-ups, networking
- Opportunity: Active deals, contract discussions
- None: Spam, newsletters, internal communications
- Email body + AI summary included in description
- Metadata fields populated (sender, subject, urgency)
- Thread tracking for conversation continuity
- Attachments linked (where supported)
# Backend tests
cd backend
pytest
# Frontend tests
cd frontend
npm run test# Backend linting
ruff check .
black .
# Frontend linting
npm run lint
npm run type-check# Backend
pip install -r requirements.txt
# Frontend
npm run build- OAuth 2.0: Secure authorization for all integrations
- Token Encryption: Sensitive tokens stored encrypted in database
- CORS Protection: Restricted origins for API access
- Rate Limiting: Prevents API abuse
- Data Isolation: Multi-tenant architecture with workspace separation
- No Password Storage: Uses Supabase Auth for user management
- .gitignore Protection: Sensitive files excluded from repository
Files Never Committed:
*.envfiles*tokens.jsonfilescredentials.json- Database backups
- API keys or secrets
See EXCLUDED_FILES_SUMMARY.md for complete exclusion list.
- API Integration Guide - Comprehensive API documentation
- Salesforce Setup - Salesforce-specific configuration
- Workflow Diagrams - Visual workflow explanations
- Issues Resolved - Complete bug fix log (50+ issues)
- Salesforce Integration Plan - Implementation roadmap
- Connect GitHub repository
- Set environment variables
- Deploy main branch
- Configure custom domain (optional)
- Import GitHub repository
- Configure build settings:
- Build Command:
npm run build - Output Directory:
dist
- Build Command:
- Add environment variables
- Deploy
- No deployment needed (managed service)
- Configure Row Level Security (RLS) policies
- Set up database backups
We welcome contributions! Here's how to get started:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and commit:
git commit -m 'Add amazing feature' - Push to your fork:
git push origin feature/amazing-feature - Open a Pull Request
- Follow existing code style (Black for Python, ESLint for TypeScript)
- Write tests for new features
- Update documentation as needed
- Keep commits atomic and well-described
OAuth Redirect Mismatch
- Ensure redirect URIs in Google/Salesforce/HubSpot consoles match your
.envconfiguration - Use exact URLs including protocol (http/https)
Database Connection Errors
- Verify Supabase credentials in
.env - Check if Supabase project is active
- Ensure connection pool isn't exhausted
CORS Errors
- Confirm
FRONTEND_URLin backend.envmatches your frontend URL - Check CORS middleware configuration in
main.py
Token Expiration
- Tokens refresh automatically; if issues persist, reconnect OAuth
- Check token expiry handling in
token_service.py
For more issues and solutions, see ISSUES_RESOLVED.md
- ✅ Gmail Integration (OAuth + Sync)
- ✅ Gemini AI Email Classification
- ✅ Salesforce Integration (Leads, Cases, Contacts)
- ✅ HubSpot Integration (Contacts, Deals)
- ✅ React Frontend with Dashboard
- ✅ Background Email Processing
- ✅ Multi-workspace Support
- ✅ Real-time Status Updates
- 🚧 Zoho Integration (in progress)
- 🚧 Mobile App (planned)
This project is licensed under the MIT License - see the LICENSE file for details.
NextEdge AI Team
- Built with ❤️ for sales and support teams everywhere
- Powered by Google Gemini AI
- Repository: github.com/kowsik11/Nextedge_AI
- Issues: Report a bug or request a feature
- Documentation: See
/docsdirectory - API Docs (local):
http://localhost:8000/docs
- FastAPI - Modern Python web framework
- React - Frontend library
- Supabase - Backend-as-a-Service
- Google Gemini AI - Advanced email analysis
- Salesforce - CRM platform
- HubSpot - CRM & Marketing platform
Last Updated: 2025-11-25 Version: 1.0.0
NextEdge AI - Intelligent Email-to-CRM Automation 🚀