// BotCompany — prospect dataset + language pools. // SIM mode: generates realistic Maharashtra SMB prospects. // (Later a real scraper can feed the same Lead shape — see /api/scraper/run.) import type { Intent, Persona } from "./types"; // ---------- deterministic RNG ---------- export function mulberry32(seed: number) { let a = seed >>> 0; return () => { a |= 0; a = (a + 0x6d2b79f5) | 0; let t = Math.imul(a ^ (a >>> 15), 1 | a); t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t; return ((t ^ (t >>> 14)) >>> 0) / 4294967296; }; } export function hashSeed(s: string): number { let h = 2166136261; for (let i = 0; i < s.length; i++) { h ^= s.charCodeAt(i); h = Math.imul(h, 16777619); } return h >>> 0; } export function pick(rng: () => number, arr: readonly T[]): T { return arr[Math.floor(rng() * arr.length) % arr.length]; } export function pickMany(rng: () => number, arr: readonly T[], n: number): T[] { const copy = [...arr]; const out: T[] = []; while (out.length < n && copy.length) { out.push(copy.splice(Math.floor(rng() * copy.length), 1)[0]); } return out; } // ---------- pools ---------- export const CITIES = [ "Sangamner", "Nashik", "Pune", "Mumbai", "Nagpur", "Thane", "Aurangabad", "Ahmednagar", "Kolhapur", "Shirdi", ] as const; export const NICHES = [ "Gym", "Ice Cream Parlour", "Car Showroom", "Civil Contractor", "Dental Clinic", "Cafe", "Salon", "Real Estate Agency", "Electronics Store", "Travel Agency", "Bakery", "Interior Design Studio", ] as const; export const OWNERS = [ "Rahul", "Priya", "Amit", "Sneha", "Vikas", "Pooja", "Suresh", "Meena", "Rohit", "Kavita", "Anil", "Deepa", "Ganesh", "Shalini", "Nikhil", "Rupali", "Sameer", "Vaishali", ] as const; export const SURNAMES = [ "Patil", "Sharma", "Deshmukh", "Kulkarni", "Joshi", "Pawar", "Jadhav", "More", "Shaikh", "Thakur", "Chavan", "Bhosale", "Rane", "Naik", ] as const; export const PREFIXES = ["Shree", "New", "Royal", "Balaji", "Star", "Metro", "Om", "Sai"] as const; export const SOURCES = [ "IndiaMART", "JustDial", "YellowPages India", "Google Maps", ] as const; export const PERSONAS: Persona[] = ["HOT", "WARM", "COLD", "GRUMPY"] as const; export function genBusinessName(rng: () => number, niche: string, city: string): string { const style = rng(); if (style < 0.35) return `${pick(rng, PREFIXES)} ${niche}`; if (style < 0.6) return `${city} ${niche} Co.`; if (style < 0.8) return `${pick(rng, SURNAMES)} ${niche}`; return `${pick(rng, PREFIXES)} ${city} ${niche}`; } export function genPhone(rng: () => number): string { let p = "9"; for (let i = 0; i < 9; i++) p += String(Math.floor(rng() * 10)); return `+91 ${p.slice(0, 5)} ${p.slice(5)}`; } export function genPersona(rng: () => number): Persona { const r = rng(); if (r < 0.3) return "HOT"; if (r < 0.6) return "WARM"; if (r < 0.82) return "COLD"; return "GRUMPY"; } // ---------- openers (bot → lead) ---------- export const OPENERS: ((b: { owner: string; business: string; niche: string; city: string }) => string)[] = [ (b) => `Namaste ${b.owner} ji 🙏 I build fast, modern websites for businesses like ${b.business} (${b.niche}, ${b.city}). Already shipped 4 live client sites — can I send you samples?`, (b) => `Hi ${b.owner}! Saw ${b.business} on ${"the directory"} — no website yet? I build 3D-styled sites that load in under 2s. Want to see 4 live examples?`, (b) => `${b.owner} ji, customers search "${b.niche} in ${b.city}" every day. A clean site wins them. I do full build + WhatsApp button for a flat fee. Samples?`, ]; // ---------- lead reply pools per persona ---------- type ReplyPools = Record>>; export const LEAD_REPLIES: ReplyPools = { HOT: { INTEREST: [ "Yes send samples please 🙌", "Interesting! Show me what you built.", "Sounds good, share your work.", ], YES: [ "Ok I am in, what do you need from me?", "Let us do it 🔥", "Yes, how do we start?", ], PRICE: ["Ok that is fair, send the proposal.", "Fine, how do I pay?"], TIME: ["Good, that works for me.", "Perfect, I need it before Diwali."], NEUTRAL: ["Tell me more.", "What else is included?"], }, WARM: { PRICE: [ "How much does it cost?", "What is your charge for a full site?", "Price? Please be direct.", ], TIME: ["How long will it take?", "Timeline? I am busy this month."], INTEREST: ["Show me 2-3 examples.", "Ok send samples, I will check."], NEUTRAL: ["Hmm, maybe. What exactly do I get?"], YES: ["Alright, let us try it.", "Ok proceed."], }, COLD: { NEUTRAL: ["Who is this?", "Not interested right now.", "I already have a website."], PRICE: ["Cost? Just asking.", "If it is cheap maybe."], TIME: ["Maybe later.", "No time for this."], NO: ["Not now, thanks.", "Nope."], }, GRUMPY: { NEUTRAL: ["Why are you messaging me?", "Where did you get my number?"], NO: ["Not interested. Stop.", "No.", "We are full, do not need."], PRICE: ["How much?? If more than 2000 forget it.", "Price batao fast."], STOP: ["STOP messaging me.", "Remove my number."], }, }; /** Intent bias per persona (weighted cycle used by the simulator). */ export const PERSONA_INTENT_BIAS: Record = { HOT: ["INTEREST", "YES", "PRICE", "INTEREST", "TIME", "YES"], WARM: ["PRICE", "TIME", "INTEREST", "NEUTRAL", "PRICE", "YES"], COLD: ["NEUTRAL", "NEUTRAL", "PRICE", "TIME", "NO", "NEUTRAL"], GRUMPY: ["NEUTRAL", "NO", "PRICE", "NEUTRAL", "NO", "STOP"], }; export function leadReplyFor(persona: Persona, intent: Intent, rng: () => number): string { const pool = LEAD_REPLIES[persona][intent]; if (pool && pool.length) return pick(rng, pool); // generic fallback keeps the thread alive const generic: Record = { YES: "Ok yes.", NO: "No thanks.", STOP: "Stop messaging me.", PRICE: "What is the price?", TIME: "How much time?", INTEREST: "Show me your work.", NEUTRAL: "Ok.", }; return generic[intent]; } // ---------- misc flavor ---------- export const SCRAPE_NOTES = [ "listed without website field", "directory contact verified", "public listing, website missing", "google maps entry, no site link", ] as const;