Email-AI is a tool that automates the process of reading, categorizing, and responding to emails in Google and Outlook accounts based on the context using AI. The tool leverages BullMQ for task scheduling and Gemini AI for context understanding and automated replies. The tool is built using TypeScript and Next.js.
- OAuth integration with Gmail and Outlook for secure email access
- Context understanding of emails using Gemini AI
- Automatic email categorization into labels: Interested, Not Interested, More Information
- Automated email replies based on the context
- Task scheduling using BullMQ, Redis
- Connect new email accounts for both Google and Outlook(in progress) using OAuth.
- Send an email to these accounts from another account.
- Showcase the tool reading incoming emails to the connected accounts.
- Categorize the email based on the content and assign a label:
- Interested
- Not Interested
- More Information
- Suggest an appropriate response based on the email content and send a reply. For example:
- If the email mentions interest in knowing more, the reply should ask if they are willing to hop on a demo call by suggesting a time.
- The tool must run automatically without manual endpoint activation.
- Node.js
- NPM or Yarn
- A Google Cloud project with OAuth crede
- Docker Redis or Redis Desktop
- Contact [[email protected]], get the credentials.json file
- OR
- go to [https://console.cloud.google.com/apis/dashboard]
- create a project
- setup O Auth Screen Consent
- set redirect_uris =
http:localhost:3000/oAuth2callback
- Save
- Download the
credential json
file - paste in into file
/src/credentials/credentials.json
- ensure the correctness of file name
- Complete your credentials in
.env
file in root folder
Screen.Recording.2024-06-27.at.7.mp4
ntials
- An Azure app registration for Outlook OAuth credentials
- OpenAI API key
-
Clone the repository:
git clone https://github.com/yourusername/email-ai.git cd email-ai
-
Install dependencies:
npm install
-
Create a
.env
file in the root directory and add the following environment variables:OPENAI_API_KEY=your_openai_api_key GEMINI_API_KEY=your_gemini_api_key GOOGLE_CLIENT_ID=your_google_client_id GOOGLE_CLIENT_SECRET=your_google_client_secret EMAIL=your_gmail_address PASSWORD=your_gmail_password NEXT_PUBLIC_URL=http://localhost:3000 PORT=3000
-
Start the OAuth setup for Gmail:
npm run gmail
-
For subsequent runs, start the application:
node index.js
src/
: Contains the source codeapp/
: App to make frontendcredentilas/
: OAuth setup for Gmail and Outlooklib/
: utitlty functionservices/
: All the servies of gmailgmail-services
: all the services of gmailoutlook-services
: All the services of outlook email
-
OAuth Setup:
- Configures OAuth access for Gmail and Outlook.
- Handles token generation and refresh.
-
Email Processing:
- Reads incoming emails.
- Categorizes emails using OpenAI.
- Assigns labels based on the content.
-
Automated Responses:
- Generates response emails using OpenAI based on the categorized context.
- Sends automated replies to the original sender.
-
Task Scheduling:
- Uses BullMQ to schedule and manage tasks for reading, categorizing, and responding to emails.
- Connect your email accounts (Gmail and Outlook) via OAuth.
- The tool will automatically start checking for new emails every 5 minutes.
- Incoming emails will be read, categorized, and labeled.
- Appropriate responses will be generated and sent back to the sender.
Contributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the MIT License.
## Contact
For any queries, please contact [[email protected]].