CRM Workflow (WFL)¶
Module Purpose: Implement the deterministic state machine that manages the lead lifecycle from ingestion (Email/Campaign) through to Enquiry conversion, ensuring data hygiene and automated validation.
[!TIP] Core Concept: Every lead follows a "Happy Path" or a "Terminal Path". The system ensures no lead skips the Validation Gate (CIN/PAN/GST check).
Use Case Quick Reference¶
| ID | Title | Priority |
|---|---|---|
| US-WFL-010 | Lead-to-Enquiry State Machine | P0 |
| US-WFL-011 | Automated Validation Gate | P0 |
| US-WFL-012 | Response Playbook Automation | P1 |
| US-WFL-013 | Terminal State Triage (Barred/Fake) | P1 |
| US-WFL-014 | Enquiry Pipeline Sub-statuses | P1 |
US-WFL-010: Lead-to-Enquiry State Machine¶
What It Does¶
Implements the core logic that moves a lead through discrete stages: New → Attempting Contact → Contacted → Qualified → Enquiry.
Who: Sales Rep, System System
When: Lead lifecycle progression
Functional Requirements¶
- State Persistence: Track the current state of every lead record in the PostgreSQL core.
- Transition Logic:
New→Validation(Automatic upon creation)Validation→Contacted(Triggered by manual logging of Call/Email)Contacted→Qualified(Requires valid CIN/PAN and manual flag)Qualified→Enquiry(Converts to Sales Pipeline)
- Draft Context: Surface the "Next Step" for the sales rep based on the current state.
US-WFL-011: Automated Validation Gate¶
What It Does¶
Automatically verifies the corporate identity of a lead using MCA and GST APIs before allowing the lead to be marked as "Qualified."
Who: System Service
When: During the Validation state
Functional Requirements¶
- API Integration: Call third-party GST/MCA verification services using the provided CIN/PAN.
- Hard Gate: If the API returns "Invalid" or "Inactive," the
Qualifiedbutton is disabled. - Status Banner: Show a "Verified" badge on the Company Master header once validation passes.
US-WFL-012: Response Playbook Automation¶
What It Does¶
Suggests specific response actions to Sales Reps based on customer interaction patterns (e.g., "Price too high," "No response post-sample").
Who: AI Assistant, Sales Rep
Functional Requirements¶
- Trigger Recognition: Staff tags an interaction with a scenario (e.g., "Price Pushback").
- Playbook Display:
- Price Pushback: Show last 5 successful quotes for this product.
- No Response: Schedule follow-up email in 48 hours.
- COA Sent: Link the specific COA version to the next transaction.
US-WFL-013: Terminal State Triage (Barred/Fake)¶
What It Does¶
Allows users to exit the workflow for invalid leads while capturing the reason for training future AI classification models.
Functional Requirements¶
- States:
Junk,Fake,Barred,Drop. - Audit Note: Force a "Reason for Exit" comment before marking as terminal.
- AI Feedback: Feed terminal records back into the fine-tuning dataset for
US-EML-002.
US-WFL-014: Enquiry Pipeline Sub-statuses¶
What It Does¶
Provides granular tracking for enquiries that have reached the Sales Pipeline but are waiting on technical or administrative dependencies.
Functional Requirements¶
- Sub-statuses:
Pending for SpecificationPending for supplier rate / RFQMake QuoteLong Pendancy(> 7 days)
- SLA Tracking: Clock starts when the sub-status is set; alerts trigger if
Long Pendancyis reached.
US-WFL-015: Executive Dashboard¶
What It Does¶
Provides high-level visibility for senior management to track the health of the entire pipeline across enquiries, quotes, and tender progress.
Functional Requirements¶
- Real-time Metrics:
- Enquiries: Count of new leads ingested this month.
- Quotes Sent: Count of leads that transitioned to "Quote Sent" stage.
- Tenders WIP: Count of active cards in the "Tender" pipeline.
- Net Gain: Count of leads converted to "Customer" status in the current month.
- Alerts:
- Unattended Leads: Highlight leads with
Last_Activity > N days(configurable by Team Lead).
- Unattended Leads: Highlight leads with
- Automated Closing (Extinguish Logic):
- If a customer sends an email with
intent == "Drop"(e.g., "Not interested", "Price too high"), the system auto-moves the Kanban card toClosed/Lostand updates the CRM Lead status toExtinguished.
- If a customer sends an email with