🛒 How I Got WhatsApp Alerts for Amul Shop Stock Updates Using Gmail + Google Scripts

Like many people who shop from Amul's online store for protein-based products, I signed up to be notified when a Protein Lassi was back in stock. The problem? I was getting email alerts, but I wanted WhatsApp pings — something instant and attention-grabbing.
So I built a little automation that does exactly that.
🔔 The Problem
Amul’s store does a great job sending email notifications for stock availability. But I don’t check my inbox every 5 minutes — WhatsApp, though? That’s always open.
Unfortunately, Amul doesn’t offer native WhatsApp alerts. So I created a custom automation that:
- Watches for a new email from
[email protected]
- Sends me a WhatsApp message with the email content
- Works in under 5 minutes — completely free
✅ The Solution: Gmail + Google Apps Script + Twilio
This guide shows you how to replicate my setup using:
- Gmail filters (to detect Amul alerts)
- Google Apps Script (to read the email)
- Twilio’s WhatsApp API (to send the message)
🧩 What You’ll Need
- A Gmail account
- A Twilio account with WhatsApp Sandbox access
- Basic access to Google Apps Script (free)
🔧 Step-by-Step Guide
1. Create a Gmail Filter for Amul Alerts
- Go to your Gmail inbox
- In the search bar, type:
from:[email protected]
- Click the filter icon on the right
- Click “Create filter”
- Check “Apply the label”, and name it:
TriggerWhatsApp
This ensures only Amul stock alerts get processed by your script.
2. Set Up the Google Apps Script
- Go to Google Apps Script
- Create a new project
- Paste this code:
function checkLabelAndNotify() {
var label = GmailApp.getUserLabelByName("TriggerWhatsApp");
var threads = label.getThreads(0, 10);
for (var i = 0; i < threads.length; i++) {
var thread = threads[i];
if (!thread.isUnread()) continue;
var messages = thread.getMessages();
var message = messages[messages.length - 1];
var sender = message.getFrom();
if (sender.indexOf("[email protected]") === -1) continue;
var subject = message.getSubject();
var body = message.getPlainBody().substring(0, 200);
sendWhatsApp("📩 New email from Amul Estore:\nSubject: " + subject + "\n" + body);
thread.markRead();
thread.removeLabel(label);
}
}
function sendWhatsApp(message) {
var url = "https://api.twilio.com/2010-04-01/Accounts/YOUR_TWILIO_ACCOUNT_SID/Messages.json";
var payload = {
"To": "whatsapp:+YOUR_WHATSAPP_NUMBER",
"From": "whatsapp:+YOUR_TWILIO_SANDBOX_NUMBER", // e.g., +14155238886
"Body": message
};
var options = {
"method": "post",
"payload": payload,
"headers": {
"Authorization": "Basic " + Utilities.base64Encode("YOUR_TWILIO_ACCOUNT_SID:YOUR_TWILIO_AUTH_TOKEN")
}
};
UrlFetchApp.fetch(url, options);
}
3. Replace These Placeholders
Placeholder | Replace With |
---|---|
YOUR_TWILIO_ACCOUNT_SID | From Twilio Console |
YOUR_TWILIO_AUTH_TOKEN | From Twilio Console |
YOUR_WHATSAPP_NUMBER | Your phone (e.g., +91XXXXXXXXXX ) |
YOUR_TWILIO_SANDBOX_NUMBER | Usually: +14155238886 |
📌 Don’t forget to send a message like join <code>
to Twilio’s sandbox number to activate WhatsApp messaging.
4. Authorize and Run the Script
- Hit ▶️
Run
next to thecheckLabelAndNotify
function - Grant permission when prompted
- It’ll run once — now automate it
5. Set an Auto Trigger
- In Apps Script, click the clock icon (Triggers) in the left panel
- Click + Add Trigger
- Function:
checkLabelAndNotify
- Event Source: Time-driven
- Frequency: Every 5 minutes (or less)
- Function:
🚫 Limitations (And Workarounds)
- Free Gmail accounts are limited to ~90 script executions/day
- If you use a 1-minute trigger, you’ll likely exceed this quota
- To go beyond that:
🔚 Final Thoughts
If you’re tired of missing time-sensitive emails, especially for things like restocks, deliveries, or OTPs — this automation is a game-changer.
You don’t need to be a coder. Just copy, paste, and set the right triggers.
And yes, you can adapt this to any sender — not just Amul. Think:
- Swiggy/Zomato order updates
- Flipkart/Amazon shipment info
- Banking OTPs or alerts