Use cases
Follow up a form submission over WhatsApp
Point a Typeform webhook at your receiver. The receiver verifies the Typeform-Signature header over the raw body, saves the response under its token, answers 200, then sends the lead one WhatsApp message through HelloHop if they answered yes to the consent question. A repeated delivery finds the same row and sends nothing new.
Facts (as of October 2026, API v1)
- Once the webhook has a secret, Typeform signs each delivery in the Typeform-Signature header: sha256= plus the base64 HMAC-SHA256 of the raw body, keyed with that secret.
- Typeform expects a 2XX within 30 seconds and retries most failures, so answer first and send after. A 404 or 410 answer disables the webhook without a retry.
- The send is one POST
/v1/sessions/{channel}/messagescall. HelloHop does not read your form. - 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
- Add the questions. Add three questions to the form: a name, a phone number with country code and a yes/no WhatsApp consent question. Give each a reference (ref) you can read in the payload.
- Create the webhook. Point a Typeform webhook for the form at your HTTPS URL and set its secret through the Typeform Webhooks API.
- Verify and save. Check the Typeform-Signature header on the raw body, save the response under its token, then answer 200.
- Send once. Skip leads without consent or with an opt-out. Claim the row, save the text, send with the row key as the Idempotency-Key.
The job: reply while the lead is warm
A person who fills out a form expects an answer soon. A short WhatsApp message tells them a person will reply, and it goes only to people who answered yes to the consent question. The reply itself is a person's job.
The receiver (Node.js)
The sample reads three answers by reference: name, phone and whatsapp_ok. A short text answer carries its value in text. Typeform's Responses API documentation shows a Phone number question answering with type phone_number and a phone_number key, and the sample reads either. The webhook example payload has no phone answer, so check a real delivery. Typeform's payload carries a response token and an event_id. The sample keys on the token, so confirm in a test delivery that a retry repeats it. Add a timer that re-runs pending rows from their stored payload. The message text is an example.
// Typeform webhooks: https://www.typeform.com/developers/webhooks/
// Signature (Typeform-Signature header, "sha256=" plus base64 HMAC-SHA256 of the raw body, your secret as the key):
// https://www.typeform.com/developers/webhooks/secure-your-webhooks/
// Payload: event_id, event_type "form_response", form_response { token, answers[] }; a text answer is
// { type: "text", text, field: { ref } } and a yes/no answer is { type: "boolean", boolean }:
// https://www.typeform.com/developers/webhooks/example-payload/ and https://www.typeform.com/developers/responses/reference/retrieve-responses/
// A Phone number question answers { type: "phone_number", phone_number: "+1XXXXXXXXXX" }:
// https://www.typeform.com/developers/responses/JSON-response-explanation/
// Typeform wants a 2XX within 30 seconds and retries most failures; a 404 or 410 disables the webhook.
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), true if this number asked you to stop.
function validTypeformSignature(raw, header) {
const { TYPEFORM_SECRET } = process.env;
const expected = 'sha256=' + crypto.createHmac('sha256', TYPEFORM_SECRET).update(raw).digest('base64');
return typeof header === 'string' && header.length === expected.length &&
crypto.timingSafeEqual(Buffer.from(header), Buffer.from(expected));
}
// Your form needs three fields with these refs: name (short text), phone (short text, country code required)
// and whatsapp_ok (yes/no, "Message me on WhatsApp about this request"). A Phone number question also works: it answers in phone_number.
const answer = (fr, ref) => fr.answers?.find((a) => a.field?.ref === ref);
async function processLead(key, fr) {
const a = answer(fr, 'phone');
const phone = String(a?.text ?? a?.phone_number ?? '').replace(/\D/g, '');
const name = String(answer(fr, 'name')?.text ?? 'there').slice(0, 60);
// Consent comes from the form itself. An opt-out is checked right before the claim.
if (!phone || answer(fr, 'whatsapp_ok')?.boolean !== true || (await hasOptedOut(phone))) return skipPending(key);
if (!(await claimSend(key))) return; // one message per response
let text = await savedBody(key);
if (!text) {
text = `Hi ${name}, thanks for filling out our form. A person will reply here within one business day.`;
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);
}
app.post('/webhooks/typeform', express.raw({ type: 'application/json' }), async (req, res) => {
if (!validTypeformSignature(req.body, req.get('Typeform-Signature'))) return res.sendStatus(401);
const event = JSON.parse(req.body.toString('utf8'));
if (event.event_type !== 'form_response') return res.sendStatus(200);
const key = `form-${event.form_response.token}`; // the response token: a repeated delivery finds the same row
try {
await saveEvent(key, req.body.toString('utf8')); // durable first
} catch {
return res.sendStatus(500); // Typeform delivers it again
}
res.sendStatus(200);
processLead(key, event.form_response).catch(console.error); // a failure leaves a row for your timer
});
app.listen(3008);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.
Tally and Google Forms
Tally webhooks and a Google Forms submit trigger in Apps Script can feed the same send code. Tally signs requests with a Tally-Signature header once you add a signing secret. An Apps Script trigger posts only what your script sends, so add a shared secret of your own and check it in the receiver. Both payload shapes differ from Typeform's, so take them from their own documentation. Keep the same rules: verify the sender, save before answering, one row per submission, and message only people who consented.
Who may be messaged
Message only leads who answered yes to a clear WhatsApp consent question on the form, and keep the message to the request they made.
Questions
- How do I verify a Typeform webhook?
- Compute the base64 HMAC-SHA256 of the raw request body with your webhook secret, prefix it with sha256=, and compare it with the Typeform-Signature header in constant time.
- How do I avoid messaging a lead twice?
- Save the response under its token before answering, claim the row before sending, and use the same key as the Idempotency-Key.
- Where does the phone number come from?
- From a form question you add, read by its reference. Require the country code so the number is complete.
- What if the send times out?
- Treat it as possibly delivered, record it as unknown and look at the chat before any resend.
- Can I use Google Forms or Tally?
- Yes, with a receiver adapted to each payload. Tally can sign its webhooks with a signing secret. An Apps Script trigger for Google Forms posts what your script sends, so add a shared secret of your own.
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.