No todo el mundo que necesita enviar WhatsApp es desarrollador backend. Equipos de operaciones, soporte y ventas suelen vivir en Google Sheets. Con Apps Script puedes disparar mensajes desde una fila de la hoja sin montar un servidor.
Este patrón es ideal para avisos manuales supervisados: tú decides cuándo enviar, fila por fila.
Estructura de la hoja
Crea columnas como:
- A — Teléfono (internacional, sin +)
- B — Mensaje
- C — Estado (pendiente / enviado / error)
Script en Apps Script
Extensiones → Apps Script. Pega este código y guarda tu API key en PropertiesService (no en la celda):
const API_KEY = PropertiesService.getScriptProperties().getProperty('MESSAGEAPI_KEY');
const API_URL = 'https://msgapi.cloud/api/v1/send';
function sendRow(row) {
const sheet = SpreadsheetApp.getActiveSheet();
const phone = String(sheet.getRange(row, 1).getValue()).replace(/\D/g, '');
const text = String(sheet.getRange(row, 2).getValue());
if (!phone || !text) return;
const response = UrlFetchApp.fetch(API_URL, {
method: 'post',
contentType: 'application/json',
headers: { 'X-API-Key': API_KEY },
payload: JSON.stringify({ recipient: phone, text: text }),
muteHttpExceptions: true,
});
const ok = response.getResponseCode() >= 200 && response.getResponseCode() < 300;
sheet.getRange(row, 3).setValue(ok ? 'enviado' : 'error: ' + response.getContentText());
}
function sendPendingRows() {
const sheet = SpreadsheetApp.getActiveSheet();
const lastRow = sheet.getLastRow();
for (let row = 2; row <= lastRow; row++) {
const status = sheet.getRange(row, 3).getValue();
if (status === 'pendiente') sendRow(row);
}
}
Automatizar con trigger
Puedes programar sendPendingRows cada hora desde Triggers en Apps Script, o ejecutarlo manualmente. Para volúmenes altos, considera un plan acorde en Account.
Límites a tener en cuenta
- Google impone cuotas diarias a
UrlFetchApp. - MessageAPI aplica límites por plan (mensajes/día y destinatarios en Personal).
- Usa WhatsApp de forma responsable; no envíes spam.
Conecta tu número y automatiza desde Sheets
Regístrate en MessageAPI, escanea el QR en Settings y usa tu API key en Apps Script.