To text a lead when someone submits a Typeform, point a Typeform webhook at a small receiver, verify its signature against the raw body, check that the person ticked your text-consent question, and then call POST /v1/messages with an idempotency key built from the response. If the consent answer is missing or "no", you send nothing.

We make Ready, so the send step uses only the request shape we document. The Typeform side (payload layout, signature header) is theirs: confirm the details against Typeform's webhook docs, because we only describe the handling pattern here.

What the flow looks like

  1. A visitor fills in your form, including a phone number and a consent question.
  2. Typeform POSTs the response to your receiver.
  3. Your receiver verifies the signature, returns 200 quickly, and queues the work.
  4. A worker checks consent, then sends the first reply.

The order matters. Verify before you parse, acknowledge before you send, and check consent before anything leaves your system.

Add the consent question first

The text goes only to people who agreed to texts through the form. So the form needs a dedicated question, a yes/no one that's unticked by default, with wording that names your business, says you'll text about their enquiry, and mentions that message rates may apply and they can reply STOP to opt out. Our consent wording guide has examples that registration reviewers accept.

Give that question and the phone question a reference you set yourself in Typeform, such as sms_consent and phone. Your code looks answers up by reference, not by position, so reordering the form later won't break it.

Set consent_attested to true only when that answer is yes. Ready doesn't store a per-contact opt-in record, so keep the response (it carries a timestamp) in your own database as your proof.

The receiver

This Express receiver reads the raw body, verifies the HMAC, acknowledges, and hands off the work.

import crypto from "node:crypto";
import express from "express";

const app = express();
const SECRET = process.env.TYPEFORM_WEBHOOK_SECRET;

function validSignature(rawBody, header) {
  if (!header) return false;
  const expected =
    "sha256=" +
    crypto.createHmac("sha256", SECRET).update(rawBody).digest("base64");
  const a = Buffer.from(expected);
  const b = Buffer.from(header);
  return a.length === b.length && crypto.timingSafeEqual(a, b);
}

app.post("/hooks/typeform", express.raw({ type: "*/*" }), (req, res) => {
  if (!validSignature(req.body, req.get("Typeform-Signature"))) {
    return res.sendStatus(401);
  }
  const event = JSON.parse(req.body.toString("utf8"));
  enqueueLead(event);
  res.sendStatus(200);
});

The header name and encoding are Typeform's, so check them in their docs and change the two strings if they differ. The pattern stays the same for any sender: HMAC the exact bytes you received, compare in constant time, reject on mismatch. Parsing the JSON first and re-serializing it changes the bytes and breaks the check, which is why the route uses express.raw.

The worker: consent check, then send

enqueueLead in the receiver puts the event on whatever queue you use, and this is the function the job runs.

function answerByRef(response, ref) {
  return response.answers?.find((a) => a.field?.ref === ref);
}

async function handleLead(event) {
  const response = event.form_response;
  const consent = answerByRef(response, "sms_consent");
  const phone = answerByRef(response, "phone");

  if (consent?.boolean !== true || !phone?.phone_number) return;

  const res = await fetch("https://api.tryready.com/v1/messages", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "X-API-Key": process.env.READY_API_KEY,
      "Idempotency-Key": `typeform-${response.token}`,
    },
    body: JSON.stringify({
      to: phone.phone_number,
      body: "Thanks for getting in touch with Acme Plumbing. We got your form and will text you the next steps shortly.",
      consent_attested: true,
    }),
    signal: AbortSignal.timeout(15000),
  });

  if (res.status === 429 || res.status >= 500) throw new Error(`retry ${res.status}`);
  if (res.status >= 400) console.warn("not sent", res.status, await res.text());
}

"Acme Plumbing" is a made-up business for the example. Unless the account turns it off, Ready adds "Reply STOP to opt out" and your business name to the first text to each contact, so you don't type it into the body. The payload shape here (an answers list with a field reference, a boolean answer for the consent question, a response token) is what we expect from Typeform; verify it against a real test delivery before you rely on it. Fall back to your own stored response id if you'd rather not depend on theirs.

Why the key comes from the response

Typeform retries a webhook when your endpoint is slow or errors, so the same response can arrive twice. Building the Idempotency-Key from the response's own identifier means the second delivery produces the same key, and the request isn't sent twice. A random UUID per delivery wouldn't give you that. The deduplication guide goes deeper on at-least-once delivery.

Checklist before you go live

CheckWhy it matters
Signature verified on the raw bodyAnyone can POST to a public URL
200 returned before the sendA slow carrier call shouldn't make Typeform retry
Consent answer required, default untickedYou text only people who agreed
Key built from the response idRedeliveries don't double-text
4xx logged, 429 and 5xx retriedA bad number isn't worth retrying
409 QUIET_HOURS_BLOCK handledIt's a time rule: send again once the window opens

A lead who submits at night may hit that last row. An API text is held only if the recipient's window opens within a few hours; otherwise it's refused with 409 QUIET_HOURS_BLOCK, and you send it again once the window opens. The quiet hours 409 guide shows the retry timing. See the webhook docs for Ready's own events.

FAQ

Can I text a lead who left a number but skipped the consent question?

No. A phone number on its own isn't agreement to receive texts. Follow up another way, such as email, or ask for consent in a second form.

What if the same lead submits twice?

Each response has its own identifier, so each gets its own key and its own text. If that's too chatty, add your own rule, such as one first reply per phone number per day, before the send.

Do I need a queue for this?

For a handful of leads a day, doing the send after the 200 in the same process is fine. Once a restart losing a lead would hurt, enqueue the job instead.

The short version

Verify the signature on the raw bytes, answer fast, require the consent answer, and key the send to the response. The messages API docs have every field, and you can start at tryready.com/signup.