Files
co-lite/openspec/specs/lead-notifications/spec.md
T
ngqileandClaude Opus 5.5 5b11e90303 docs: archive add-custom-html-block and add-lead-notifications
Sync their spec deltas into landing-pages and the new lead-notifications
spec, and point the deployment SQL paths at the archive folders.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2026-12-03 09:05:20 +08:00

5.7 KiB

lead-notifications Specification

Purpose

In-app notifications for staff: a bell with unread state, and alerts when a lead is assigned, a landing-page sign-up arrives, a customer sends a WhatsApp message, or follow-ups fall due.

Requirements

Requirement: Staff Notification Bell

The portal SHALL show every signed-in staff user a bell in the header with the count of their unread notifications, refreshed at least every 30 seconds while the page is visible. Opening the bell SHALL list their newest notifications, newest first, and mark the listed ones read. Choosing a notification SHALL open the page it links to.

Scenario: Unread count and opening the bell

  • GIVEN a salesperson has 3 unread notifications
  • WHEN they open any portal page
  • THEN the bell shows 3
  • WHEN they open the bell
  • THEN the 3 notifications are listed newest first
  • AND after a reload the bell shows no unread count

Scenario: A notification opens its lead

  • GIVEN a "lead assigned" notification for lead L
  • WHEN the salesperson chooses it
  • THEN the portal opens lead L

Requirement: Notifications Page

The portal SHALL provide a notifications page listing the signed-in user's notifications, newest first and paged, showing which are unread, with an action to mark all of them read.

Scenario: Mark all read

  • GIVEN a user with 25 notifications, 5 of them unread
  • WHEN they open the notifications page and choose "Mark all read"
  • THEN none of their notifications is unread
  • AND the bell shows no unread count

Requirement: Notifications Are Private To Their Recipient

The system SHALL show and change a user's notifications only for that user, identified from their session. A request naming another user's notification SHALL be refused as not found. A notification SHALL only name a lead of the recipient's own company.

Scenario: Another user's notification

  • GIVEN notification N belongs to user A
  • WHEN user B asks to mark N read
  • THEN the request is refused as not found
  • AND N stays unread for user A

Scenario: Two companies

  • GIVEN an INS salesperson and a CV salesperson
  • WHEN a CV lead is assigned to the CV salesperson
  • THEN only the CV salesperson is notified

Requirement: Notifications Follow The Reader's Language

A notification SHALL be stored as message codes with parameters and shown in the reader's current portal language. Its parameters SHALL NOT include phone numbers or email addresses.

Scenario: Chinese reader

  • GIVEN a "lead assigned" notification
  • WHEN a user with the portal in Chinese opens the bell
  • THEN the notification text is in Chinese, with the lead's name

Requirement: Lead Assigned Notification

When an event lead's salesperson is set or changed to a user, the system SHALL notify that user, linking to the lead. It SHALL NOT notify a user who assigned the lead to themselves, and SHALL NOT notify anyone when the salesperson is cleared.

Scenario: Manager assigns a lead

  • WHEN a manager assigns event lead L to salesperson S
  • THEN S gets one "lead assigned" notification naming L and its event

Scenario: Self-assignment

  • WHEN salesperson S assigns lead L to themselves
  • THEN no notification is created

Requirement: Landing Page Sign-up Notification

When a landing-page sign-up creates or updates an event lead, the system SHALL notify the lead's salesperson if it has one, otherwise every member of the event's sales team, once each. With no salesperson and no sales team, nobody SHALL be notified.

Scenario: Unassigned sign-up

  • GIVEN event E has sales team members S1 and S2
  • WHEN a visitor signs up on a page whose form belongs to E, and no salesperson is assigned
  • THEN S1 and S2 each get one "new sign-up" notification

Scenario: Assigned at capture

  • WHEN a web sign-up is captured already assigned to S
  • THEN S gets exactly one notification, the "new sign-up" one

Requirement: WhatsApp Message Notification

When an inbound WhatsApp message is recorded on a chat with an owner, the system SHALL notify the owner, linking to the chat. While the owner has an unread notification for that chat, a further message SHALL update it rather than add another. A chat without an owner SHALL notify nobody.

Scenario: Busy chat

  • GIVEN salesperson S owns a chat
  • WHEN the customer sends 4 messages before S opens the bell
  • THEN S has one unread notification for that chat, timed at the last message

Scenario: Unowned chat

  • WHEN a message arrives on a chat without an owner
  • THEN no notification is created

Requirement: Follow-ups Due Notification

Every day at 08:00 Malaysia time, the system SHALL send each salesperson with open event leads whose next follow-up date is today or earlier one summary notification giving the count due today and the count overdue, linking to their event leads.

Scenario: Morning summary

  • GIVEN salesperson S has 2 open leads due today and 1 open lead due yesterday
  • WHEN the daily run happens
  • THEN S gets one notification saying 2 due today and 1 overdue

Scenario: Nothing due

  • GIVEN salesperson S has no open lead due today or earlier
  • WHEN the daily run happens
  • THEN S gets no notification

Requirement: Notifications Never Block The Action

A failure to create a notification SHALL NOT fail or roll back the sign-up, assignment or inbound message that caused it. The failure SHALL be logged without names, phone numbers or email addresses.

Scenario: Notification store down

  • GIVEN the notification store cannot be reached
  • WHEN a visitor signs up on a landing page
  • THEN the sign-up succeeds and the lead is saved