Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
42 lines
2.5 KiB
Markdown
42 lines
2.5 KiB
Markdown
# Proposal
|
|
|
|
## Why
|
|
|
|
Sales staff learn about new work only by refreshing lists. A lead assigned to them, a sign-up from a landing page, a customer's WhatsApp reply and a follow-up falling due all go unnoticed until someone looks. This is feature-list item 12, needed before go-live on 2027-01-15. On 2026-12-02 the owner chose an in-app bell only and approved the design: `docs/superpowers/specs/2026-12-02-lead-notifications-design.md`.
|
|
|
|
## What Changes
|
|
|
|
- **Bell in the portal header** for every signed-in staff user:
|
|
- an unread badge, refreshed every 30 seconds while the tab is visible;
|
|
- a drop-down of recent notifications, each linking to its lead or chat;
|
|
- a full notifications page;
|
|
- read state kept on the server.
|
|
- **Four triggers:**
|
|
- a lead assigned to someone notifies that salesperson;
|
|
- a landing-page sign-up notifies the assigned salesperson, else the event's sales team;
|
|
- an inbound WhatsApp message notifies the chat owner, at most one unread notification per chat;
|
|
- a daily 08:00 (Malaysia) summary of follow-ups due or overdue, per salesperson.
|
|
- **Text follows the reader's language**: notifications store message codes and parameters, not text.
|
|
- **Best effort:** a notification that cannot be written never fails the sign-up, assignment or message behind it.
|
|
|
|
## Capabilities
|
|
|
|
### New Capabilities
|
|
|
|
- `lead-notifications`: the staff bell, its read state, and the four triggers with their recipients.
|
|
|
|
### Modified Capabilities
|
|
|
|
None. The triggers add a side effect to lead capture, lead assignment and WhatsApp intake without changing their specified behaviour.
|
|
|
|
## Impact
|
|
|
|
- **services-system:** the unused `notification` table gains `recipient_type`, `company_id`, `title`, `type`, `link`, `collapse_key`, `seen`, `read_at` and an index, and moves to `utf8mb4`. New endpoints: create, list mine, unread count, mark read, mark all read.
|
|
- **SQL:** `sql/01-notification-columns.sql` (DDL), `sql/02-notification-labels.sql` (labels), `sql/99-rollback.sql`. Mirror 01 into `local/seed/`.
|
|
- **services-counter:** a notifier called after commit on assignment and on web sign-up; a daily follow-up job.
|
|
- **services-whatsapp:** a notifier called after an inbound message is recorded.
|
|
- **mobile-api:** `/api/admin/notifications` (list, unread count, read, read all), always for the signed-in user.
|
|
- **Portal:** `NotificationsBell` in the header, `/notifications` page, BFF routes, labels with Chinese. Ported from babyboo.
|
|
- **Gateway:** unchanged; `/api/admin/**` is already routed.
|
|
- **Dependencies:** none.
|