This project enables automatic SMS notifications via WhatsApp for unread emails using Google App Scripts, Twilio, and an external Node.js server. When a user has unread emails, an SMS is sent to a specified number—typically the email owner—to alert them about their unread messages.
- Email Monitoring: Automatically checks for unread emails in a user's Gmail account.
- SMS Notifications: Sends notification messages through WhatsApp using Twilio's messaging API.
- Customizable Alerts: Users can set which email labels to monitor and define notification intervals.
- A Google Cloud Platform account with access to Google App Scripts.
- A Twilio account with WhatsApp messaging capabilities.
- Node.js installed on your local machine or server.
- Basic understanding of JavaScript and Node.js for server setup.
- Open Google Apps Script and create a new project.
- Paste the provided Google Apps Script code into the script editor.
- Save and name your project.
- Set the Google App Script triggers to run at your preferred interval (e.g., every 5 minutes).
- Sign up or log in to your Twilio account.
- Set up WhatsApp sandbox following the instructions provided in your Twilio dashboard.
- Obtain your Account SID and Auth Token from the Twilio Console.
- Clone the repository to your local machine or server.
- Install necessary dependencies by running:
npm install
- Create an
.env
file in the root directory and add the following environment variables:TWILIO_ACCOUNT_SID=your_account_sid TWILIO_AUTH_TOKEN=your_auth_token TWILIO_WHATSAPP_NUMBER=your_whatsapp_number PORT=your_preferred_port
- Use Ngrok to expose your local server by running:
ngrok http server_port
- Start the server using:
node server.js
- Google App Script (GAS): Google App Script (GAS): Executes periodically to check for unread emails in the Gmail account.
- Data Transfer: Data Transfer: If unread emails are found, GAS sends a request with the email details to the external server hosted via Ngrok.
- SMS Notification: The server processes this data and uses Twilio to send an SMS notification through WhatsApp to the specified user number.
Ensure the system is properly configured to start receiving SMS notifications for unread emails. Check your server and script logs to monitor activity and troubleshoot any issues.
Feel free to fork this project and contribute by submitting a pull request. We appreciate improvements to the codebase, especially in enhancing the robustness of the email checking and SMS sending functionalities.