How to write a PRD for notifications: email, push, SMS, and in-app — without spamming your users
How to write a PRD for notifications: email, push, SMS, and in-app — without spamming your users Most PRDs describe notifications in one line: "users get notified when their generation is ready." Then the AI coding age
How to write a PRD for notifications: email, push, SMS, and in-app — without spamming your users
Most PRDs describe notifications in one line: "users get notified when their generation is ready." Then the AI coding agent fills in the blanks — and it fills them with the most common defaults it has seen: an email for everything, a push for everything, no preferences screen, no quiet hours, and no record of what was already sent. The user gets the same message three times on three channels, at 3 a.m., for an event they never asked to hear about.
Notifications are not a feature you can leave to defaults. Every message your product sends is a withdrawal from the user's trust. Spend it on things they asked for, on the channel they chose, at a time they accept — and the spec is where that contract gets written. Here is what I put in the spec when the product needs email, push, SMS, and in-app notifications.
1. Name every notification event in a table, not a sentence
"Notify the user" is not a requirement. It hides a dozen decisions: which events send a message, on which channel, to whom, and what happens when two events fire at once. If the PRD does not answer these, the agent answers them — usually by sending everything everywhere, or by building one sendEmail() call wired to the wrong trigger.
For Web Dev Mehedi, the events get their own section in PRODUCT_REQUIREMENTS.md, as a table:
## FEAT-041 — Notification events
| Event | Trigger | Channel | Audience |
|------------------------|----------------------------------|----------------|-----------------|
| Generation complete | All 4 files are ready | In-app + email | The user who generated |
| Credits low | Balance drops below 20 credits | In-app + email | The account owner |
| Payment confirmed | Webhook confirms a payment | Email | The payer |
| Payment failed | Provider reports failure | Email | The payer |
| Generation failed | A generation errors out | In-app + email | The user who generated |
| Weekly digest | Monday 09:00 Asia/Dhaka | Email | Opted-in users only |
Four rules sit under the table. First, no event sends an SMS — SMS is reserved for nothing in this product, and saying so in the spec stops the agent from adding it "helpfully" later. Second, in-app is the default channel and email is the backup: if the user is online when the generation completes, the in-app toast is the notification, and the email is skipped. Third, marketing messages are a separate list from product messages, and no product event may ever be used to carry a marketing line. Fourth, every event has exactly one owner event in the code — the agent may not invent a new event type without adding a row to this table first.
The acceptance criteria are checkable, not aspirational:
- GIVEN a generation completes while the user is on the site,
WHEN the suite is ready,
THEN the user sees an in-app toast and receives no email
for the same event.
- GIVEN a generation completes while the user is offline,
WHEN the suite is ready,
THEN one email is sent and the in-app notification is
waiting when they return.
- GIVEN a user's balance drops to 15 credits,
WHEN the low-credits threshold is crossed,
THEN one low-credits message is sent — and no second one
until the balance is topped up above 20 again.
- GIVEN a user has opted out of the weekly digest,
WHEN Monday 09:00 arrives,
THEN no digest email is sent to them.
Rule: if an event is not in the table, it does not send a message. The table is the whole list, and the list is the whole contract.
2. Specify the channel matrix and the user's control
A PRD that says "users can manage notification settings" has specified almost nothing. Which settings? Per event or one global switch? Does turning off email also turn off in-app? What happens at night? What does the user see the first time?
For PayTrack — the micro-merchant ledger from my template, where a shopkeeper records customer credit and takes payments over bKash and Nagad — the preferences are written out as their own feature:
## FEAT-042 — Notification preferences
- **Per-event switches**: every event in the FEAT-041 table has
its own on/off switch. Turning off "payment failed" email
never turns off "generation complete" — each event is
independent, and the default for every product event is ON.
- **Channel choice**: for each event the user picks in-app,
email, or both. SMS is not offered. The choice is stored
per event, not per user, because a merchant wants payment
failures by email and generation updates in-app.
- **Quiet hours**: the user sets a start and end time (default
22:00–08:00 Asia/Dhaka). During quiet hours, non-urgent
events are held and delivered as one summary when quiet
hours end. Payment failures are urgent and are never held.
- **Digest, not drip**: if three events fire for the same user
within 10 minutes, they are grouped into one message instead
of three. The digest names each event; it never hides one.
- **One-click unsubscribe**: every email carries an unsubscribe
link for that event type, not just for all mail. Clicking it
updates the preference immediately — no login required.
The "payment failures are urgent and are never held" rule is the one every vague spec skips, and it is the one that costs real money: a shopkeeper whose bKash payment failed needs to know now, not in a morning summary. Without that distinction in the spec, the agent either holds everything (and the user misses the failure) or holds nothing (and the user is woken at 3 a.m. by a digest).
The UI spec carries the preferences screen itself: a table with one row per event, a channel picker, and the quiet-hours control — so the agent builds a settings page that matches the rules, instead of a single "notifications on/off" toggle that deletes the whole contract.
3. Put delivery in the database, not in hope
This is the mistake I see most often in agent-built notification systems: the code calls the email provider and hopes. The provider retries, the webhook fires twice, the queue restarts — and the user gets the same "your generation is ready" email three times. Then the fix is an apology and a user who now ignores every message you send.
The notification record carries its own protection, in TECHNICAL_ARCHITECTURE.md:
-- Every message is a row before anything is sent
CREATE TABLE public.notifications (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id UUID NOT NULL REFERENCES auth.users(id) ON DELETE CASCADE,
event TEXT NOT NULL,
channel TEXT NOT NULL CHECK (channel IN ('in_app', 'email')),
-- The idempotency key: event + user + the thing it is about
dedupe_key TEXT NOT NULL UNIQUE,
status TEXT NOT NULL DEFAULT 'queued'
CHECK (status IN ('queued', 'sent', 'delivered', 'failed', 'read')),
title TEXT NOT NULL,
body TEXT NOT NULL,
deep_link TEXT,
send_after TIMESTAMPTZ DEFAULT now(),
created_at TIMESTAMPTZ DEFAULT now()
);
-- Preferences are rows too — one per user per event
CREATE TABLE public.notification_preferences (
user_id UUID NOT NULL REFERENCES auth.users(id) ON DELETE CASCADE,
event TEXT NOT NULL,
channel TEXT NOT NULL DEFAULT 'in_app'
CHECK (channel IN ('in_app', 'email', 'both', 'off')),
PRIMARY KEY (user_id, event)
);
ALTER TABLE public.notifications ENABLE ROW LEVEL SECURITY;
ALTER TABLE public.notification_preferences ENABLE ROW LEVEL SECURITY;
-- A user sees only their own notifications and preferences
CREATE POLICY "Users see their own notifications"
ON public.notifications FOR SELECT USING (user_id = auth.uid());
CREATE POLICY "Users manage their own preferences"
ON public.notification_preferences FOR ALL USING (user_id = auth.uid());
Two rules make this safe. First, dedupe_key is unique: the same event about the same generation can only ever create one notification row, so a retried webhook or a restarted queue cannot send the message twice. Second, sending is a state machine, not a function call — a row moves from queued to sent to delivered, and a failed row is retried with backoff, at most three times, before it is marked dead and reported. There is no bare sendEmail() anywhere for a bug to call twice.
The API contract carries the rest:
// POST /api/v1/notifications/preferences
export const UpdatePreferencesSchema = z.object({
event: z.string().min(1),
channel: z.enum(['in_app', 'email', 'both', 'off']),
});
// Internal: POST /api/v1/notifications/emit (server only, never from the client)
export const EmitNotificationSchema = z.object({
userId: z.string().uuid(),
event: z.string().min(1),
dedupeKey: z.string().min(1),
title: z.string().min(1).max(120),
body: z.string().min(1).max(500),
deepLink: z.string().optional(),
});
Note what the emit schema forbids: the client triggering a notification. If the browser can emit events, someone will spam another user. Only the server emits, and only after checking the preference row — the preference check happens before the notification row is created, so an opted-out user never even gets a queued row.
4. Specify templates and content rules in the UI spec
Notifications fail more often in their wording than in their delivery: a push that contains a password reset link, an email subject that says "Notification" and nothing else, a message with no link back to the thing it is about. Each one needs a designed template, because the alternative is the agent's default — a generic string with the user's data pasted in.
UI_UX_SPECIFICATION.md carries four content rules for Web Dev Mehedi:
## Notification content rules
- **Subject names the event**: "Your PRD suite is ready" —
never "Notification from Web Dev Mehedi" and never a bare
event code. The user decides from the inbox whether to open it.
- **No secrets in any message**: no passwords, no reset links in
push or in-app text, no full credit-card or transaction details.
A payment email names the plan and amount, never the provider's
raw response.
- **Every message links back**: the in-app toast and the email
both carry a deep link to the generation, the billing page, or
the relevant screen. A notification without a link is a dead end.
- **One language, one voice**: plain, short sentences; the event
first, the detail second, the action last. No marketing copy
inside a product message, ever.
The "no secrets" rule is the one teams skip, and it is the one that becomes a security incident: a push notification previewed on a lock screen is visible to anyone holding the phone. The spec says it plainly — sensitive values never leave the server in a message body.
5. The handoff: test the notification paths before shipping
Notifications are the one area where "it worked once" means nothing, because the developer testing it receives exactly one message, once, while watching. The implementation file therefore carries a test phase that fires the same event three times, opts a user out mid-flight, and sends at midnight:
Phase 4 — FEAT-041/042 Notifications
1. Implement the notifications and notification_preferences
tables exactly as specified in TECHNICAL_ARCHITECTURE.md §1.
2. Build the emit path, the preference screen, and the quiet-hours
hold from UI_UX_SPECIFICATION.md and the API schemas.
3. Test the duplicate path: emit the same generation-complete
event three times with the same dedupe_key. Exactly one
notification row exists and one message is sent.
4. Test the opt-out path: turn off the weekly digest, then trigger
Monday 09:00. No digest email is sent and no row is queued.
5. Test the quiet-hours path: fire a low-credits event at 23:00
with quiet hours 22:00–08:00. The message is held and delivered
as a summary at 08:00 — but a payment-failed event at 23:00
is delivered immediately.
6. Test the tampered path: send an emit request from the client
with another user's id and confirm it is rejected — only the
server emits notifications.
7. If any notification path behaves differently from the spec, stop
and report which one — do not relax a check to make a test pass.
That last instruction is the whole point. When a test fails, the tempting fix is to drop the dedupe key, or to send everything immediately "to make the demo smoother." A notification sent twice is trust spent twice. The failure is information: the spec, the emit path, or the test needs a human decision.
Where this lives in my specs
This is why the generator I built treats notifications as four files, not one line. PRODUCT_REQUIREMENTS.md carries the event table, the preference rules, and the checkable acceptance criteria. TECHNICAL_ARCHITECTURE.md carries the notifications and preferences tables, the unique dedupe key that stops double sending, and the Zod schemas that refuse a client-emitted event. UI_UX_SPECIFICATION.md carries the preference screen and the four content rules, so a message names its event, links back, and never leaks a secret. And AI_AGENT_IMPLEMENTATION.md carries the phased handoff, so the agent tests the duplicate event, the opt-out, the quiet hours, and the tampered emit before anything ships.
A PRD that says "users get notified" is a wish. A PRD that names the events, the channels, the quiet hours, the dedupe key, and the failure screens is a notification system an agent can actually build — and one your users will keep switched on.
If you want the same starting point, the generator writes the event table, the notifications and preferences schemas, the content rules, and the phased build order into every suite it produces. You can try it free with 50 credits at webdevmehedi.com/ai-prd-generator — and the free template behind the format is in the ai-prd-template repo.
Web Dev Mehedi turns an app idea into a build-ready PRD, UI/UX spec, database schema, API contracts, and Cursor/Claude Code rules in under 60 seconds. Free signup includes 50 credits; paid plans start at ৳99/month.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.