WhatsApp· 9 min read

Cal.com webhook to WhatsApp booking reminders and replies


Subscribe a Cal.com or Cal.diy webhook to BOOKING_CREATED, BOOKING_RESCHEDULED and BOOKING_CANCELLED, and verify X-Cal-Signature-256 on every request. Keep your own copy of each booking keyed by uid, then send a utility confirmation and a 24-hour reminder with Confirm, Reschedule and Cancel. Cancel and Reschedule taps go back through Cal.com API v2. Confirm is stored in your own table, because Cal.com’s API v2 documents no endpoint for an attendee to confirm attendance.

The reminder pattern itself, with TTL, template category and delivery tracking, is in WhatsApp appointment reminders with Confirm and Reschedule. This post covers what Cal adds: its payload, its signature, its write-back endpoints and the events your own calls fire back at you. The Calendly version is in Calendly webhooks to WhatsApp, and a WhatsApp waitlist can refill a slot when a booking is canceled.

Why self-hosted Cal.diy needs its own reminder path

Cal.diy has had no built-in reminders since it split from Cal.com in April 2026. Cal.com’s post of 2026-04-15 describes Cal.diy as “the open-source scheduling platform”, relicensed from AGPL 3.0 to MIT, and says “Cal.diy ships with API v2 only” (Moving to closed-source: the technical changes, accessed 2026-11-25). The core scheduling logic, the app store, the booking flows and API v2 stayed. The “automated workflow engine (reminders, follow-ups, triggers)” was removed.

The repository README agrees: “Teams, Organizations, Insights, Workflows, SSO/SAML, and other EE-only features have been removed” (calcom/cal.diy, accessed 2026-11-25). It also says “There is no hosted/managed version.”

Two pull requests of October and November 2026 are cleanup after that split. PR #30447 removed unused WhatsApp workflow strings on 2026-10-29 and closed issue #30446, which notes “Workflows isn’t in Cal.diy”. PR #30442 removed the Twilio page and unused Twilio environment variables, merged on 2026-11-03. PR #30334 is still open and was marked stale on 2026-11-08.

Hosted Cal.com still has Workflows, and its API reference lists a /v2/workflows endpoint. The webhook path below runs the same way against hosted Cal.com and a self-hosted Cal.diy deployment.

Cal stores the attendee’s phone in a system booking field called attendeePhoneNumber. In the Cal.diy source, it is defined with type: "phone", hidden: true and required: false (getBookingFields.ts, accessed 2026-11-25). Out of the box, nobody sees it, so un-hide it in the event type’s booking questions.

Add a checkbox question for WhatsApp consent next to it. Cal doesn’t provide one, so this is a recommendation, not a Cal feature. Word it so the attendee knows the channel and the purpose. One example: “Send me booking confirmations and reminders on WhatsApp.” The code reads this question by its identifier, set in CONSENT_FIELD. How to collect WhatsApp opt-in covers what else to record.

The service strips the phone to digits for the to field, so a leading plus sign or spaces don’t matter. If your attendees type numbers by hand elsewhere, normalize them as shown in E.164 phone number normalization.

Subscribe the webhook

Create the subscription with POST /v2/webhooks (create a webhook, accessed 2026-11-25). The body needs subscriberUrl, active and triggers[]. Set secret too, because the service rejects unsigned requests. The optional version takes 2021-10-20 or 2026-07-27, which adds ICS content. customHeaders accepts up to 10 headers.

Subscribe at least BOOKING_CREATED, BOOKING_RESCHEDULED and BOOKING_CANCELLED. Event types that require host confirmation emit BOOKING_REQUESTED first. We haven’t verified whether BOOKING_CREATED also fires for those, so the service logs BOOKING_REQUESTED and waits. Test it on your own deployment before you rely on either.

The payload Cal sends

Every delivery has the envelope {triggerEvent, createdAt, payload} (Cal.com webhooks help, accessed 2026-11-25). These are the payload keys the service reads:

Key What it holds
uid The booking’s unique ID, used in every API v2 call
startTime, endTime ISO times in UTC
title, status Event title and status, for example ACCEPTED
attendees[] name, email, timeZone, language and more
responses.attendeePhoneNumber.value The phone, once the field is visible
responses.<your question>.value Your consent checkbox
rescheduleUid On reschedule: the previous booking’s uid
cancellationReason On cancel

Each entry in responses carries label, value and isHidden. On a reschedule, uid is the new booking, and rescheduleUid points at the old one, along with rescheduleId, rescheduleStartTime and rescheduleEndTime. attendees[].phoneNumber appears in some payloads, but it is null in the samples, so read responses instead.

Verify the signature and treat retries as unknown

Cal signs the raw body with HMAC-SHA256 and sends the hex digest in X-Cal-Signature-256. The Cal.diy source computes createHmac("sha256", params.secret).update(`${params.body}`).digest("hex") and sends it with X-Cal-Webhook-Version (sendPayload.ts, accessed 2026-11-25). No timestamp is signed, so the signature gives no replay protection. Deduplicate on your side.

Without a secret, the header holds the literal string no-secret-provided, which the service rejects. If a custom payloadTemplate isn’t valid JSON, the content type becomes application/x-www-form-urlencoded. And the request is a single fetch with redirect: "manual", so a 3xx is not followed. Give Cal the final HTTPS URL, never one that redirects.

That file has no retry and no timeout. The help page says “Delivery can retry and arrive more than once or out of order”, but only for registration events. Cal documents no retry policy for booking webhooks. The service answers 200 at once, dedupes on triggerEvent plus uid, and does the work after the response.

The WhatsApp side uses a different scheme, X-Hub-Signature-256 with a sha256= prefix and your app secret. Verify X-Hub-Signature-256 on WhatsApp webhooks explains why both checks must run on the raw bytes.

Two templates and three buttons

Both messages are utility templates. They are tied to a booking the attendee made and carry no promotion, which is the test the reminder pillar walks through. Create them with the same message_templates call shown there.

Template Body Buttons TTL
booking_confirmed Hi {{customer_name}}, your {{event}} is booked for {{date}} at {{time}}. Reply here if you need to change it. None Default
booking_reminder_24h Hi {{customer_name}}, a reminder that your {{event}} is on {{date}} at {{time}}. Please confirm, reschedule or cancel below. Quick replies Confirm, Reschedule, Cancel 43,200 seconds

For clinics and other health services, fill {{event}} with a neutral word such as “appointment”, because a Cal event title can name a treatment.

For the confirmation, Meta’s booking appointment template is an alternative when you want a “View details” sheet with a manage link. It can’t carry quick replies, so it can’t be the reminder. The pillar post lists its fields. Its create call and send parameters are covered in full in the booking appointment template guide.

The service

This file runs as pasted on Node 18 or later with Express 4. It holds state in memory so you can try it. The two webhook routes verify their own signatures, and the reminder job runs every minute.

// cal-whatsapp.js: Cal.com or Cal.diy bookings to WhatsApp confirmation, reminder and replies.
// Node 18+ and Express 4. Run: npm install express && node cal-whatsapp.js
const crypto = require("crypto");
const express = require("express");

function env(name, fallback) {
  const value = process.env[name] || fallback;
  if (!value) throw new Error(`Missing environment variable ${name}`);
  return value;
}
const CAL_WEBHOOK_SECRET = env("CAL_WEBHOOK_SECRET");
const CAL_API_KEY = env("CAL_API_KEY"); // cal_live_... or cal_... for test
const CAL_API_BASE = env("CAL_API_BASE", "https://api.cal.com/v2"); // Cal.diy: your own deployment
const CAL_EVENT_TYPE_ID = env("CAL_EVENT_TYPE_ID"); // the event type to offer slots from
const CONSENT_FIELD = env("CONSENT_FIELD", "whatsappConsent"); // your checkbox question
const WA_TOKEN = env("WA_TOKEN");
const PHONE_NUMBER_ID = env("PHONE_NUMBER_ID");
const APP_SECRET = env("APP_SECRET");
const VERIFY_TOKEN = env("VERIFY_TOKEN");
const PORT = Number(env("PORT", "3000"));

const GRAPH_URL = `https://graph.facebook.com/v26.0/${PHONE_NUMBER_ID}/messages`;
const MINUTE = 60 * 1000;
const HOUR = 60 * MINUTE;
const REMINDER_LEAD = 24 * HOUR;
const REMINDER_TTL = 12 * HOUR; // message_send_ttl_seconds 43200 on booking_reminder_24h

// In-memory state so the file runs as is. Use your database in production.
const bookings = new Map(); // Cal booking uid -> local booking
const ownReschedules = new Set(); // old uids we rescheduled from WhatsApp
const seenCal = new Set(); // triggerEvent:uid already processed
const seenWa = new Set(); // inbound wamids already processed

const digits = (phone) => String(phone || "").replace(/\D/g, "");
function safeEqual(a, b) {
  const x = Buffer.from(a);
  const y = Buffer.from(b);
  return x.length === y.length && crypto.timingSafeEqual(x, y);
}

function formatWhen(iso, timeZone) {
  const d = new Date(iso);
  return {
    date: d.toLocaleDateString("en-US", { timeZone, weekday: "long", month: "long", day: "numeric" }),
    time: d.toLocaleTimeString("en-US", { timeZone, hour: "numeric", minute: "2-digit" }),
    short: d.toLocaleString("en-US", {
      timeZone, weekday: "short", month: "short", day: "numeric", hour: "numeric", minute: "2-digit",
    }),
  };
}

async function cal(method, path, version, body) {
  const res = await fetch(CAL_API_BASE + path, {
    method,
    headers: {
      Authorization: `Bearer ${CAL_API_KEY}`,
      "cal-api-version": version,
      ...(body ? { "Content-Type": "application/json" } : {}),
    },
    body: body ? JSON.stringify(body) : undefined,
  });
  const data = await res.json().catch(() => ({}));
  if (!res.ok) {
    const err = new Error(`Cal ${method} ${path} returned ${res.status}: ${JSON.stringify(data)}`);
    err.status = res.status;
    throw err;
  }
  return data;
}

async function sendWhatsApp(message, attempt = 1) {
  let status = 0;
  let data = {};
  try {
    const res = await fetch(GRAPH_URL, {
      method: "POST",
      headers: { Authorization: `Bearer ${WA_TOKEN}`, "Content-Type": "application/json" },
      body: JSON.stringify({ messaging_product: "whatsapp", recipient_type: "individual", ...message }),
    });
    status = res.status;
    data = await res.json().catch(() => ({}));
    if (res.ok) return data.messages[0].id;
  } catch (err) {
    data = { error: String(err) };
  }
  if ((status === 0 || status === 429 || status >= 500) && attempt < 4) {
    await new Promise((resolve) => setTimeout(resolve, 2 ** attempt * 1000));
    return sendWhatsApp(message, attempt + 1);
  }
  throw new Error(`WhatsApp send failed with HTTP ${status}: ${JSON.stringify(data)}`);
}

const sendText = (to, body) => sendWhatsApp({ to, type: "text", text: { body } });

function templateMessage(booking, name, withButtons) {
  const when = formatWhen(booking.startTime, booking.timeZone);
  const components = [{
    type: "body",
    parameters: [
      { type: "text", parameter_name: "customer_name", text: booking.name },
      { type: "text", parameter_name: "event", text: booking.title },
      { type: "text", parameter_name: "date", text: when.date },
      { type: "text", parameter_name: "time", text: when.time },
    ],
  }];
  if (withButtons) {
    ["confirm", "reschedule", "cancel"].forEach((action, index) => components.push({
      type: "button",
      sub_type: "quick_reply",
      index: String(index),
      parameters: [{ type: "payload", payload: `cal|${booking.uid}|${action}` }],
    }));
  }
  return { to: booking.phone, type: "template", template: { name, language: { code: "en_US" }, components } };
}

function fromPayload(p) {
  const attendee = (p.attendees || [])[0] || {};
  return {
    uid: p.uid,
    title: p.title || "appointment",
    name: attendee.name || p.responses?.name?.value || "there",
    phone: digits(p.responses?.attendeePhoneNumber?.value),
    consent: p.responses?.[CONSENT_FIELD]?.value === true,
    startTime: p.startTime,
    timeZone: attendee.timeZone || "UTC",
    createdAt: Date.now(),
    status: "booked", // booked | confirmed | reschedule_requested | cancelled
    reminder: null, // null | "sending" | "skipped" | "failed" | wamid
  };
}

function moveBooking(oldUid, newUid, startTime) {
  if (bookings.has(newUid)) return bookings.get(newUid); // already moved
  const old = bookings.get(oldUid);
  if (!old) return null;
  bookings.delete(oldUid);
  const moved = { ...old, uid: newUid, startTime, status: "booked", reminder: null, createdAt: Date.now() };
  bookings.set(newUid, moved);
  return moved;
}

const canMessage = (booking) => Boolean(booking.phone && booking.consent);

async function onCalEvent(triggerEvent, p) {
  if (triggerEvent === "BOOKING_CREATED") {
    const booking = fromPayload(p);
    bookings.set(booking.uid, booking);
    if (canMessage(booking)) await sendWhatsApp(templateMessage(booking, "booking_confirmed", false));
    return;
  }
  if (triggerEvent === "BOOKING_RESCHEDULED") {
    const ours = ownReschedules.has(p.rescheduleUid); // we already confirmed it in the chat
    let booking = moveBooking(p.rescheduleUid, p.uid, p.startTime);
    if (!booking) {
      booking = fromPayload(p);
      bookings.set(booking.uid, booking);
    }
    if (ours) booking.status = "confirmed"; // the attendee picked this time in the chat
    else if (canMessage(booking)) await sendWhatsApp(templateMessage(booking, "booking_confirmed", false));
    return;
  }
  if (triggerEvent === "BOOKING_CANCELLED") {
    const booking = bookings.get(p.uid);
    if (booking) booking.status = "cancelled"; // stops the reminder
    return;
  }
  console.log("not handled", triggerEvent, p.uid); // BOOKING_REQUESTED and others
}

async function runReminders() {
  const now = Date.now();
  for (const booking of bookings.values()) {
    if (booking.reminder || !canMessage(booking) || booking.status === "cancelled") continue;
    const start = Date.parse(booking.startTime);
    if (now < start - REMINDER_LEAD) continue;
    const bookedLate = booking.createdAt > start - REMINDER_LEAD; // the confirmation was enough
    if (bookedLate || now >= start - REMINDER_LEAD + REMINDER_TTL || now >= start) {
      booking.reminder = "skipped";
      continue;
    }
    booking.reminder = "sending";
    try {
      booking.reminder = await sendWhatsApp(templateMessage(booking, "booking_reminder_24h", true));
    } catch (err) {
      booking.reminder = "failed";
      console.error("reminder failed", booking.uid, err.message);
    }
  }
}

async function offerSlots(booking) {
  const query = new URLSearchParams({
    eventTypeId: CAL_EVENT_TYPE_ID,
    start: new Date().toISOString(),
    end: new Date(Date.now() + 7 * 24 * HOUR).toISOString(),
    timeZone: booking.timeZone,
  });
  const { data = {} } = await cal("GET", `/slots?${query}`, "2024-09-04");
  const rows = Object.values(data).flat().slice(0, 10).map((slot) => ({
    id: `slot|${booking.uid}|${slot.start}`,
    title: formatWhen(slot.start, booking.timeZone).short.slice(0, 24),
  }));
  if (rows.length === 0) {
    booking.status = "booked";
    return sendText(booking.phone, "There are no open times in the next 7 days. Reply here and a person will help.");
  }
  return sendWhatsApp({
    to: booking.phone,
    type: "interactive",
    interactive: {
      type: "list",
      body: { text: "Pick a new time for your booking:" },
      action: { button: "See times", sections: [{ title: "Open times", rows }] },
    },
  });
}

async function onTap(booking, action) {
  if (booking.status === "cancelled") return sendText(booking.phone, "This booking is already cancelled.");
  if (Date.parse(booking.startTime) <= Date.now()) return sendText(booking.phone, "This booking has already passed.");
  const when = formatWhen(booking.startTime, booking.timeZone);
  if (action === "confirm") {
    if (booking.status === "confirmed") return;
    booking.status = "confirmed"; // Cal has no attendee confirm endpoint: this table is the record
    return sendText(booking.phone, `Thanks, ${booking.name}. You are confirmed for ${when.date} at ${when.time}.`);
  }
  if (action === "cancel") {
    booking.status = "cancelled"; // set first so a second tap does nothing
    try {
      await cal("POST", `/bookings/${booking.uid}/cancel`, "2026-02-25", {
        cancellationReason: "Cancelled by the attendee on WhatsApp",
      });
    } catch (err) {
      booking.status = "booked";
      console.error(err.message);
      return sendText(booking.phone, "We could not cancel this booking. A person on our team will follow up.");
    }
    return sendText(booking.phone, "Your booking is cancelled.");
  }
  if (action === "reschedule") {
    if (booking.status === "reschedule_requested") return;
    booking.status = "reschedule_requested";
    try {
      return await offerSlots(booking);
    } catch (err) {
      booking.status = "booked";
      console.error(err.message);
      return sendText(booking.phone, "We could not load open times. A person on our team will follow up.");
    }
  }
}

async function onSlot(booking, start) {
  if (booking.status !== "reschedule_requested" || Number.isNaN(Date.parse(start))) return;
  ownReschedules.add(booking.uid);
  let result;
  try {
    result = await cal("POST", `/bookings/${booking.uid}/reschedule`, "2026-02-25", {
      start,
      reschedulingReason: "Requested by the attendee on WhatsApp",
    });
  } catch (err) {
    ownReschedules.delete(booking.uid);
    booking.status = "booked";
    console.error(err.message);
    return sendText(booking.phone, "We could not move your booking. A person on our team will follow up.");
  }
  const d = result.data || {};
  const newUid = d.rescheduledToUid || (d.rescheduledFromUid ? d.uid : null);
  // Without a new uid in the response, the BOOKING_RESCHEDULED webhook moves the booking.
  const moved = newUid ? moveBooking(booking.uid, newUid, start) : booking;
  moved.status = "confirmed";
  const when = formatWhen(start, moved.timeZone);
  return sendText(moved.phone, `Done. Your new time is ${when.date} at ${when.time}.`);
}

async function onWhatsAppMessage(msg) {
  if (msg.type === "button") {
    const [prefix, uid, action] = String(msg.button?.payload || "").split("|");
    const fromContext = [...bookings.values()].find((b) => b.reminder === msg.context?.id);
    const booking = prefix === "cal" ? bookings.get(uid) : fromContext;
    const act = prefix === "cal" ? action : { Confirm: "confirm", Reschedule: "reschedule", Cancel: "cancel" }[msg.button?.text];
    if (booking && act) return onTap(booking, act);
    return console.warn("unmatched tap", msg.id); // for example a reminder for a time that has since moved
  }
  if (msg.type === "interactive" && msg.interactive?.type === "list_reply") {
    const [prefix, uid, start] = String(msg.interactive.list_reply?.id || "").split("|");
    const booking = bookings.get(uid);
    if (prefix === "slot" && booking) return onSlot(booking, start);
    return;
  }
  if (msg.type === "text" && msg.from && /^\s*stop\s*$/i.test(msg.text?.body || "")) {
    for (const booking of bookings.values()) if (booking.phone === msg.from) booking.consent = false;
    return sendText(msg.from, "You will not get booking messages here anymore.");
  }
}

const app = express();

app.post("/cal/webhook", express.raw({ type: "*/*" }), (req, res) => {
  const header = req.get("X-Cal-Signature-256") || "";
  if (!Buffer.isBuffer(req.body) || header === "no-secret-provided") return res.sendStatus(401);
  const expected = crypto.createHmac("sha256", CAL_WEBHOOK_SECRET).update(req.body).digest("hex");
  if (!safeEqual(header, expected)) return res.sendStatus(401);
  let event;
  try {
    event = JSON.parse(req.body.toString("utf8"));
  } catch {
    return res.sendStatus(400);
  }
  res.sendStatus(200); // answer first, work after
  const key = `${event.triggerEvent}:${event.payload?.uid}`;
  if (seenCal.has(key)) return;
  seenCal.add(key);
  onCalEvent(event.triggerEvent, event.payload || {}).catch((err) => console.error("cal event", key, err.message));
});

app.get("/wa/webhook", (req, res) => {
  const ok = req.query["hub.mode"] === "subscribe" && req.query["hub.verify_token"] === VERIFY_TOKEN;
  return ok ? res.send(String(req.query["hub.challenge"])) : res.sendStatus(403);
});

app.post("/wa/webhook", express.raw({ type: "application/json" }), (req, res) => {
  if (!Buffer.isBuffer(req.body)) return res.sendStatus(400);
  const expected = "sha256=" + crypto.createHmac("sha256", APP_SECRET).update(req.body).digest("hex");
  if (!safeEqual(req.get("X-Hub-Signature-256") || "", expected)) return res.sendStatus(401);
  res.sendStatus(200);
  let body;
  try {
    body = JSON.parse(req.body.toString("utf8"));
  } catch {
    return;
  }
  for (const entry of body.entry || []) {
    for (const change of entry.changes || []) {
      if (change.field !== "messages") continue;
      for (const status of change.value?.statuses || []) {
        if (status.status === "failed") console.warn("send failed", status.id, JSON.stringify(status.errors));
      }
      for (const msg of change.value?.messages || []) {
        if (seenWa.has(msg.id)) continue;
        seenWa.add(msg.id);
        onWhatsAppMessage(msg).catch((err) => console.error("whatsapp message", msg.id, err.message));
      }
    }
  }
});

setInterval(() => runReminders().catch((err) => console.error("scheduler", err.message)), MINUTE);
app.listen(PORT, () => console.log(`listening on ${PORT}`));

To try the Cal route without a real booking, sign a body yourself with the same secret. The service answers 200, then tries to send booking_confirmed, which needs the approved template and a WhatsApp number that accepts test messages.

BODY='{"triggerEvent":"BOOKING_CREATED","createdAt":"2026-11-25T12:00:00.000Z","payload":{"uid":"test-uid-1","title":"Consultation","startTime":"2026-11-28T15:00:00.000Z","endTime":"2026-11-28T15:30:00.000Z","attendees":[{"name":"Marina","timeZone":"America/New_York"}],"responses":{"attendeePhoneNumber":{"label":"Phone","value":"+16505551234","isHidden":false},"whatsappConsent":{"label":"WhatsApp","value":true,"isHidden":false}}}}'
SIG=$(printf '%s' "$BODY" | openssl dgst -sha256 -hmac "$CAL_WEBHOOK_SECRET" | awk '{print $NF}')
curl -i -X POST http://localhost:3000/cal/webhook \
  -H "Content-Type: application/json" \
  -H "X-Cal-Signature-256: $SIG" \
  --data-binary "$BODY"

Write the reply back to Cal.com

Every booking endpoint warns that cal-api-version “Must be set to 2026-02-25”. Other values fall back to an older version of the endpoint. The slots endpoint is the exception: it requires 2024-09-04. Authentication is Authorization: Bearer with a cal_live_ key, or a cal_ test key.

Tap Call cal-api-version Body
Cancel POST /v2/bookings/{bookingUid}/cancel 2026-02-25 cancellationReason
Reschedule, step 1 GET /v2/slots?eventTypeId=&start=&end=&timeZone= 2024-09-04 None
Reschedule, step 2 POST /v2/bookings/{bookingUid}/reschedule 2026-02-25 start (required), reschedulingReason
Confirm None in Cal: store it in your own table n/a n/a

Sources: Cal.com API v2 reference pages for cancel, slots and reschedule, accessed 2026-11-25.

Cancel returns {status: "success", data: {...}}. Reschedule returns 201, with rescheduledFromUid and rescheduledToUid linking the two bookings. Bookings that are cancelled, rejected or awaiting_host return 400, and a pending booking stays pending after the move. Slots come back as data keyed by date, each holding objects with start, or {} when nothing is free. That page’s schema and example disagree slightly, so log one real response before you trust the parser. The service offers at most 10 slots, the row limit of a WhatsApp list, listed with the other limits in interactive buttons and list messages.

POST /v2/bookings/{uid}/confirm exists, but it is the host accepting a pending booking, not the attendee confirming attendance (confirm a booking, accessed 2026-11-25). We found no endpoint to write booking metadata either. Keep the attendee’s confirmation in your own table. If you mark no-shows later, the mark-absent endpoint’s version header is documented as 2024-08-13, while a third-party page says 2026-02-25, so test it.

One alternative to the slot list is POST /v2/bookings/{bookingUid}/request-reschedule. Cal’s page says “The booking will be cancelled and the attendee will receive an email with a link to reschedule.” That moves the conversation to email and cancels first, so the service doesn’t use it.

The API allows 120 requests per minute per key, raisable to 200 (API v2 introduction, accessed 2026-11-25). The base URL https://api.cal.com/v2 comes from Cal’s examples. On Cal.diy, point CAL_API_BASE at your own deployment’s API v2.

When the loop breaks

Your own calls come back as webhooks

A cancel or reschedule made from WhatsApp fires BOOKING_CANCELLED or BOOKING_RESCHEDULED back to your endpoint. Without a guard, the customer gets a second confirmation for a change they made a minute ago. The service records the old uid in ownReschedules before the call and stays silent when the webhook names it. A cancel sends nothing on the webhook path at all.

The booking moves to a new uid

On reschedule, the reminder state must follow the new uid. moveBooking copies the local row to the new key, resets the reminder and makes the call idempotent. Whichever arrives first, the API response or the webhook, does the move, and the second finds it done. A tap on a reminder sent for the old time no longer matches a booking, so the service logs it instead of acting on the wrong appointment.

Duplicate or out-of-order events

Because Cal signs no timestamp and documents no retry policy for bookings, dedupe on triggerEvent plus uid. A BOOKING_CANCELLED that arrives after a reschedule names the old uid, which no longer exists locally, so it does nothing. Move the in-memory sets to a unique index before production.

A booking without a phone or without the consent box gets no WhatsApp message at all. A reply of STOP clears consent on every booking for that number. Inbound WhatsApp duplicates are skipped by message id, as in the reminder pillar.

Cal.com refuses the change

A 400 on reschedule usually means the booking is canceled, rejected or still waiting for the host. The service resets the state and tells the customer a person will follow up. Route those cases to a real inbox, because a silent failure here leaves the attendee thinking the move went through.

Where Z-API Omni fits

Omni sends the same two templates on a Meta Cloud API channel and the slot list as an interactive list on WhatsApp. Its n8n integration page lists Send Template and Send Interactive Button operations and no trigger node. If you build this flow in n8n instead of Express, use n8n’s Webhook node for both the Cal events and the inbound messages. The inbound JSON of a template button tap isn’t documented yet, so test that branch before you depend on it.

Each number costs US$29 a month for 1 to 10 numbers, US$26 for 11 to 50, US$23 for 51 to 100 and US$20 above 100. Webhooks are included without limit, and Meta’s fees are passed through on the official connection.

View documentation

Z-API Omni team