This Python project automates sending personalized WhatsApp messages to clients using the Meta (Facebook) Graph API and Google Sheets as the data source.
It reads phone numbers and company names from a Google Sheet, sends each recipient a templated WhatsApp message (with an image), and then updates the spreadsheet with the status (Sent or Failed) and timestamp for tracking.
- ✅ Google Sheets integration via
gspread - ✅ WhatsApp Business API integration via
requests - ✅ Sends templated image messages automatically
- ✅ Updates message status and timestamp back to the sheet
- ✅ Handles up to 1500 messages per run (configurable)
- ✅ Includes delay between requests to prevent rate-limit issues
whatsapp-meta-api-automation-main/
│
├── main.py # Main automation script
├── requirements.txt # Python dependencies
├── README.md # Project documentation
└── credentials.json # Google API credentials (FIND YOUR GOOGLE API CREDENTIALS)
- Python 3.8+
- A Google Cloud Service Account with access to your Google Sheet
- A valid Meta WhatsApp Business API setup
- A pre-approved WhatsApp message template on Meta
1️⃣ Clone this repository
git clone https://github.com/monojitbgit/whatsapp-meta-api-automation.gitcd whatsapp-meta-api-automation-main2️⃣ Install dependencies
Make sure you have Python 3.8+ and pip installed, then run:
pip install -r requirements.txt
3️⃣ Create credentials.json
- Go to your Google Cloud Console.
- Create or use an existing Service Account.
- Generate a JSON key file and download it.
- Rename the file to credentials.json.
- Place it in the root of your project folder.
- After you create your service account and credentials.json, you must share your Google Sheet with your service account’s email address.
It usually looks like this:
your-service-account-name@your-project-id.iam.gserviceaccount.com
Now your script will be authorized to read and update the sheet using that service account.
4️⃣ Update configuration in the script
Open main.py and replace the following placeholders with your actual credentials and IDs:
api_url = "https://graph.facebook.com/v20.0/YOUR_PHONE_NUMBER_ID/messages"
access_token = "YOUR_ACCESS_TOKEN"
template_name = "your_template_name"
image_url = "https://drive.google.com/uc?export=download&id=YOUR_IMAGE_ID"
SPREADSHEET_NAME = "YOUR SPREADSHEET NAME"
WORKSHEET_NAME = "YOUR SHEET NAME"
Once everything is configured, run:
python main.py
You’ll see console output showing:
API responses
Message delivery status
Timestamp updates
Your Google Sheet will be updated automatically in:
Column Purpose
A Phone Number
B Company Name
L Timestamp (auto)
M Status (Sent/Failed)
⚙️ Behavior Details
Processes only rows where Column M (Status) is empty.
Writes timestamp in Column L and status in Column M.
Includes a time.sleep(1) delay between messages to respect API limits.
Stops automatically after 1500 messages (configurable in the code).
🧩 Dependencies
The project depends on the following Python packages:
gspread
google-auth
requests
These are listed in requirements.txt.
Install them all at once using:
pip install -r requirements.txt
This project is licensed under the MIT License.
You’re free to use, modify, and distribute it for personal or commercial purposes.