Use cases
Send WhatsApp messages from Airtable record changes
To send WhatsApp messages from Airtable with HelloHop, add an Airtable automation that triggers on a record change and runs a script. The script posts the record to your receiver with a shared secret, and the receiver calls the HelloHop send route. Airtable documents no signature on a script's requests, so the shared secret is your check.
Facts (as of October 2026, API v1)
- This page uses the Run a script action of an Airtable automation. It is not available on Airtable's Free plan, and a script can make 50 fetch requests per run, each timing out after 30 seconds.
- The triggers include when a record is created, when a record is updated, when a record matches a condition and when a record enters a view. Airtable says the created and updated triggers fire as soon as the first characters are typed, so a condition on Status suits a message better.
- Airtable documents no signature on the requests a script sends. The sample checks a shared value that you store as a secret in the script and as an environment variable on the receiver.
- Airtable's documentation does not describe a retry of a failed script run. The script throws on any non-2xx answer, so the run shows as failed, and the receiver saves each record before it answers.
- HelloHop sends the message. The table, the trigger and the consent column are yours. HelloHop has no scheduler, labels or CRM.
- The unified POST
/v1/sessions/{channel}/messagesroute accepts an Idempotency-Key of up to 255 characters. Repeating the same key and body within 24 hours returns the first result without another send, with the response header Idempotent-Replayed: true. - A 504 send_unconfirmed, a timeout, a 409 idempotency_uncertain or a 503 with ambiguous true means the message may have gone out. Treat it as possibly delivered and look at the chat before you send it again.
- The free sandbox channel allows 180 messages sent a day and 10 new chats a month, counted in Bangkok time. That is enough to build and test the whole flow before you pay.
- Prices: from $20 USD per number per month, billed annually, with a free sandbox and no per-message fees.
Steps
- Prepare the table. Add Name, Phone (with country code), Status and a checkbox field named Consent checkbox. Add two formula fields: Record ID as RECORD_ID() and WhatsApp OK as IF({Consent checkbox}, "yes", "no").
- Create the automation. Use the trigger When a record matches a condition, with Status is Ready to ship as the condition, then add a Run a script action.
- Post the record. In the script, send recordId, name, phone, whatsappOk and status to your receiver with the shared value in the X-Automation-Secret header. Throw if the answer is not 2xx.
- Check, save and send. The receiver checks the shared value, saves the record under its id and status, claims the row and sends one message.
What Airtable runs and what you run
| Step | Who does it |
|---|---|
| Notice a record change and start the automation | Airtable |
| Run a script that posts the record to your server | Airtable (the script is yours) |
| Check the shared value, save the record, decide who may be messaged | Your receiver |
| Send each message once | HelloHop: the send route with an Idempotency-Key |
The receiver (Node.js)
The receiver sends one message per record and status, so a record that is saved again with the same status does not send twice. Only the status Ready to ship sends. A record that arrives without a phone number or a yes is not saved, so the same record posted again once it is complete is still sent. A run that succeeds in Airtable means only that the receiver acknowledged the request: a record with no consent, no phone, another status or an opted-out number is deliberately not sent. Look in your own table for the send outcome, not in the run history. Implement the helpers named in the comments on your own database. The timer in the sample runs recovery and then re-runs pending rows from their stored payload. The Airtable script is at the bottom of the sample as comments, to paste into the Run a script action.
// Airtable automation: trigger "When a record matches a condition" (or "When a record is created"), action "Run a script".
// Docs: https://support.airtable.com/docs/run-a-script-action (fetch() in a script times out after 30 seconds, 50 fetch requests per run,
// input.config() reads input variables, input.secret.<name> reads a secret) and
// https://support.airtable.com/docs/getting-started-with-airtable-automations (the triggers).
// Airtable documents no signature on a script's fetch, so this receiver checks a shared secret that you also store as a secret in the script.
// Airtable does not document a retry of a failed script run; the script throws on any non-2xx answer so the run shows as failed.
import crypto from 'node:crypto';
import express from 'express';
const API = 'https://api.hellohop.app/v1';
const { CHANNEL_ID, CHANNEL_TOKEN } = process.env;
// One send. Repeating the same key with the same body returns the first result.
async function sendWhatsApp(key, message) {
try {
const res = await fetch(`${API}/sessions/${CHANNEL_ID}/messages`, {
method: 'POST',
headers: {
Authorization: `Bearer ${CHANNEL_TOKEN}`,
'Content-Type': 'application/json',
'Idempotency-Key': key,
},
body: JSON.stringify(message),
signal: AbortSignal.timeout(15000),
});
const data = await res.json().catch(() => ({}));
const result = { status: res.status, code: data.code, ambiguous: data.ambiguous, id: data.id };
if (classify(result) === 'retry') {
// 429 whatsapp_rate_limited carries no Retry-After, so it falls back to 1 second. This helper waits at most 30 seconds;
// a longer Retry-After is not slept through: result.retryAt (Unix ms) says when the row is due, and your sweep or timer retries then.
const h = res.headers.get('Retry-After');
const ms = Math.max(0, (h ? (/^\d+$/.test(h) ? Number(h) * 1000 : Date.parse(h) - Date.now()) : 1000) || 1000);
result.retryAt = Date.now() + ms;
await new Promise((resolve) => setTimeout(resolve, Math.min(30000, ms)));
}
return result;
} catch {
return { status: 0 }; // timeout or lost connection: the message may have gone out
}
}
// One answer per send: sent (server_ack), queued, retry, unknown or failed.
function classify({ status, code, ambiguous }) {
if (status === 200) return 'sent'; // server_ack, not delivered
if (status === 202) return 'queued'; // observe webhooks, do not resend
// Refused before sending: repeat the same key and body later.
const refused = ['upstream_unavailable', 'hopsmart_settings_unavailable', 'operator_unresolved'];
if (status === 429 || (status === 503 && (ambiguous === false || refused.includes(code)))) return 'retry';
// Possibly sent: look at the chat, never resend.
if (status === 0 || status >= 500 || code === 'idempotency_uncertain') return 'unknown';
return 'failed'; // an unlinked channel, idempotency_conflict, a bad request: fix it, do not retry
}
// Your events table: unique key, payload, state, claimed_at (Unix ms), message_id, next_attempt (Unix ms, default 0). Helpers:
// saveEvent(key, payload) insert a pending row once; a repeat changes nothing
// claimSend(key) atomic pending -> claimed, only when next_attempt <= now; sets claimed_at; true for one caller only
// finish(key, expected, state, id, nextAttempt) UPDATE only WHERE state = expected; save the message id
// retry returns to pending and saves nextAttempt (the helper's retryAt); all other outcomes stop automatic sends
// skipPending(key) UPDATE pending -> skipped only; never overwrites a claim or an outcome
// saveBody(key, text) / savedBody(key) keep the exact text, so a retry sends the same body
// Your timer calls recoverAbandonedClaims first, then re-runs pending rows. Never re-send unknown rows.
// db.run(sql, params) executes SQL in your database; claimed_at is Unix milliseconds.
async function recoverAbandonedClaims() {
await db.run("UPDATE events SET state = 'unknown' WHERE state = 'claimed' AND (claimed_at IS NULL OR claimed_at < ?)",
[Date.now() - 5 * 60 * 1000]);
}
const app = express();
// Also yours: hasOptedOut(phone) is true if this number asked you to stop;
// dueKeys(now) lists the keys of pending rows that are due; eventPayload(key) returns the saved payload text.
const { AIRTABLE_SHARED_SECRET } = process.env;
if (!AIRTABLE_SHARED_SECRET || AIRTABLE_SHARED_SECRET.length < 24) throw new Error('Set AIRTABLE_SHARED_SECRET (24 characters or more) before you start');
function validSecret(header) {
const a = crypto.createHash('sha256').update(String(header ?? '')).digest();
const b = crypto.createHash('sha256').update(AIRTABLE_SHARED_SECRET).digest();
return crypto.timingSafeEqual(a, b); // compare fixed-length hashes in constant time
}
// Your table needs: Name, Phone (with country code), Status (single select) and two formula fields: Record ID = RECORD_ID() and
// WhatsApp OK = IF({Consent checkbox}, "yes", "no"). Both formulas return text, so the receiver compares plain strings and never reads a checkbox value.
// The automation sends the row when Status becomes "Ready to ship". The message wording is an example.
// Sends one saved record. Called by the route and by the timer, so a retry sends the same text under the same key.
async function processRecord(key, rec) {
const phone = String(rec.phone ?? '').replace(/\D/g, '');
if (await hasOptedOut(phone)) return skipPending(key); // checked again right before the claim
if (!(await claimSend(key))) return;
let text = await savedBody(key);
if (!text) {
text = `Hi ${String(rec.name ?? 'there').slice(0, 60)}, your order is packed and ready to ship. Reply here if anything needs to change.`;
await saveBody(key, text); // a retry sends this exact text
}
const result = await sendWhatsApp(key, { type: 'text', to: phone, text });
await finish(key, 'claimed', classify(result), result.id, result.retryAt);
}
app.post('/webhooks/airtable', express.json({ limit: '20kb' }), async (req, res) => {
if (!validSecret(req.get('X-Automation-Secret'))) return res.sendStatus(401);
const { recordId, phone: rawPhone, whatsappOk, status } = req.body ?? {};
if (!recordId || typeof recordId !== 'string') return res.sendStatus(400);
const key = `airtable-${recordId}-${String(status).replace(/\W+/g, '-')}`; // one message per record and status
const phone = String(rawPhone ?? '').replace(/\D/g, '');
try {
// Not ready, no phone, no yes or opted out: save nothing, so the same record posted again once it is complete is still sent.
if (status !== 'Ready to ship' || !phone || whatsappOk !== 'yes' || (await hasOptedOut(phone))) return res.sendStatus(200);
await saveEvent(key, JSON.stringify(req.body)); // durable first
} catch {
return res.sendStatus(500); // the script throws, so the run shows as failed
}
res.sendStatus(200);
processRecord(key, req.body).catch(console.error); // a failure leaves a row for your timer
});
// Your timer: every minute run recovery, then send the pending rows that are due again from their saved payload.
setInterval(async () => {
try {
await recoverAbandonedClaims();
for (const key of await dueKeys(Date.now())) {
try { await processRecord(key, JSON.parse(await eventPayload(key))); } // an unreadable row stays pending for the next tick
catch (err) { console.error(key, err); }
}
} catch (err) { console.error(err); }
}, 60 * 1000);
app.listen(3011);
// ---- Airtable "Run a script" action (a separate file, in Airtable) ----
// Input variables (the Input Variables sidebar of the script editor): recordId (the Record ID formula field), name, phone, whatsappOk, status. Secret: automationSecret.
// let { recordId, name, phone, whatsappOk, status } = input.config();
// const res = await fetch('https://your-server.example/webhooks/airtable', {
// method: 'POST',
// headers: { 'Content-Type': 'application/json', 'X-Automation-Secret': input.secret.automationSecret },
// body: JSON.stringify({ recordId, name, phone, whatsappOk, status }),
// });
// if (!res.ok) throw new Error('Receiver answered ' + res.status);What the handler does with each send result
| Send result | What your handler does |
|---|---|
| 200 server_ack | WhatsApp acknowledged the send. Mark it sent and save id; this is not a delivery receipt. |
| 202 queued | Persisted in the queue, not delivered. A channel that queues its sends (for example while accepted sends drain) answers every text send this way, with id, status queued, position and expires_at. Mark it queued and save id. Observe the result through webhooks without resending. |
| 429, or 503 with ambiguous false or code upstream_unavailable, hopsmart_settings_unavailable or operator_unresolved | Refused before sending. Honor Retry-After, keep the same key and body, and retry later. The Node helper waits at most 30 seconds before returning retry with a retryAt time, and the pages that keep a due time skip the row until then; the other Node timer pages retry on their next run. The Flask, Python reminder and PHP samples return the time to retry instead of waiting; the Sheets helper saves next_attempt_at and skips the row until then. |
| 504 send_unconfirmed, 409 idempotency_uncertain, 503 with ambiguous true, a timeout or a lost response | Possibly delivered. Mark it unknown and look at the chat before any resend. Never force a resend of an uncertain key with a new key. |
| 409 idempotency_conflict | The same key was used for a different message. Fix how you build the key. The first message is unchanged. |
| Any other 409 | Mark it failed. Fix the channel before scheduling another attempt. |
| Other 4xx | The request is wrong and a retry will not fix it. Log it and move on. |
Subscribe to message and message.status webhooks and verify their signatures. The result of a queued send arrives as a message event: match the saved response id to payload.id. message.status reports delivered or read for each id in payload.ids. A send held by HopSmart™ expires 72 hours after acceptance, and the 202 carries expires_at. If no event arrives, read the job with GET /hopsmart/jobs/{id}. Save event ids to deduplicate. Do not resend queued work while waiting for a result.
Who may be messaged
Message only people who agreed to WhatsApp messages, keep each message about their record, and stop when they ask. The sample checks your opt-out list before every send, and recording a stop request in that list is your code. Consent rules differ by country, so check the ones that apply to you.
Questions
- Does Airtable sign its automation requests?
- Airtable does not document a signature for requests sent by a Run a script action, so check a shared value that only your script and your receiver know.
- Which Airtable plans can run scripts in automations?
- Airtable lists the Run a script action as unavailable on the Free plan. Check Airtable's pricing page for which paid plans include it.
- How do I avoid sending the same record twice?
- Save each record under its id and status before you answer, claim the row before you send, and use that key as the Idempotency-Key.
- What happens when the send times out?
- Treat it as possibly delivered, record it as unknown and look at the chat before any resend.
- Can I use Notion instead of Airtable?
- Notion has its own signed webhooks, but an event names the page and carries no property values, so your receiver would read the page from the Notion API first. This page covers Airtable only.
Free sandbox, forever. Upgrade when you're ready.
Start freeKeep going
HelloHop is an independent WhatsApp API for developers: send and receive messages, automate groups and communities, and get signed webhooks. Not affiliated with WhatsApp or Meta. You link your own number.