Updated on November 4, 2026
To send WhatsApp messages from Google Sheets, you use the spreadsheet’s own Apps Script: a function reads each row, builds the JSON for an approved template using the columns as variables, and calls the official WhatsApp Business API with UrlFetchApp.fetch. The response (the message ID or the error) is written back to the row, and the token lives in Script Properties, not in the code. It works well for notices of up to a few hundred contacts per run, as long as you respect Apps Script limits and each person’s opt-in.
Below are the full script, the sheet layout, the limits that matter, and when to swap the spreadsheet for a sturdier automation.
When a spreadsheet makes sense
| Scenario | Sheets + Apps Script | Better with another tool |
|---|---|---|
| Event reminder to opted-in registrants | Yes | |
| Daily invoice or order notice exported from your ERP | Yes | |
| Recurring sends to tens of thousands of contacts | Your own system with a queue | |
| Auto-replies to incoming messages | Webhook server, n8n, bot | |
| Human customer support | A support tool connected to the API |
If the data already lives in your ERP, you can skip the sheet and send straight from system events: see how to integrate the WhatsApp API with your ERP.
A spreadsheet is a great sending “console” for non-developers, but it doesn’t receive webhooks easily. For two-way flows, see n8n with the WhatsApp Business API or Make and Zapier.
Before you start
- A number on the official WhatsApp API with an approved template. Business-initiated messages outside the 24-hour window must be templates.
- The access token and Phone Number ID (or a provider’s token, as shown at the end).
- A list containing only contacts who opted in. The WhatsApp Business Messaging Policy requires permission to receive messages. See how to build an opt-in list.
In this example the template is called event_reminder, in en_US, with three body variables:
Hi {{1}}! Reminder: {{2}} takes place on {{3}}. Reply to this message if you have questions.
Want to try it while you read? Create a Vectalk account and send your first message through the official API. Create free account →
Sheet layout
Create a tab named Sends with these columns, starting on row 1:
| A: phone | B: name | C: event | D: date | E: optin | F: status | G: message_id | H: sent_at |
|---|---|---|---|---|---|---|---|
| 16505551234 | Sarah | Sales workshop | Nov 12, 7 pm | yes | |||
| 447700900123 | James | Sales workshop | Nov 12, 7 pm | yes |
Rules:
- Phone with country code, digits only (the script strips spaces and dashes). No leading
+or00. - optin must be
yesfor the row to be sent. - Columns F, G and H are filled by the script. Rows with a status are never resent.
Store the token in Script Properties
Never paste the token into the code: anyone with edit access to the sheet would see it. Use Script Properties:
- In the spreadsheet, open Extensions > Apps Script.
- In the left sidebar, click Project Settings (gear icon).
- Under Script Properties, click Add script property.
- Create
WA_TOKEN,WA_PHONE_IDandWA_BASE_URL(for examplehttps://graph.facebook.com/v26.0). - Click Save script properties.
The script reads them with PropertiesService.getScriptProperties().getProperty(...). Keep in mind that anyone who can edit the Apps Script project can read these properties, so limit edit access to the spreadsheet.
The full script
Paste this into the Apps Script editor (Code.gs):
const SHEET_NAME = 'Sends';
const TEMPLATE_NAME = 'event_reminder';
const TEMPLATE_LANG = 'en_US';
const MAX_PER_RUN = 200; // keeps each run well under 6 minutes
const COL = { phone: 1, name: 2, event: 3, date: 4, optin: 5, status: 6, msgId: 7, sentAt: 8 };
function onOpen() {
SpreadsheetApp.getUi()
.createMenu('WhatsApp')
.addItem('Send pending', 'sendPending')
.addToUi();
}
function config_() {
const p = PropertiesService.getScriptProperties();
const cfg = {
token: p.getProperty('WA_TOKEN'),
phoneId: p.getProperty('WA_PHONE_ID'),
baseUrl: p.getProperty('WA_BASE_URL'),
};
if (!cfg.token || !cfg.baseUrl) throw new Error('Set WA_TOKEN and WA_BASE_URL in Script Properties.');
return cfg;
}
function normalizePhone_(value) {
return String(value).replace(/\D/g, '');
}
function buildPayload_(row) {
return {
messaging_product: 'whatsapp',
to: normalizePhone_(row[COL.phone - 1]),
type: 'template',
template: {
name: TEMPLATE_NAME,
language: { code: TEMPLATE_LANG },
components: [{
type: 'body',
parameters: [
{ type: 'text', text: String(row[COL.name - 1]) },
{ type: 'text', text: String(row[COL.event - 1]) },
{ type: 'text', text: String(row[COL.date - 1]) },
],
}],
},
};
}
function sendPending() {
const cfg = config_();
const sheet = SpreadsheetApp.getActive().getSheetByName(SHEET_NAME);
const data = sheet.getDataRange().getValues();
const url = cfg.phoneId ? `${cfg.baseUrl}/${cfg.phoneId}/messages` : `${cfg.baseUrl}/messages`;
let sent = 0;
for (let i = 1; i < data.length && sent < MAX_PER_RUN; i++) {
const row = data[i];
const done = String(row[COL.status - 1]).trim() !== '';
const optedIn = String(row[COL.optin - 1]).trim().toLowerCase() === 'yes';
const phone = normalizePhone_(row[COL.phone - 1]);
if (done || !phone) continue;
const r = i + 1; // actual sheet row
if (!optedIn) {
sheet.getRange(r, COL.status).setValue('skipped: no opt-in');
continue;
}
const resp = UrlFetchApp.fetch(url, {
method: 'post',
contentType: 'application/json',
headers: { Authorization: `Bearer ${cfg.token}` },
payload: JSON.stringify(buildPayload_(row)),
muteHttpExceptions: true,
});
const code = resp.getResponseCode();
let body = {};
try { body = JSON.parse(resp.getContentText()); } catch (e) {}
if (code >= 200 && code < 300 && body.messages) {
sheet.getRange(r, COL.status).setValue('accepted');
sheet.getRange(r, COL.msgId).setValue(body.messages[0].id);
} else {
if (code === 429 || (body.error && body.error.code === 130429)) break; // rate limited: leave the row pending for the next run
const err = body.error ? `${body.error.code}: ${body.error.message}` : `HTTP ${code}`;
sheet.getRange(r, COL.status).setValue(`error ${err}`);
}
sheet.getRange(r, COL.sentAt).setValue(new Date());
sent++;
Utilities.sleep(100);
}
SpreadsheetApp.flush();
}
How to use it:
- Save, reload the spreadsheet, and a WhatsApp > Send pending menu appears.
- On the first run, Google asks you to authorize the script to access the sheet and external services. Review and authorize.
- Test with one row containing your own number before running the full list.
Why muteHttpExceptions: true? According to the UrlFetchApp reference, an HTTP error code throws an exception by default and stops the script. With this option on, the response comes back normally, so you can write Meta’s error to the row and move on.
“Accepted” is not “delivered”
When the API returns messages[0].id, the message was accepted for sending, not necessarily delivered. Delivered, read or failed come later via webhook, as sent, delivered, read and failed statuses (message status webhooks). That’s why the script saves the message_id: an automation that receives the webhook (n8n, Make or your own server) can find the row and update the status column.
Apps Script limits that matter
Values from the Apps Script quotas page, checked on November 4, 2026:
| Limit | Consumer account (gmail.com) | Google Workspace |
|---|---|---|
| URL Fetch calls per day | 20,000 | 100,000 |
| Script runtime per execution | 6 minutes | 6 minutes |
| Total trigger runtime per day | 90 minutes | 6 hours |
Google warns that quotas can change at any time without notice. In practice:
MAX_PER_RUNexists so you never hit the 6-minute ceiling. For longer lists, run it again (processed rows are skipped) or add a time-driven trigger from the Triggers menu in Apps Script.- Each message is one URL Fetch call. On a consumer account, 20,000 a day is the cap across all your scripts.
UrlFetchApp.fetchAllsends several requests in one call and speeds up larger lists, but it also makes it easier to hit your number’s rate limit.
WhatsApp has its own limits too: your portfolio’s messaging limit (unique recipients per 24 hours), your number’s throughput, and the per-user marketing message cap. Marketing messages over that cap aren’t delivered (error 131049).
Cost and good practices
- Template category: an event reminder can be utility or marketing depending on the wording. See event reminders: utility or marketing.
- Price: Meta charges per delivered message according to its rate card for the recipient’s country. For recipients in Brazil, since October 1, 2026, marketing costs BRL 0.3217 and utility BRL 0.0350 per delivered message. Run the numbers in the cost calculator before sending to the whole sheet.
- Personal data: the sheet holds names and phone numbers. Share it only with people who need it and delete what you no longer use. Data protection laws apply (in Brazil, the LGPD, Law 13,709/2018; in Europe, the GDPR); this is not legal advice.
- Opt-out: if someone asks to stop, set their opt-in column to
noright away.
How to do this with Vectalk
The same script works with Vectalk, a proxy for the official Cloud API that uses the same payloads. Only the Script Properties change:
| Property | Meta direct | Vectalk |
|---|---|---|
WA_BASE_URL | https://graph.facebook.com/v26.0 | https://apis.vectalk.com.br/api |
WA_PHONE_ID | Phone Number ID | Leave empty with an instance token |
WA_TOKEN | Meta token | Token created under Settings → API Tokens |
With WA_PHONE_ID empty, the script calls POST https://apis.vectalk.com.br/api/messages, as in the quickstart (in Portuguese). With an instance token, the number is resolved automatically (authentication). You can create the template in the dashboard’s Template Library, and each delivered message is deducted from your prepaid balance, with no card registered at Meta. Vectalk has no native bulk sender: here, your spreadsheet is the sender. Create your account.
Frequently asked questions
Can I send free-form text from the sheet?
Only to people who messaged you in the last 24 hours. To start a conversation, the API requires an approved template, which is what spreadsheets are usually used for.
Can I attach an image or PDF?
Yes, if the template has a media header. Add a header component with the public URL or media ID in buildPayload_. The component is the same one used in any media template.
Can the script send automatically every day?
Yes, if you create a time-driven trigger in the Apps Script editor’s Triggers menu and pick the sendPending function. Stay within your account’s daily trigger runtime.
Why does the status column show error 132000?
That code means the number of parameters doesn’t match the template. Check that the approved template has exactly the three variables the script sends. See error 132000: template parameters.
How many messages can I send per run?
The script caps it at 200 per run to stay far from 6 minutes. The real number depends on API response times; adjust MAX_PER_RUN after measuring.
Official sources consulted on November 4, 2026: Apps Script: Quotas for Google Services, Apps Script: UrlFetchApp, Apps Script: Properties Service, WhatsApp Business Messaging Policy, Vectalk: Quickstart, Vectalk: Authentication.
Try the official WhatsApp API today
Create your account, generate a token and send your first message with the quick-start guide. Same payloads and webhooks as Meta's Cloud API.
