Product · Mobile · Backend · Next.js
The Pager That Needs No Scan
Part two of building a phone-as-pager for restaurants. When the system already knows who the customer is, the scan disappears: identity captured at order time, the kitchen screen as the trigger, four channels behind one notifier, and the two clocks that stop a silently undelivered push from becoming a customer who never gets told. Plus why I'd poll a status API rather than wait for a webhook.
In the first post I built a pager out of a QR code: you order at a kiosk or a counter, a code comes back with the order, you scan it, and your own phone becomes the buzzer. The property I cared most about was that it works for a complete stranger who tells the system nothing — no name, no number, no account, no app — because the plastic puck it replaces asks for nothing either.
But it still starts with a customer scanning a QR code. That's a real action, and real actions have drop-off. Some people won't scan. Some phones have a camera app that fights them. Someone hands the receipt to a friend. And on a busy counter, "scan this" is one more sentence a staff member has to say and one more thing to go wrong.
So the natural next question is: when do we already know who the customer is, and can we skip the scan entirely?
Quite often, it turns out. The order isn't anonymous nearly as often as the QR design assumes. A member scans their loyalty QR at the counter. A cashier types a phone number for the receipt. The customer is standing there with the brand's app already open and signed in. In every one of those cases the system has an identity before the food is cooked — and an identity is all a pager really needs.
That reframes the feature. The QR flow answers "how do I reach a stranger's phone?" This post answers an easier question — "how do I reach a customer I already recognise?" — and then the much harder one sitting underneath it, which is how you deliver a message you cannot prove arrived.
Fair warning on status, same as last time: this half is design rather than shipped code. It's grounded in things that already exist, but none of it is built yet.
What identity looks like at order time
Three things can bind an order to a person, in descending order of how good the resulting experience is.
A member code. The loyalty account already carries a memberCode, and the app
already displays it as a scannable member QR in the wallet and profile screens. That
QR exists today so customers can earn points at the counter. The realisation worth
having is that it's the same handshake, running the other direction: instead of the
customer scanning the kiosk, the counter scans the customer. One scan, already part of
the loyalty ritual, and now the order knows whose phone to buzz.
A signed-in app session. If the customer ordered from the app in the first place —
or is simply signed in on the device — the identity is already established. The native
shell hands the web layer the customer identifier over the same bridge it uses for
everything else, preferring memberCode and falling back to customerId, and the
auth UID and push token are already on hand.
A phone number. The weakest form and by far the most common: someone reads out ten digits at the counter. No app, no account, no loyalty. But it's enough to send a message, which turns out to be enough to build a pager on.
The important detail is that the checkout payload already has room for all of this. It
accepts customerId, authUid, and — this is the one that matters most — pushToken.
A push token, at order-creation time, in the same call that creates the order.
That's the whole trick of the identity path. If the token is on the order when the order is born, there is nothing to register later, no bridge call to make, no page for the customer to keep open, and no QR to scan. The binding that the entire part-one architecture works to establish through a scan can, in the identity case, simply be an attribute of the order from the first millisecond.
There's a rule I had to write down explicitly, because this is the exact point where a convenient feature starts bending an operation into a shape nobody chose: never ask for identity I don't already have — only harvest what's already there. All three sources above are opportunistic. The member QR was already being scanned for points. The app session already existed. The number was already given, for a receipt.
What must never happen is that this feature becomes the reason a counter starts asking for phone numbers. The moment "can I get your number?" enters the script, the anonymous customer from the top of this post has to decline something — and being made to refuse is a worse experience than being handed a plastic coaster, by a wide margin. Anonymous stays the default path. Identity is a shortcut taken when it happens to be lying on the floor, never a toll collected on the way to lunch.
The trigger moves to the kitchen
The QR path is customer-triggered: someone scans, a page opens, that page polls. This one is kitchen-triggered, and that's a better shape.
The chef is already touching a screen. When an order is accepted, when it's fired, when
it's plated and ready — the kitchen display is where the truth about that order actually
changes. The status vocabulary already exists and already moves: an order goes from
placed, to confirmed by the kitchen, to prepared, to served, carried in order_state
and ticket_state on the ticket.
Nobody has to do anything new. The chef advances the ticket exactly as they do today, and that single tap becomes the event that notifies every customer who's bound to that order, on every channel they're bound through. The notification stops being a feature the customer opts into and becomes a consequence of the kitchen doing its job.
This is the part I like most architecturally, because it inverts the effort. On the QR path, the customer does work (scan, open, enable, keep the page alive) so that the system can tell them something. Here, the system does the work, and the customer does nothing at all. The best interface for "your food is ready" is no interface — just a buzz that arrives.
One event, every channel it has
Once the trigger is a status change rather than a page, the delivery mechanism becomes a fan-out: one event, offered to whichever channels that order actually has bound.
App push is the real pager — instant, silent until it matters, and the only channel that can vibrate the phone in someone's pocket the way the plastic puck did. It fires whenever a device token is on the order, whether the token arrived at checkout or through the QR path from the first post. Same push, same payload, two ways of getting bound.
Web push is that same idea without the install. Once the notifier exists, a browser subscription is just another transport row sitting next to a device token, and it reaches the Android customer who scanned a QR and downloaded nothing. It's the cheapest channel here — no per-message cost at all — and the most anonymous, since a push endpoint identifies a browser rather than a person. The only reason it sits second rather than first is platform coverage, not preference; the first post has the ladder and the iOS caveat that puts it there.
WhatsApp is the one that changes the economics, and in most of the markets I build for it isn't a nice-to-have — it's where people actually read messages. If all we have is a phone number, a WhatsApp template message on each meaningful status is a genuinely good pager: it lands on the lock screen, it buzzes, it threads into a conversation the customer can scroll back through, and it costs a fraction of what the equivalent SMS volume does. Crucially it requires nothing from the customer — no app, no install prompt, no account. The number they gave for the receipt is the number that buzzes.
SMS is the floor beneath WhatsApp. It works on a phone with no data, no smartphone OS, and no messaging app, which is exactly the customer the other two channels quietly exclude. It's the most expensive per message and the least expressive, so it's the fallback rather than the default — used when WhatsApp can't deliver, or when a venue serves a demographic where it's simply the right call.
The design rule tying them together: one message per meaningful state, per order, per channel, and never two channels saying the same thing. If a device token is bound, the push is the pager and the WhatsApp message doesn't fire — a customer who gets buzzed twice for one plate of food learns to ignore both. Channel selection resolves once, in priority order, when the notifier runs.
Resolves once, but not forever — and that caveat is what the next section is about. The chosen channel gets a deadline, and if nothing confirms delivery
before it passes, the notifier moves down the list rather than assuming a buzz that
never happened. What keeps that from becoming the double-message problem is the dedupe
key: (orderId, state), marked the moment any channel confirms, so an escalation and
a late delivery confirmation collapse into one message instead of two.
Two clocks: push and polling, together
This is the decision I like most in the whole design, and it came from asking a dull question — what happens when a push just doesn't arrive?
Push is not a delivery guarantee. It's a best-effort handoff to FCM, to APNs, or to a browser vendor's push service, and then onward to a phone that might be in Doze, stuck behind a hotel wifi captive portal, or holding a token that went stale when its owner reinstalled the app last week. Worse, the failure is silent at both ends: my server gets a cheerful queued response, and the customer gets nothing at all. A pager that fails silently is worse than no pager, because the customer has stopped watching the counter on the strength of my promise.
So neither mechanism is allowed to be the only one. Every path runs two clocks.
On the client, a page that's open keeps a watchdog. An arriving push updates the UI immediately and resets the clock. If no push lands within a window of when the order was expected to move, the watchdog quietly resumes the ordinary status poll and the page catches itself up. The customer never learns which mechanism told them — push is the fast path, polling is the floor, and the interface is identical either way.
On the server, the notifier does the same thing one layer up. A push goes out and a deadline goes with it. If nothing confirms delivery before that deadline, the notifier escalates to the next bound channel instead of assuming the buzz happened. That's the whole distance between "we sent a push" and "the customer knows," and only the second one is the product.
Order reaches READY
→ push dispatched, deadline set
→ delivery confirmed? → done
→ deadline passed? → escalate to the next bound channel
(WhatsApp → SMS, and an open page polls it up anyway)Two rules stop this collapsing into the double-buzz problem I warned about earlier.
The escalation is sequential, not parallel. Channels are tried in priority order with a deadline between them, never fanned out at once in the hope that one lands. A customer who gets a push and a WhatsApp and an SMS for one plate of food learns, very efficiently, to ignore all three.
The dedupe key is the order and the state, not the attempt. (orderId, READY) is
marked notified the instant any channel confirms, so a transport retry, a replayed
webhook, and a watchdog firing at the same moment all collapse into one message.
Idempotency at the level of the business event rather than the transport is what makes
it safe to be this aggressive about delivery.
It's the frontend philosophy from the first post pointed at the backend: native push, then web push, then another channel, then a poll, then a number printed on a receipt — each layer independently sufficient, each one slower and dumber than the last.
Which states are worth interrupting someone for
More status updates is not a better product. Every message is an interruption, and the quickest way to make a customer mute a channel forever is to narrate the entire life of their order at them.
So the states earn their message individually:
Accepted by the kitchen — worth one message, and only for orders placed remotely or scheduled ahead. It answers a real anxiety ("did that actually go through?"). For a customer standing ten feet from the counter who just paid, it's noise; they watched it happen.
Ready — the message the whole system exists for. Always sent, on every channel, on every path. This is the buzz.
Delayed or rejected — the underrated one. Physical pagers cannot express this at all, which means the customer's only recourse today is to walk up and ask. A message that says the kitchen is running behind, or that something on the order can't be made, turns the worst service moment into a manageable one. In many ways this is a bigger upgrade over the plastic puck than the ready alert itself, because it's information the old hardware was categorically incapable of carrying.
Completed or served — almost never worth sending. The customer is holding the food. They know. The only reason to send anything here is a receipt or a rating prompt, and that's a different feature with different consent, not a pager alert.
That editorial judgement — which events deserve a vibration and which are just the system talking about itself — is most of the design work in a notification feature. The plumbing is easy. Knowing when to shut up is not.
The backend half
The web layer from the first post answers "what is the status of this order?" — the existing status API does that well. It cannot answer the question the pager actually depends on: "which phone should be notified when this order changes?" Nothing in the current system stores that relationship, so it needs a small, purpose-built layer:
- Register:
POST /api/order-status/alertsbinds an order to one or more device tokens, with platform and current status. - Watch: either poll the status API server-side for registered orders, or consume a POS webhook if one is available.
- Send: push when the order reaches ready, with fulfilment-appropriate copy — "Order #784919 is ready for pickup" for takeaway, "Order #784919 is ready to serve. Please show this screen at the counter" for dine-in.
- Deduplicate: mark the notification sent, because a status watcher that fires twice buzzes the customer twice, and a pager that cries wolf gets ignored exactly like a smoke alarm does.
I want to flag the naming choice, small as it is. I went with
/api/order-status/alerts rather than a sprawling /api/order-alert-subscriptions,
because grouping it under order-status says something true about where this belongs:
it's not a new subscriptions subsystem, it's one more thing you can do with an order's
status. API paths are documentation that can't drift, and the shape of your URLs is
the shape of how the next engineer will think about your system.
Note also that one order maps to many tokens, not one. Two people at a table can both scan the same QR from the same receipt, and both should get buzzed. Modelling that as one-to-one on day one would be a migration later for no reason.
The one real dependency is the trigger
If I had to name the single point of failure in all of this, it isn't push, and it isn't the app. It's step 2 above: how does my backend find out that an order became ready? Every channel, both clocks, and both halves of this post hang off that one event arriving.
There are two ways to get it, and they fail in opposite directions.
A POS webhook is fast — the chef taps, my endpoint knows about a second later. It also needs the POS to offer one, and it needs me to build retries, idempotency keys and a dead-letter path, because a dropped webhook is dropped forever and nothing in the system notices. The customer simply never gets buzzed, and I find out from a complaint.
Server-side polling of the status API is slower and very hard to break. It needs cooperation from nobody, it runs against an API I already use, and it is self-healing: a tick that fails is caught by the next one. The cost is arithmetic rather than architecture — two hundred live orders polled every fifteen seconds is about thirteen requests a second, which is nothing, and it only ever polls orders that are both registered and non-terminal.
So: polling first, webhook as an optimisation, and keep the poller running afterwards as reconciliation. The webhook makes it fast; the poller makes it true.
What makes me comfortable leading with the slow one is having actually written out the latency budget, which I'd recommend to anyone who thinks they need real-time:
chef taps READY on the kitchen display
→ ingress ~1s (webhook) or 0–15s (poll)
→ notifier + dedupe <100ms
→ FCM / APNs / web push delivery 1–5s, longer under Doze
→ phone vibrates
≈ 5s worst case with a webhook
≈ 20s worst case on polling aloneTwenty seconds. The food sits under a heat lamp longer than that, and the walk back from two shops down is longer than that. A pager doesn't need to be real-time; it needs to be reliable. Which means the thing I was most tempted to treat as a blocker — waiting on a webhook that lives on somebody else's roadmap — isn't a blocker at all. I can build the entire feature on polling, ship it, and let the webhook land later as a latency improvement no customer will consciously notice.
That's the same argument as the frontend degradation ladder, turned around and aimed at the backend. I didn't notice the symmetry until I'd written both of them down, which is most of why I write these things down.
What gets harder
I want to be as honest about this half's costs as I was about the QR path's, because the identity-first path is more convenient and more dangerous.
Consent is not implied by a phone number. Someone giving their number so a receipt can be emailed to them has not asked to be messaged. Order-status updates are transactional and defensible; anything drifting toward marketing is a different conversation with different rules, and platform policy on WhatsApp business messaging draws that line hard. The engineering fix is boring and non-negotiable: separate the transactional binding from any marketing consent, store them apart, and never let a promotional send borrow a transactional binding.
A wrong number messages a stranger. Ten digits read aloud across a noisy counter is an error-prone channel, and the failure mode isn't a lost notification — it's an unrelated person receiving somebody else's order status. That's a small privacy incident, and it's why the message should carry the collection number and the venue but never a customer's name or the itemised order.
Stale tokens rot. A device token captured at checkout is only valid until the customer reinstalls, logs out, or the OS rotates it. Push silently fails against a dead token — you don't get an error the customer can see, you get nothing. Any serious implementation has to treat delivery failure as a signal, prune dead tokens, and fall through to the next channel rather than assuming a queued push is a delivered one.
Cost per message is real. Polling a status API is nearly free; WhatsApp and SMS are priced per send. That changes the calculus about which states are worth a message from a design opinion into a line item, which is a useful discipline — it makes restraint economically obvious as well as correct.
The two halves are one system
It's tempting to read the identity path as a replacement for the QR path. It isn't, and the distinction matters: they bind the same thing through different doors.
The QR path binds an anonymous walk-in to their order in the ten seconds after they pay. The identity path binds a recognised customer to their order before the kitchen even sees it. Both end at the same place — an order that knows how to reach a human — and both feed the same notifier, the same status vocabulary, the same dedupe rules, and in the app case the exact same push.
Which is why the sequencing works: the QR path had to be built first, because it forces you to solve the general problem of "how does an order reach a phone" without the luxury of knowing who anybody is. Once that exists, the identity path is a shortcut into it rather than a parallel system. It doesn't replace the scan — it just means most customers never need one.
And that's the honest end state I'm building toward. Not "scan this QR code to track your order," which is still asking something of a person who just wants lunch. Just: the food is ready, and their phone tells them, through whatever channel they already had.
Where this stands
This half is design, not code. The identity-first path is grounded in things that
already exist — the member QR and memberCode, the bridge that hands the app's customer
identifier to the web layer, and a checkout payload that already accepts pushToken and
authUid — but nothing in it is built yet.
It shares a dependency with the QR path anyway: both need the notifier and the status watcher, so the first slice of that work is the same work either way. That's the sequencing argument from the first post holding up — the web layer was useful on its own, the notifier makes both halves real, and each phase after it is a strict upgrade to something already working rather than a prerequisite for anything working at all.
If I had to pick the one piece to build first, it's the poller and the notifier with its
(orderId, state) dedupe key. Everything in both posts — the QR path's push, the
identity path's fan-out, web push, WhatsApp, SMS — arrives at that same object. It's the
smallest thing I can build that makes every other channel a configuration change rather
than a project.
