Skip to content

Latest commit

 

History

History
161 lines (119 loc) · 3.79 KB

README.md

File metadata and controls

161 lines (119 loc) · 3.79 KB

Gmail AI Assistant

An automated email response system powered by Google's Gemini AI that intelligently processes and responds to emails based on their content.

🌟 Features

  • Automated Email Analysis: Uses Gemini AI to analyze incoming emails and categorize them
  • Smart Categorization: Automatically labels emails as "Interested", "Not Interested", or "More Information"
  • Automated Responses: Generates contextual responses based on email content
  • Spam/Automation Filter: Automatically filters out automated emails and notifications
  • Gmail Integration: Seamlessly works with Gmail using official APIs
  • Label Management: Creates and manages Gmail labels automatically
  • Rate Limiting: Processes a configurable number of emails per check
  • Interval Processing: Checks for new emails at regular intervals

🚀 Getting Started

Prerequisites

  • Node.js (v16 or higher)
  • TypeScript
  • Gmail Account
  • Google Cloud Project with Gmail API enabled
  • Gemini API Key

Installation

  1. Clone the repository:
git clone https://github.com/pantharshit007/automatedMails.git
cd automatedMails
  1. Install dependencies:
npm install
  1. Create necessary directories:
mkdir tokens
  1. Set up environment variables: Create a .env file in the root directory:
GEMINI_API_KEY=your_gemini_api_key_here
  1. Set up Google Cloud credentials:
    • Create a project in Google Cloud Console
    • Enable Gmail API
    • Create OAuth 2.0 credentials
    • Download the credentials and save as credentials.json in the project root

Configuration

  1. Update the constants in src/index.ts if needed:
const MAX_MAIL: number = 2; // Maximum emails to process per check
const SENDERS_NAME: string = "Your Name"; // Your name for email signatures
const INTERVAL: number = 2 * 60 * 1000; // Check interval (2 minutes)
  1. Customize ignore patterns: Edit the ignore_patterns.json file to add/remove email patterns to ignore.

🛠️ Development

Run in development mode:

npm run dev

Build the project:

npm run build

Start the built version:

npm start

You can also use script.js instead

node src/script.js

📁 Project Structure (temp)

.
├── README.md
├── credentials.json
├── package-lock.json
├── package.json
├── src
│   ├── ai
│   │   └── analyzeEmail.ts
│   ├── config
│   │   └── config.ts
│   ├── emailProcess
│   │   └── email.ts
│   ├── index.ts
│   ├── last_processed.txt
│   ├── script.js
│   ├── spamEmail
│   │   ├── ignore_patterns.json
│   │   └── pattern.ts
│   ├── types.ts
│   └── utils.ts
├── tokens
│   └── token.json
├── tsconfig.json
└── tsconfig.tsbuildinfo

Important

Keep your credentials.json, token.json & .env file secure

⚙️ How It Works

  1. Authentication:

    • Uses OAuth 2.0 for Gmail API authentication
    • Stores and manages tokens automatically
  2. Email Processing:

    • Checks for unread emails at regular intervals
    • Filters out automated emails based on ignore patterns
    • Extracts email content for analysis
  3. AI Analysis:

    • Uses Gemini AI to analyze email content
    • Determines the appropriate category and response
    • Generates contextual replies
  4. Response Handling:

    • Applies appropriate labels to emails
    • Sends automated responses
    • Marks emails as read
    • Updates processing timestamps

⚠️ Limitations

  • Maximum email processing limit per check
  • Rate limiting based on Gmail API quotas
  • Depends on Gemini AI API availability
  • Limited to text-based email content analysis (somewhat)