Skip to content

Visual Kanban Workflow (KBN)

Module Purpose: Provide a visual, interactive workspace where users can manage emails as "cards" in "buckets" (columns), replacing the invisible automation of the previous MVP.

[!IMPORTANT] Implementation Strategy: We will use Plane.so as the open-source Kanban foundation. Plane provides a Linear-quality UI with full API access for custom integrations. The use cases below define the business logic and workflowsโ€”Plane handles UI rendering, while our backend handles AI classification and CRM/ERP sync.

[!TIP] Deployment: Self-hosted Docker Compose on internal infrastructure. See Prerequisites for setup details.


Use Case Quick Reference

ID Title Priority
KBN-001 View Email Board P1
KBN-002 Manage Columns & Rules P1
KBN-003 Drag-and-Drop Classification P1
KBN-004 Quick Card Actions P2
KBN-005 Automated Work Shifting P2
KBN-006 communication Re-tagging P1

UC-KBN-001: View Email Board

What It Does

Renders the real-time Kanban board where enquiry emails appear as cards. It allows sales teams to visualize their workload, filter by hierarchy (team view vs personal view), and identify urgent actions via visual indicators.

Who: Sales Rep, Manager, Email Delegator
When: Daily start-of-day and continuous monitoring
Why: Emails buried in Outlook folders get missed. A board visualizes the backlog and flow.


How It Works

Board Initialization

  1. User logs in and navigates to /kanban
  2. System loads cards based on user's role:
  3. Sales Rep: Shows only leads assigned to them
  4. Manager: Shows leads assigned to their hierarchy + unassigned leads
  5. Admin: Shows global view
  6. Default Filter: "My Inbox" (Active leads, last 30 days)

Card Rendering (The "Face" of the Email)

Each card displays minimal but critical info: - Header: Email Subject (truncated) - Badges: High Priority (red), Sample Requested (blue) - Meta: Sender Name, Company Name (from Prelead match) - Aging: "2 days ago" (Color coded: Red if > 48h) - Visuals: Abstract thumbnail if PDF/Image attached

Real-Time Sync

  • WebSocket Connection: The board subscribes to mailbox.{user_id} channel
  • New Email: When EML-001 detects a new email, a card "flies in" to the first column
  • Status Change: If another user moves a card, it updates instantly on all screens

Edge Cases

What if a user has 5000+ emails?
System implements Infinite Scroll per column. Loads first 20 cards. As user scrolls down, fetches next 20. "Load More" button appears at bottom.

What if WebSocket disconnects?
Banner appears: "Connection lost. Trying to reconnect..." Board freezes to prevent stale state edits.

What if an email belongs to multiple potential columns?
Business Rule: Single Status Truth. An email can only be in ONE column at a time defined by email_status field.


Success Signals

  • Board renders in < 1.5 seconds
  • New emails appear instantly without page refresh
  • Manager can switch view to see subordinate's board
  • "High Priority" cards visually distinct (red border/badge)
  • Scroll position maintained when clicking into a card and returning

Developer Notes

Tech Stack (Plane.so Integration):

  • Frontend: Plane.so self-hosted (React + Next.js)
  • Backend: Custom API bridge for email ingestion โ†’ Plane Issue creation
  • Sync: Plane Webhooks โ†’ Pebble Orchestrator for CRM/ERP sync

Integration Points:

Plane API Pebble Action
POST /issues Create card from classified email
PATCH /issues/{id} Update card metadata (intent, priority)
Webhook: issue.updated Trigger CRM sync on column change
Custom Labels Map to stream, intent_tags, entity_id

UC-KBN-002: Manage Kanban Columns

What It Does

Allows administrators to create, rename, reorder, and configure operational status columns on the Kanban board, including setting up automated rules that move cards based on email content patterns.

Who: Admin, Board Owner
When: During board setup OR ongoing maintenance
Why: Different teams have different workflows - customizable columns ensure the board matches real operational statuses


How It Works

Creating a New Column

  1. Admin clicks "+ Add Column" button in board header
  2. System shows inline editor with fields:
  3. Column Name (e.g., "Waiting for Lab Results")
  4. Color tag (pick from palette: red, blue, green, yellow, purple)
  5. Position (drag handle to place between existing columns)
  6. Admin saves โ†’ Column appears immediately in all users' boards
  7. Empty column shows message: "Drag cards here when waiting for lab results"

Auto-Move Rules (Optional)

Admin can set up intelligent automation:

Example Rule: "Auto-move to 'Waiting for Samples'" - Trigger: Email subject OR body contains "sample" - Action: Move card to this column automatically - Notification: Send alert to Lab Manager

System Behavior: - Scans incoming email content using keyword matching - If match found: Card auto-moves + notification fires - User sees: "๐Ÿค– Auto-moved by rule: 'sample' keyword detected"

Reordering Columns

  • Admin enables "Edit Mode" (๐ŸŽจ button in header)
  • Drag column headers left/right to reorder
  • Changes save instantly, affect all users
  • Common order: Pending โ†’ Query โ†’ Docs โ†’ Samples โ†’ Quote โ†’ Drop

Edge Cases

What if user drags column during active drag?
System blocks: "Cannot reorder columns while cards are being moved. Try again."

What if auto-rule creates infinite loop?
Example: Rule 1 moves to Column A if "urgent", Rule 2 moves to Column B if in Column A
System detects: Max 2 auto-moves per card per day, then flags for manual review


Success Signals

โœ… New column appears across all user boards within 2 seconds
โœ… Auto-rules trigger correctly on keyword match
โœ… Column reordering persists after browser refresh
โœ… Color changes apply to all cards in that column


Developer Notes

Backend: - Store column config in kanban_columns table with board_id, position, color, auto_rules JSON - Auto-rule engine: Run regex on email subject + body

Related UCs: - KBN-001 โ€“ Where columns render - KBN-006 โ€“ Content detection that feeds auto-rules


UC-KBN-003: Drag-and-Drop Classification

What It Does

Enables users to update email enquiry status by simply dragging cards between columns. The drop action acts as a "Trigger" that fires off stage-specific workflow activities (e.g., asking the HOD for technical advice, generating a quote draft, or triggering an approval flow).

Who: Sales Rep, Manager
When: Triage / Daily Workflow
Why: Replaces complex dropdown menus and status forms with a single intuitive gesture.


How It Works

The Move Action

  1. User grabs a card from "Enquiry Pending"
  2. System highlights valid drop zones (some columns might be restricted)
  3. User drops card into "Pending Technical Query"

System Reaction (The Trigger)

  1. Frontend: Card snaps to new column instantly (optimistic UI update)
  2. Backend:
  3. Updates email_status = "Pending Technical Query"
  4. Logs: User X moved Card Y from A to B
  5. Workflow Execution:
  6. Detects New Column = "Pending Technical Query"
  7. Action: Creates an "Internal Activity" assigned to Technical HOD
  8. Email/Notification: Sends ping to HOD: "Review required for [Company Name]"

Drop Column Special Logic

If dropped in "Drop / Lost" column: - Block: Modal popup appears - Ask: "Reason for Loss?" (Price, Specs, Stock, Dup) - Action: Routes to Manager for approval before final closure


Edge Cases

What if I drag to "Quote" but product details are missing?
System opens the Quotation Create screen (QTN-001) pre-filled, but validation errors prevent saving until fixed. "You can't leave this in Quote column without a drafted quote."

What if I don't have permission?
(e.g., Sales Rep trying to move to "Finance Verification")
Card snaps back to original column. Toast Error: "Unauthorized transition."


Success Signals

โœ… Drag action feels smooth (60fps), no lag
โœ… HOD receives notification within 5 seconds of drop
โœ… "Lost" reason modal forces user input
โœ… Database status matches visual column position exactly


Developer Notes

State Management: Use optimistic updates. Update UI first, then API. If API fails, roll back UI and show error. Audit Trail: Every move must be logged in activity_log for SLA tracking.

Related UCs: - QTN-001 โ€“ Triggered by move to Quote column - WFL-002 โ€“ Approval workflow for Drop


UC-KBN-004: Quick Card Actions

What It Does

Provides one-click actions directly on the card face or context menu (right-click) to perform high-frequency tasks like Preview, Archive, or Convert to Lead without opening the detailed view.

Who: Sales Rep, Manager
When: Rapid Triage / Board Scanning
Why: Speed. Clicking into every email to archive it is too slow for 100+ emails/day.


How It Works

Action Menu

Trigger: Right-click card OR click the โ‹ฎ menu icon.

Options: 1. Preview: Opens quick-view modal (read-only email body) 2. Archive: Removes from board (Soft delete / Hide) 3. Create Lead: Converts raw email intent to CRM Lead 4. Dialer Sync: Checks phone number, schedules call task 5. Recall: (Only if shifted) Reclaim ownership

Preview Modal

  • Shows email body (sanitized HTML)
  • "Reply" button (opens Outlook/Composer)
  • "Close" (Esc key)

Create Lead Logic

  • Scrapes: From Name, Domain, Subject
  • Pre-fills: First Name, Company, Requirement
  • API Call: POST to CRM lead endpoint
  • Success: Card icon changes to ๐Ÿ‘ค (Lead)

Edge Cases

What if email is already a lead?
"Create Lead" option is disabled/hidden.

What if Preview fails?
Fallback to "Open in Outlook" link.

Dialer Sync outside hours?
Schedules task for next business day 10 AM.


Success Signals

โœ… Context menu opens instantly
โœ… Archive action has "Undo" toast (5s duration)
โœ… Create Lead pre-fills 80%+ of available data fields


UC-KBN-005: Automated Work Shifting (11:30 AM)

What It Does

Ensures business continuity by automatically detecting absent employees at 11:30 AM and shifting their high-priority "Due Today" cards to a backup owner or HOD.

Who: System Background Job (Cron)
When: Daily at 11:30 AM (configurable)
Why: Sales enquiries rot quickly. If a rep is sick, the customer shouldn't wait 24h.


How It Works

Detection Phase

  1. Time Check: Clock strikes 11:30 AM
  2. Login Check: System queries user_session table
  3. "Has User X logged in today?"
  4. No: User X is marked "Absent / Late"

Shifting Phase

  1. Query Workload: Find cards owned by User X where:
  2. Status != Closed
  3. Priority = High OR Last_Interaction > 24h
  4. Identify Target: Look up User X's backup_owner_id (e.g., Bob)
  5. If Bob is also absent -> Escalate to manager_id
  6. Execution:
  7. Update assigned_user_id = Bob
  8. Add Tag: SHIFTED_FROM_JANE
  9. Send Email to Bob: "Jane is away. 5 High Priority leads moved to you."

Recall Phase (The "I'm Here!" Moment)

  1. If Jane logs in at 12:00 PM:
  2. System detects late login
  3. Popup: "Values were shifted to Bob. Recall?"
  4. Action: Jane clicks "Recall All" -> Cards move back.

Edge Cases

What if everyone is absent? (e.g., Holiday)
System checks Holiday_Master. If today is holiday, Job skips.

What if Bob is overwhelmed?
(Future) Load balancing check: If Bob has > 50 cards, shift to Round Robin pool instead.

Partial Recall?
Jane sees list of shifted items. Can select specific ones to recall, leave others with Bob.


Success Signals

โœ… Job runs reliably at 11:30 AM
โœ… Only High Priority items move (Low priority waits)
โœ… Hierarchy fallbacks work (Backup -> HOD -> Admin)
โœ… Recall function restores original ownership cleanly


Developer Notes

Scheduler: Use BullMQ / Quartz / Cron. Audit: Log every shift event (AUTO_SHIFT, MANUAL_RECALL) in activity timeline. Performance: Batch updates. Don't fire 50 separate DB calls for 50 cards.


UC-KBN-006: Communication Re-tagging & Threads

What It Does

Analyzes incoming emails (replies/forwards) to automatically tag cards (e.g., "Sample Requested", "Negotiation") and groups them into a single chronological thread, ensuring context isn't lost.

Who: AI Engine / NLP Service
When: On Email Ingest
Why: A single enquiry might have 50 email exchanges. They should be 1 card, not 50.


How It Works

Threading Logic

  1. Header Analysis: Check In-Reply-To and References headers.
  2. Subject Analysis: Remove "Re:", "Fwd:", match simplified subject string.
  3. Match: If match found -> Attach outgoing email to Existing Card. DO NOT create new card.
  4. Bump card to top of column (Sort by Last Updated)

Semantic Re-tagging

  1. Scan Content: AI scans body text for intent keywords.
  2. "Please send sample" -> Tag: Sample Req
  3. "Too expensive" -> Tag: Negotiation
  4. "PFA Purchase Order" -> Tag: PO Received -> Auto-move to "Order" column
  5. Update UI: Add colored badge to card face.

Thread UI

  • Card shows "๐Ÿ’ฌ 5" indicator.
  • Clicking opens Timeline View (Chat style interface) showing all emails in order.

Edge Cases

False Positive Threading
Customer sends new enquiry with same subject "Enquiry".
Logic: Check timestamp. If > 30 days gap, treat as new enquiry (New Card).

Conflicting Tags
Email 1: "Send sample". Email 2: "Cancel sample".
Logic: Newest intent wins or adds "Conflict" flag for human review.


Success Signals

โœ… Threaded replies attach to parent card 99% of time
โœ… Keywords trigger correct tags (Sample, PO, Quote)
โœ… Visual Thread view renders HTML emails correctly


โ† Back to Use Cases