The Leads & CRM module is the commercial backbone of B2B Import ERP. It centralizes every inbound prospect — whether they arrived through the public Wizard, a manual entry by a sales rep, or a marketing campaign — into a single pipeline where automated scoring, stage tracking, and activity logging drive the conversion process from first contact to closed deal.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ency07/B2B-import/llms.txt
Use this file to discover all available pages before exploring further.
Lead Sources
Wizard Form
Visitors who complete the public pre-engineering calculator at
/wizard are automatically registered as scored leads the moment they submit the form.Manual Entry
Sales representatives can create leads directly from the dashboard at
/dashboard/leads, associating them with an existing client and contact record.Marketing Campaigns
Leads generated from external campaigns (email, WhatsApp broadcasts, landing page contact forms) are captured via
submitContactForm() and scored on arrival.Lead Scoring Algorithm
Every lead is scored automatically bycalculateLeadScore() in src/app/actions/leads.ts. The algorithm accumulates points from three independent factors, then applies SPAM detection, and finally maps the total to a risk level.
Scoring Factors
Professional Role
+40 pts — Director de Planta, Gerente de Mantenimiento, Supervisor de HVAC / Operaciones+25 pts — Ingeniero de Proyectos, Compras / Abastecimiento+10 pts — Any other role
Urgency
+40 pts —
alta (emergency, same-day SLA)+20 pts — media (priority project)+5 pts — baja (planning stage)Email Domain
−20 pts — Public domains:
gmail.com, yahoo.com, outlook.com, hotmail.com, live.com, icloud.comSPAM — Disposable domains: yopmail.com, mailinator.com, tempmail.comSPAM with a score of 0 regardless of role or urgency.
Score Thresholds
| Score Range | Risk Level |
|---|---|
| Disposable / invalid email | SPAM |
| 70 – 100 | CALIENTE |
| 40 – 69 | TIBIO |
| 0 – 39 | FRIO |
Risk Levels
Risk levels are intentionally stored in Spanish (
CALIENTE, TIBIO, FRIO, SPAM) to match the target market. The database constraint in 20260617000035_industrial_cms.sql enforces these exact string values and rejects any English equivalents.🔥 CALIENTE
High-priority prospect. Score ≥ 70. Corporate email, senior role, and high urgency. Assign immediately; expected short sales cycle.
🌡️ TIBIO
Moderate engagement. Score 40–69. Needs nurturing — schedule a follow-up call and add to an email sequence.
❄️ FRIO
Low engagement or low-value indicators. Score < 40. Keep in pipeline but deprioritize; may still convert over a longer cycle.
🚫 SPAM
Disposable email detected, or address is malformed. Score forced to 0. Filtered out of the active pipeline automatically.
TypeScript Interface
Server Actions
Both actions are defined insrc/app/actions/leads.ts and run exclusively on the server under the Supabase Service Role.
calculateLeadScore
Computes the score and risk level for a given email, role, and urgency string. Pure function with no database side effects — safe to call for previews or dry-runs.
createLeadWithScore
Calls calculateLeadScore internally, then inserts a new row into the leads table with status: "NUEVO", lead_source: "WEBSITE", and the computed score and risk_level. Returns the full persisted lead record.
CRM Pipeline Stages
Leads move through the following ordered stages. Stage transitions are logged incrm_activity_logs with an immutable trigger that blocks physical deletion — all audit records are preserved indefinitely.
| Stage | Description |
|---|---|
| Nuevo | Lead just created; awaiting first contact |
| En Contacto | First outreach made; conversation open |
| Calificado | Budget, authority, need, and timeline confirmed |
| Propuesta | Formal quote or technical proposal delivered |
| Negociación | Terms, pricing, or scope being negotiated |
| Ganado | Deal closed; converts to a work order or invoice |
| Perdido | Opportunity closed without a sale; reason logged |