This Node.js application automatically responds to unreplied emails in your Gmail inbox while you're on vacation.
This Node.js application uses the Gmail API to check for new emails in your Gmail inbox, identify unreplied emails, and automatically respond with a predefined message. It also adds a label to the email and moves it to the labeled category. The application repeats this process in random intervals, simulating a vacation auto-responder.
Before using this application, ensure you have the following:
- Node.js installed on your machine
- A Gmail account
- Google Cloud Platform project with the Gmail API enabled
- API credentials in JSON format (Create credentials)
-
Clone this repository to your local machine:
git clone https://github.com/himacharan128/gmailAutoResponder.git cd gmailAutoResponder
-
Install dependencies:
npm install
-
Configure Gmail API:
- Enable the Gmail API and download the credentials.json file from the Google Cloud Console.
- Save the credentials.json file in the project directory.
- Create userSecret.json:
Create a userSecret.json file in the project directory with the following structure:
{ "installed": { "client_id": "<YOUR_CLIENT_ID>", "client_secret": "<YOUR_CLIENT_SECRET>", "redirect_uris": ["urn:ietf:wg:oauth:2.0:oob", "http://localhost"] } }
Run the application with the following command:
npm start
Visit http://localhost:8080 in your browser to authenticate and start the auto-responder.
Adjust the following variables in app.js to customize the behavior:
- LabelName: The label name for auto-replied emails.
- SCOPES: Gmail API scopes for authentication.
- app.js: Main application file with the server setup and Gmail API integration.
- gmailFunctions.js: Module containing functions for interacting with the Gmail API.
- userSecret.json: JSON file containing your OAuth 2.0 client credentials.
- The app processes unreplied emails at random intervals to simulate a real-time vacation response.
- Auto-reply message content can be customized in the sendAutoReply function.