add LLM-based enterprise lead scoring and auto-replies
Extract delivery logic from the enterprise route into a dedicated module that grades inquiries via the Zen responses API, falls back to simple regex scoring on failure, and sends templated auto-replies for generic and procurement-blocked leads. Made-with: Cursor
This commit is contained in:
parent
a6f23cb08e
commit
bc3fe8f4f5
5 changed files with 380 additions and 52 deletions
53
packages/console/app/test/enterprise.test.ts
Normal file
53
packages/console/app/test/enterprise.test.ts
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
import { describe, expect, test } from "bun:test"
|
||||
import { fallback, kind, reply, type Score } from "../src/lib/enterprise"
|
||||
|
||||
describe("enterprise lead routing", () => {
|
||||
test("routes procurement blockers to procurement reply", () => {
|
||||
const score = fallback({
|
||||
name: "Jane Doe",
|
||||
role: "CTO",
|
||||
company: "Acme",
|
||||
email: "jane@acme.com",
|
||||
message: "We're stuck in procurement, security review, and vendor approval through Coupa.",
|
||||
})
|
||||
|
||||
expect(score.procurement).toBe(true)
|
||||
expect(kind(score)).toBe("procurement")
|
||||
})
|
||||
|
||||
test("routes vague inquiries to the generic reply", () => {
|
||||
const score = fallback({
|
||||
name: "Jane Doe",
|
||||
role: "Engineer",
|
||||
email: "jane@example.com",
|
||||
message: "Can you tell me more about enterprise pricing?",
|
||||
})
|
||||
|
||||
expect(score.effort).toBe("low")
|
||||
expect(kind(score)).toBe("generic")
|
||||
})
|
||||
|
||||
test("keeps high intent leads for manual follow-up", () => {
|
||||
const score: Score = {
|
||||
company: "Acme",
|
||||
size: "1001+",
|
||||
first: "Jane",
|
||||
title: "CTO",
|
||||
seats: 500,
|
||||
procurement: false,
|
||||
effort: "high",
|
||||
summary: "Large rollout with clear buying intent.",
|
||||
}
|
||||
|
||||
expect(kind(score)).toBeNull()
|
||||
})
|
||||
|
||||
test("renders the procurement reply with security notes", () => {
|
||||
const mail = reply("procurement", "Jane")
|
||||
|
||||
expect(mail.subject).toContain("security")
|
||||
expect(mail.text).toContain("SOC 1 compliant")
|
||||
expect(mail.text).toContain("MIT licensed")
|
||||
expect(mail.html).toContain("Stefan")
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue