@xapp/stentor-service-generative-ai 1.90.8 → 1.91.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/GenerativeAIService.js +1 -1
- package/lib/GenerativeAIService.js.map +1 -1
- package/lib/models/LeadAnalysis.d.ts +188 -6
- package/lib/models/LeadAnalysis.js +229 -0
- package/lib/models/LeadAnalysis.js.map +1 -1
- package/lib/prompts/AnalyzeEmail.d.ts +1 -1
- package/lib/prompts/AnalyzeEmail.js +20 -119
- package/lib/prompts/AnalyzeEmail.js.map +1 -1
- package/lib/prompts/AnalyzeLead.d.ts +8 -0
- package/lib/prompts/AnalyzeLead.js +29 -119
- package/lib/prompts/AnalyzeLead.js.map +1 -1
- package/lib/prompts/leadTaxonomyPrompt.d.ts +14 -0
- package/lib/prompts/leadTaxonomyPrompt.js +46 -0
- package/lib/prompts/leadTaxonomyPrompt.js.map +1 -0
- package/package.json +1 -1
|
@@ -78,7 +78,7 @@ class GenerativeAIService {
|
|
|
78
78
|
if (!(options === null || options === void 0 ? void 0 : options.highValueLeadDescription)) {
|
|
79
79
|
delete analysis.highValueLead;
|
|
80
80
|
}
|
|
81
|
-
analysis.analysisVersion =
|
|
81
|
+
analysis.analysisVersion = AnalyzeLead_1.ANALYZE_LEAD_VERSION;
|
|
82
82
|
return analysis;
|
|
83
83
|
});
|
|
84
84
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenerativeAIService.js","sourceRoot":"","sources":["../src/GenerativeAIService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAgBA,yDAA0I;AAC1I,
|
|
1
|
+
{"version":3,"file":"GenerativeAIService.js","sourceRoot":"","sources":["../src/GenerativeAIService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAgBA,yDAA0I;AAC1I,uDAAiI;AACjI,mEAA+J;AAC/J,uCAAkG;AAElG,4CAAwD;AAExD,6DAA+F;AAE/F;;;;;;;;;;;;GAYG;AAC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
|
20
20
|
* - TEST: Test message, placeholder text, or internal system check
|
|
21
21
|
* - OTHER: Content cannot be reasonably determined
|
|
22
22
|
*/
|
|
23
|
-
export
|
|
23
|
+
export declare const CONTACT_TYPES: readonly ["BILLING_ISSUE", "CANCELLATION", "COMPLAINT", "COMPLIMENT", "CONTACT_REQUEST", "EMPLOYMENT_INQUIRY", "MISSED_APPOINTMENT", "QUESTION", "QUOTE_REQUEST", "RESCHEDULE_REQUEST", "SERVICE_REQUEST", "SPAM", "TEST", "OTHER"];
|
|
24
|
+
export type ContactType = (typeof CONTACT_TYPES)[number];
|
|
24
25
|
/**
|
|
25
26
|
* Describes what kind of work the customer is requesting (high-level categorization).
|
|
26
27
|
*
|
|
@@ -40,16 +41,180 @@ export type ContactType = "BILLING_ISSUE" | "CANCELLATION" | "COMPLAINT" | "COMP
|
|
|
40
41
|
* - TREATMENT: Active service to resolve or prevent an issue (pest control, mold remediation, etc.)
|
|
41
42
|
* - OTHER: Work that doesn't fit the above categories
|
|
42
43
|
*/
|
|
43
|
-
export
|
|
44
|
+
export declare const SERVICE_TYPES: readonly ["CLEANING", "CONSULTATION", "INSPECTION", "INSTALLATION", "MAINTENANCE", "REFINISH", "REMODEL", "REPAIR", "SUPPORT", "TRANSPORT", "TREATMENT", "OTHER"];
|
|
45
|
+
export type ServiceType = (typeof SERVICE_TYPES)[number];
|
|
44
46
|
/**
|
|
45
|
-
*
|
|
47
|
+
* The trades a lead can be classified into, each with the definition the model is given.
|
|
48
|
+
*
|
|
49
|
+
* This is the ONE list: the `JobType` union, the definitions in the AnalyzeLead and AnalyzeEmail
|
|
50
|
+
* prompts, both JSON schemas and the response validation are all derived from it. It used to be
|
|
51
|
+
* written out four times, and a change to one copy silently left the others behind.
|
|
46
52
|
*
|
|
47
53
|
* See LEAD_ANALYSIS_GUIDE.md for detailed definitions and examples.
|
|
48
54
|
*
|
|
49
55
|
* @remarks
|
|
50
|
-
* Some categories have aliases (e.g., electrical/electrician, gutter/gutters)
|
|
56
|
+
* Some categories have aliases (e.g., electrical/electrician, gutter/gutters). They are label values
|
|
57
|
+
* that dashboards, GraphQL filters and customer webhooks already read, so collapsing them is a
|
|
58
|
+
* coordinated change of its own — not something to do in passing.
|
|
59
|
+
*
|
|
60
|
+
* Added in analysis 1.3.0, from production leads the classifier had no value for (2026-09-14):
|
|
61
|
+
* fireplace_chimney, drainage_waterproofing, water_treatment, pool_spa, closets_organization,
|
|
62
|
+
* radon_mitigation, awnings_shade, and the non-home-services tenants dental, eye_care,
|
|
63
|
+
* event_rental and salon.
|
|
51
64
|
*/
|
|
52
|
-
export
|
|
65
|
+
export declare const JOB_TYPE_DEFINITIONS: readonly [{
|
|
66
|
+
readonly value: "appliance_repair";
|
|
67
|
+
readonly definition: "Appliance repair services.";
|
|
68
|
+
}, {
|
|
69
|
+
readonly value: "awnings_shade";
|
|
70
|
+
readonly definition: "Awnings, canopies, shade sails, and outdoor canvas structures.";
|
|
71
|
+
}, {
|
|
72
|
+
readonly value: "blinds";
|
|
73
|
+
readonly definition: "Window blinds and shades installation services.";
|
|
74
|
+
}, {
|
|
75
|
+
readonly value: "carpentry";
|
|
76
|
+
readonly definition: "Carpentry or woodworking services.";
|
|
77
|
+
}, {
|
|
78
|
+
readonly value: "cleaning";
|
|
79
|
+
readonly definition: "General cleaning services (house, carpet, duct, etc.).";
|
|
80
|
+
}, {
|
|
81
|
+
readonly value: "closets_organization";
|
|
82
|
+
readonly definition: "Closet systems and home or garage organization.";
|
|
83
|
+
}, {
|
|
84
|
+
readonly value: "construction";
|
|
85
|
+
readonly definition: "General construction services.";
|
|
86
|
+
}, {
|
|
87
|
+
readonly value: "contractor";
|
|
88
|
+
readonly definition: "General contracting services (same as construction).";
|
|
89
|
+
}, {
|
|
90
|
+
readonly value: "dental";
|
|
91
|
+
readonly definition: "Dental care: cleanings, exams, fillings, crowns, extractions, dentures.";
|
|
92
|
+
}, {
|
|
93
|
+
readonly value: "drainage_waterproofing";
|
|
94
|
+
readonly definition: "Drainage, French drains, sump pumps, and basement or foundation waterproofing.";
|
|
95
|
+
}, {
|
|
96
|
+
readonly value: "drywall";
|
|
97
|
+
readonly definition: "Drywall installation or repair.";
|
|
98
|
+
}, {
|
|
99
|
+
readonly value: "electrical";
|
|
100
|
+
readonly definition: "Electrical work or services, including EV charger installation.";
|
|
101
|
+
}, {
|
|
102
|
+
readonly value: "electrician";
|
|
103
|
+
readonly definition: "Electrical work or services (same as electrical).";
|
|
104
|
+
}, {
|
|
105
|
+
readonly value: "event_rental";
|
|
106
|
+
readonly definition: "Party and event rentals: tents, tables, chairs, linens, equipment.";
|
|
107
|
+
}, {
|
|
108
|
+
readonly value: "eye_care";
|
|
109
|
+
readonly definition: "Eye exams, optometry, contact lenses, and eyewear.";
|
|
110
|
+
}, {
|
|
111
|
+
readonly value: "fencing";
|
|
112
|
+
readonly definition: "Fence installation or repair.";
|
|
113
|
+
}, {
|
|
114
|
+
readonly value: "fireplace_chimney";
|
|
115
|
+
readonly definition: "Fireplaces, gas logs and inserts, chimneys, and wood or pellet stoves.";
|
|
116
|
+
}, {
|
|
117
|
+
readonly value: "flooring";
|
|
118
|
+
readonly definition: "Flooring installation, refinishing, or repair (hardwood, tile, garage floor coatings, etc.).";
|
|
119
|
+
}, {
|
|
120
|
+
readonly value: "gutter";
|
|
121
|
+
readonly definition: "Gutter installation, rerouting, or cleaning.";
|
|
122
|
+
}, {
|
|
123
|
+
readonly value: "gutters";
|
|
124
|
+
readonly definition: "Gutter services (same as gutter).";
|
|
125
|
+
}, {
|
|
126
|
+
readonly value: "handyman";
|
|
127
|
+
readonly definition: "General home repair and maintenance services.";
|
|
128
|
+
}, {
|
|
129
|
+
readonly value: "house_cleaning";
|
|
130
|
+
readonly definition: "House cleaning services (same as cleaning).";
|
|
131
|
+
}, {
|
|
132
|
+
readonly value: "hvac";
|
|
133
|
+
readonly definition: "Heating, ventilation, or air conditioning services, including dryer vent cleaning.";
|
|
134
|
+
}, {
|
|
135
|
+
readonly value: "junk_removal";
|
|
136
|
+
readonly definition: "Junk and debris removal services.";
|
|
137
|
+
}, {
|
|
138
|
+
readonly value: "landscaping";
|
|
139
|
+
readonly definition: "Landscaping or yard services.";
|
|
140
|
+
}, {
|
|
141
|
+
readonly value: "landscaper";
|
|
142
|
+
readonly definition: "Landscaping services (same as landscaping).";
|
|
143
|
+
}, {
|
|
144
|
+
readonly value: "legal_services";
|
|
145
|
+
readonly definition: "Legal services.";
|
|
146
|
+
}, {
|
|
147
|
+
readonly value: "masonry";
|
|
148
|
+
readonly definition: "Masonry, brick, stone, or tuckpointing work.";
|
|
149
|
+
}, {
|
|
150
|
+
readonly value: "mold_remediation";
|
|
151
|
+
readonly definition: "Mold inspection, removal, or remediation services.";
|
|
152
|
+
}, {
|
|
153
|
+
readonly value: "moving";
|
|
154
|
+
readonly definition: "Moving or relocation services.";
|
|
155
|
+
}, {
|
|
156
|
+
readonly value: "painting";
|
|
157
|
+
readonly definition: "Painting services.";
|
|
158
|
+
}, {
|
|
159
|
+
readonly value: "painter";
|
|
160
|
+
readonly definition: "Painting services (same as painting).";
|
|
161
|
+
}, {
|
|
162
|
+
readonly value: "pest_control";
|
|
163
|
+
readonly definition: "Pest control services (insects, termites, rodents).";
|
|
164
|
+
}, {
|
|
165
|
+
readonly value: "plumbing";
|
|
166
|
+
readonly definition: "Plumbing services, including water heaters, fixtures, backflow testing, and septic.";
|
|
167
|
+
}, {
|
|
168
|
+
readonly value: "pool_spa";
|
|
169
|
+
readonly definition: "Pool and spa installation, repair, cleaning, and maintenance.";
|
|
170
|
+
}, {
|
|
171
|
+
readonly value: "pressure_washing";
|
|
172
|
+
readonly definition: "Pressure washing and power washing services.";
|
|
173
|
+
}, {
|
|
174
|
+
readonly value: "radon_mitigation";
|
|
175
|
+
readonly definition: "Radon testing and mitigation systems.";
|
|
176
|
+
}, {
|
|
177
|
+
readonly value: "remodeling";
|
|
178
|
+
readonly definition: "Remodeling or renovation (kitchen, bathroom, home).";
|
|
179
|
+
}, {
|
|
180
|
+
readonly value: "restoration";
|
|
181
|
+
readonly definition: "Water, fire, or damage restoration services.";
|
|
182
|
+
}, {
|
|
183
|
+
readonly value: "roofing";
|
|
184
|
+
readonly definition: "Roofing services.";
|
|
185
|
+
}, {
|
|
186
|
+
readonly value: "roofer";
|
|
187
|
+
readonly definition: "Roofing services (same as roofing).";
|
|
188
|
+
}, {
|
|
189
|
+
readonly value: "salon";
|
|
190
|
+
readonly definition: "Hair, nail, and beauty salon services.";
|
|
191
|
+
}, {
|
|
192
|
+
readonly value: "siding";
|
|
193
|
+
readonly definition: "Siding installation or repair services.";
|
|
194
|
+
}, {
|
|
195
|
+
readonly value: "tree_services";
|
|
196
|
+
readonly definition: "Tree removal, trimming, and care services.";
|
|
197
|
+
}, {
|
|
198
|
+
readonly value: "water_treatment";
|
|
199
|
+
readonly definition: "Water softeners, filtration, reverse osmosis, and well water treatment.";
|
|
200
|
+
}, {
|
|
201
|
+
readonly value: "wildlife_control";
|
|
202
|
+
readonly definition: "Wildlife removal or exclusion services (e.g., raccoons, squirrels, bats).";
|
|
203
|
+
}, {
|
|
204
|
+
readonly value: "window_cleaning";
|
|
205
|
+
readonly definition: "Window cleaning services.";
|
|
206
|
+
}, {
|
|
207
|
+
readonly value: "window_installation";
|
|
208
|
+
readonly definition: "Window installation or replacement services.";
|
|
209
|
+
}, {
|
|
210
|
+
readonly value: "windows_doors";
|
|
211
|
+
readonly definition: "Window or door installation or replacement.";
|
|
212
|
+
}, {
|
|
213
|
+
readonly value: "other";
|
|
214
|
+
readonly definition: "Services that do not fit above.";
|
|
215
|
+
}];
|
|
216
|
+
export type JobType = (typeof JOB_TYPE_DEFINITIONS)[number]["value"];
|
|
217
|
+
export declare const JOB_TYPES: JobType[];
|
|
53
218
|
/**
|
|
54
219
|
* Indicates how quickly the issue should be addressed based on the nature of the problem.
|
|
55
220
|
*
|
|
@@ -64,7 +229,8 @@ export type JobType = "appliance_repair" | "blinds" | "carpentry" | "cleaning" |
|
|
|
64
229
|
*
|
|
65
230
|
* Note: Urgency is determined by the nature of the issue itself, not solely by customer's stated urgency.
|
|
66
231
|
*/
|
|
67
|
-
export
|
|
232
|
+
export declare const URGENCY_TYPES: readonly ["LOW", "MEDIUM", "HIGH", "URGENT", "NOT_SPECIFIED"];
|
|
233
|
+
export type UrgencyType = (typeof URGENCY_TYPES)[number];
|
|
68
234
|
export interface LeadAnalysis {
|
|
69
235
|
/**
|
|
70
236
|
* The version of the analysis that was performed. This changes when major changes are made to the analysis process. It can be used to determine if the analysis is up to date and needs to be re-run.
|
|
@@ -103,3 +269,19 @@ export interface LeadAnalysis {
|
|
|
103
269
|
*/
|
|
104
270
|
analysis?: string;
|
|
105
271
|
}
|
|
272
|
+
export interface RawLeadLabels {
|
|
273
|
+
contactType?: string;
|
|
274
|
+
serviceType?: string;
|
|
275
|
+
jobType?: string;
|
|
276
|
+
urgency?: string;
|
|
277
|
+
}
|
|
278
|
+
export type NormalizedLeadLabels = Pick<LeadAnalysis, "contactType" | "serviceType" | "jobType" | "urgency">;
|
|
279
|
+
/**
|
|
280
|
+
* Checks the labels a model returned against the allowed values.
|
|
281
|
+
*
|
|
282
|
+
* Bedrock ignores the JSON schema that lists them, and the parsers used to cast whatever came back,
|
|
283
|
+
* so production held 83 invented job types, 22 invented service types, and QUOTE_REQUEST — a contact
|
|
284
|
+
* type — in serviceType 209 times. A known variant maps to the value it means; anything else unknown
|
|
285
|
+
* falls to its catch-all. An absent label stays absent.
|
|
286
|
+
*/
|
|
287
|
+
export declare function normalizeLeadLabels(raw: RawLeadLabels): NormalizedLeadLabels;
|
|
@@ -1,4 +1,233 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*! Copyright (c) 2024, XAPP AI */
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.URGENCY_TYPES = exports.JOB_TYPES = exports.JOB_TYPE_DEFINITIONS = exports.SERVICE_TYPES = exports.CONTACT_TYPES = void 0;
|
|
5
|
+
exports.normalizeLeadLabels = normalizeLeadLabels;
|
|
6
|
+
/**
|
|
7
|
+
* Categorizes the nature of the customer's interaction with the business.
|
|
8
|
+
*
|
|
9
|
+
* See LEAD_ANALYSIS_GUIDE.md for detailed definitions and examples.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* - BILLING_ISSUE: Concerns about charges, refunds, pricing discrepancies, or payments
|
|
13
|
+
* - CANCELLATION: Asking to cancel an appointment, service, subscription, or contract
|
|
14
|
+
* - COMPLAINT: Dissatisfaction with business, product, or service quality (excluding billing/scheduling)
|
|
15
|
+
* - COMPLIMENT: Positive feedback about the business, staff, or product
|
|
16
|
+
* - CONTACT_REQUEST: Request for contact without actionable details (use only for vague "call me" requests)
|
|
17
|
+
* - EMPLOYMENT_INQUIRY: Questions about jobs, openings, hiring, or how to apply
|
|
18
|
+
* - MISSED_APPOINTMENT: Reporting a no-show, missed call/visit, or confirmation confusion
|
|
19
|
+
* - QUESTION: General inquiry about business/services without requesting service or quote
|
|
20
|
+
* - QUOTE_REQUEST: Requesting a price, cost, estimate, quote, or ballpark figure
|
|
21
|
+
* - RESCHEDULE_REQUEST: Asking to change date/time of existing appointment or scheduled service
|
|
22
|
+
* - SERVICE_REQUEST: Requesting service, repair, installation, maintenance, inspection, or scheduling
|
|
23
|
+
* - SPAM: Unsolicited, irrelevant, deceptive, or low-value content
|
|
24
|
+
* - TEST: Test message, placeholder text, or internal system check
|
|
25
|
+
* - OTHER: Content cannot be reasonably determined
|
|
26
|
+
*/
|
|
27
|
+
exports.CONTACT_TYPES = [
|
|
28
|
+
"BILLING_ISSUE",
|
|
29
|
+
"CANCELLATION",
|
|
30
|
+
"COMPLAINT",
|
|
31
|
+
"COMPLIMENT",
|
|
32
|
+
"CONTACT_REQUEST",
|
|
33
|
+
"EMPLOYMENT_INQUIRY",
|
|
34
|
+
"MISSED_APPOINTMENT",
|
|
35
|
+
"QUESTION",
|
|
36
|
+
"QUOTE_REQUEST",
|
|
37
|
+
"RESCHEDULE_REQUEST",
|
|
38
|
+
"SERVICE_REQUEST",
|
|
39
|
+
"SPAM",
|
|
40
|
+
"TEST",
|
|
41
|
+
"OTHER"
|
|
42
|
+
];
|
|
43
|
+
/**
|
|
44
|
+
* Describes what kind of work the customer is requesting (high-level categorization).
|
|
45
|
+
*
|
|
46
|
+
* See LEAD_ANALYSIS_GUIDE.md for detailed definitions and examples.
|
|
47
|
+
*
|
|
48
|
+
* @remarks
|
|
49
|
+
* - CLEANING: Cleaning work (house, windows, ducts, carpet, gutters)
|
|
50
|
+
* - CONSULTATION: Requesting advice or guidance only, not execution
|
|
51
|
+
* - INSPECTION: Evaluation or assessment to check a condition or issue
|
|
52
|
+
* - INSTALLATION: New installation of a product or system
|
|
53
|
+
* - MAINTENANCE: Routine or recurring upkeep
|
|
54
|
+
* - REFINISH: Refinishing surfaces (floors, cabinets, painting, staining)
|
|
55
|
+
* - REMODEL: Renovating or improving an existing structure or space
|
|
56
|
+
* - REPAIR: Fixing an existing product or system
|
|
57
|
+
* - SUPPORT: Help with an issue or appointment related to service but not the work itself
|
|
58
|
+
* - TRANSPORT: Moving, hauling, or delivering items
|
|
59
|
+
* - TREATMENT: Active service to resolve or prevent an issue (pest control, mold remediation, etc.)
|
|
60
|
+
* - OTHER: Work that doesn't fit the above categories
|
|
61
|
+
*/
|
|
62
|
+
exports.SERVICE_TYPES = [
|
|
63
|
+
"CLEANING",
|
|
64
|
+
"CONSULTATION",
|
|
65
|
+
"INSPECTION",
|
|
66
|
+
"INSTALLATION",
|
|
67
|
+
"MAINTENANCE",
|
|
68
|
+
"REFINISH",
|
|
69
|
+
"REMODEL",
|
|
70
|
+
"REPAIR",
|
|
71
|
+
"SUPPORT",
|
|
72
|
+
"TRANSPORT",
|
|
73
|
+
"TREATMENT",
|
|
74
|
+
"OTHER"
|
|
75
|
+
];
|
|
76
|
+
/**
|
|
77
|
+
* The trades a lead can be classified into, each with the definition the model is given.
|
|
78
|
+
*
|
|
79
|
+
* This is the ONE list: the `JobType` union, the definitions in the AnalyzeLead and AnalyzeEmail
|
|
80
|
+
* prompts, both JSON schemas and the response validation are all derived from it. It used to be
|
|
81
|
+
* written out four times, and a change to one copy silently left the others behind.
|
|
82
|
+
*
|
|
83
|
+
* See LEAD_ANALYSIS_GUIDE.md for detailed definitions and examples.
|
|
84
|
+
*
|
|
85
|
+
* @remarks
|
|
86
|
+
* Some categories have aliases (e.g., electrical/electrician, gutter/gutters). They are label values
|
|
87
|
+
* that dashboards, GraphQL filters and customer webhooks already read, so collapsing them is a
|
|
88
|
+
* coordinated change of its own — not something to do in passing.
|
|
89
|
+
*
|
|
90
|
+
* Added in analysis 1.3.0, from production leads the classifier had no value for (2026-09-14):
|
|
91
|
+
* fireplace_chimney, drainage_waterproofing, water_treatment, pool_spa, closets_organization,
|
|
92
|
+
* radon_mitigation, awnings_shade, and the non-home-services tenants dental, eye_care,
|
|
93
|
+
* event_rental and salon.
|
|
94
|
+
*/
|
|
95
|
+
exports.JOB_TYPE_DEFINITIONS = [
|
|
96
|
+
{ value: "appliance_repair", definition: "Appliance repair services." },
|
|
97
|
+
{ value: "awnings_shade", definition: "Awnings, canopies, shade sails, and outdoor canvas structures." },
|
|
98
|
+
{ value: "blinds", definition: "Window blinds and shades installation services." },
|
|
99
|
+
{ value: "carpentry", definition: "Carpentry or woodworking services." },
|
|
100
|
+
{ value: "cleaning", definition: "General cleaning services (house, carpet, duct, etc.)." },
|
|
101
|
+
{ value: "closets_organization", definition: "Closet systems and home or garage organization." },
|
|
102
|
+
{ value: "construction", definition: "General construction services." },
|
|
103
|
+
{ value: "contractor", definition: "General contracting services (same as construction)." },
|
|
104
|
+
{ value: "dental", definition: "Dental care: cleanings, exams, fillings, crowns, extractions, dentures." },
|
|
105
|
+
{ value: "drainage_waterproofing", definition: "Drainage, French drains, sump pumps, and basement or foundation waterproofing." },
|
|
106
|
+
{ value: "drywall", definition: "Drywall installation or repair." },
|
|
107
|
+
{ value: "electrical", definition: "Electrical work or services, including EV charger installation." },
|
|
108
|
+
{ value: "electrician", definition: "Electrical work or services (same as electrical)." },
|
|
109
|
+
{ value: "event_rental", definition: "Party and event rentals: tents, tables, chairs, linens, equipment." },
|
|
110
|
+
{ value: "eye_care", definition: "Eye exams, optometry, contact lenses, and eyewear." },
|
|
111
|
+
{ value: "fencing", definition: "Fence installation or repair." },
|
|
112
|
+
{ value: "fireplace_chimney", definition: "Fireplaces, gas logs and inserts, chimneys, and wood or pellet stoves." },
|
|
113
|
+
{ value: "flooring", definition: "Flooring installation, refinishing, or repair (hardwood, tile, garage floor coatings, etc.)." },
|
|
114
|
+
{ value: "gutter", definition: "Gutter installation, rerouting, or cleaning." },
|
|
115
|
+
{ value: "gutters", definition: "Gutter services (same as gutter)." },
|
|
116
|
+
{ value: "handyman", definition: "General home repair and maintenance services." },
|
|
117
|
+
{ value: "house_cleaning", definition: "House cleaning services (same as cleaning)." },
|
|
118
|
+
{ value: "hvac", definition: "Heating, ventilation, or air conditioning services, including dryer vent cleaning." },
|
|
119
|
+
{ value: "junk_removal", definition: "Junk and debris removal services." },
|
|
120
|
+
{ value: "landscaping", definition: "Landscaping or yard services." },
|
|
121
|
+
{ value: "landscaper", definition: "Landscaping services (same as landscaping)." },
|
|
122
|
+
{ value: "legal_services", definition: "Legal services." },
|
|
123
|
+
{ value: "masonry", definition: "Masonry, brick, stone, or tuckpointing work." },
|
|
124
|
+
{ value: "mold_remediation", definition: "Mold inspection, removal, or remediation services." },
|
|
125
|
+
{ value: "moving", definition: "Moving or relocation services." },
|
|
126
|
+
{ value: "painting", definition: "Painting services." },
|
|
127
|
+
{ value: "painter", definition: "Painting services (same as painting)." },
|
|
128
|
+
{ value: "pest_control", definition: "Pest control services (insects, termites, rodents)." },
|
|
129
|
+
{ value: "plumbing", definition: "Plumbing services, including water heaters, fixtures, backflow testing, and septic." },
|
|
130
|
+
{ value: "pool_spa", definition: "Pool and spa installation, repair, cleaning, and maintenance." },
|
|
131
|
+
{ value: "pressure_washing", definition: "Pressure washing and power washing services." },
|
|
132
|
+
{ value: "radon_mitigation", definition: "Radon testing and mitigation systems." },
|
|
133
|
+
{ value: "remodeling", definition: "Remodeling or renovation (kitchen, bathroom, home)." },
|
|
134
|
+
{ value: "restoration", definition: "Water, fire, or damage restoration services." },
|
|
135
|
+
{ value: "roofing", definition: "Roofing services." },
|
|
136
|
+
{ value: "roofer", definition: "Roofing services (same as roofing)." },
|
|
137
|
+
{ value: "salon", definition: "Hair, nail, and beauty salon services." },
|
|
138
|
+
{ value: "siding", definition: "Siding installation or repair services." },
|
|
139
|
+
{ value: "tree_services", definition: "Tree removal, trimming, and care services." },
|
|
140
|
+
{ value: "water_treatment", definition: "Water softeners, filtration, reverse osmosis, and well water treatment." },
|
|
141
|
+
{ value: "wildlife_control", definition: "Wildlife removal or exclusion services (e.g., raccoons, squirrels, bats)." },
|
|
142
|
+
{ value: "window_cleaning", definition: "Window cleaning services." },
|
|
143
|
+
{ value: "window_installation", definition: "Window installation or replacement services." },
|
|
144
|
+
{ value: "windows_doors", definition: "Window or door installation or replacement." },
|
|
145
|
+
{ value: "other", definition: "Services that do not fit above." }
|
|
146
|
+
];
|
|
147
|
+
exports.JOB_TYPES = exports.JOB_TYPE_DEFINITIONS.map((d) => d.value);
|
|
148
|
+
/**
|
|
149
|
+
* Indicates how quickly the issue should be addressed based on the nature of the problem.
|
|
150
|
+
*
|
|
151
|
+
* See LEAD_ANALYSIS_GUIDE.md for detailed definitions and examples.
|
|
152
|
+
*
|
|
153
|
+
* @remarks
|
|
154
|
+
* - LOW: Not time-sensitive, can be addressed at business's convenience
|
|
155
|
+
* - MEDIUM: Not time-sensitive, can be addressed within a couple of weeks
|
|
156
|
+
* - HIGH: Not life-threatening but should be addressed within a few days (may lead to property damage)
|
|
157
|
+
* - URGENT: Life-threatening or causing property damage, should be addressed ASAP (potentially same day)
|
|
158
|
+
* - NOT_SPECIFIED: Urgency could not be determined from available information
|
|
159
|
+
*
|
|
160
|
+
* Note: Urgency is determined by the nature of the issue itself, not solely by customer's stated urgency.
|
|
161
|
+
*/
|
|
162
|
+
exports.URGENCY_TYPES = ["LOW", "MEDIUM", "HIGH", "URGENT", "NOT_SPECIFIED"];
|
|
163
|
+
/**
|
|
164
|
+
* Job types the model has returned in production that are not values, mapped to the value they
|
|
165
|
+
* mean. Measured on analysis 1.2.0 (2026-09-14): the model invented 113 values, led by chimney,
|
|
166
|
+
* waterproofing, awning, drainage and charging_station.
|
|
167
|
+
*/
|
|
168
|
+
const JOB_TYPE_VARIANTS = {
|
|
169
|
+
awning: "awnings_shade",
|
|
170
|
+
awnings: "awnings_shade",
|
|
171
|
+
shade_sails: "awnings_shade",
|
|
172
|
+
charging_station: "electrical",
|
|
173
|
+
ev_charger: "electrical",
|
|
174
|
+
ev_charging: "electrical",
|
|
175
|
+
chimney: "fireplace_chimney",
|
|
176
|
+
fireplace: "fireplace_chimney",
|
|
177
|
+
gas_fireplace: "fireplace_chimney",
|
|
178
|
+
closet: "closets_organization",
|
|
179
|
+
closets: "closets_organization",
|
|
180
|
+
organization: "closets_organization",
|
|
181
|
+
drainage: "drainage_waterproofing",
|
|
182
|
+
waterproofing: "drainage_waterproofing",
|
|
183
|
+
basement_waterproofing: "drainage_waterproofing",
|
|
184
|
+
sump_pump: "drainage_waterproofing",
|
|
185
|
+
pool: "pool_spa",
|
|
186
|
+
pools: "pool_spa",
|
|
187
|
+
spa: "pool_spa",
|
|
188
|
+
radon: "radon_mitigation",
|
|
189
|
+
septic: "plumbing",
|
|
190
|
+
water_heater: "plumbing",
|
|
191
|
+
water_softener: "water_treatment",
|
|
192
|
+
water_filtration: "water_treatment",
|
|
193
|
+
garage_floor: "flooring",
|
|
194
|
+
garage_floor_coating: "flooring",
|
|
195
|
+
dryer_vent: "hvac"
|
|
196
|
+
};
|
|
197
|
+
const CONTACT_TYPE_SET = new Set(exports.CONTACT_TYPES);
|
|
198
|
+
const SERVICE_TYPE_SET = new Set(exports.SERVICE_TYPES);
|
|
199
|
+
const JOB_TYPE_SET = new Set(exports.JOB_TYPES);
|
|
200
|
+
const URGENCY_TYPE_SET = new Set(exports.URGENCY_TYPES);
|
|
201
|
+
const text = (v) => (typeof v === "string" && v.trim() ? v.trim() : undefined);
|
|
202
|
+
/**
|
|
203
|
+
* Checks the labels a model returned against the allowed values.
|
|
204
|
+
*
|
|
205
|
+
* Bedrock ignores the JSON schema that lists them, and the parsers used to cast whatever came back,
|
|
206
|
+
* so production held 83 invented job types, 22 invented service types, and QUOTE_REQUEST — a contact
|
|
207
|
+
* type — in serviceType 209 times. A known variant maps to the value it means; anything else unknown
|
|
208
|
+
* falls to its catch-all. An absent label stays absent.
|
|
209
|
+
*/
|
|
210
|
+
function normalizeLeadLabels(raw) {
|
|
211
|
+
var _a, _b, _c, _d;
|
|
212
|
+
const out = {};
|
|
213
|
+
const contactType = (_a = text(raw.contactType)) === null || _a === void 0 ? void 0 : _a.toUpperCase();
|
|
214
|
+
if (contactType) {
|
|
215
|
+
out.contactType = (CONTACT_TYPE_SET.has(contactType) ? contactType : "OTHER");
|
|
216
|
+
}
|
|
217
|
+
const serviceType = (_b = text(raw.serviceType)) === null || _b === void 0 ? void 0 : _b.toUpperCase();
|
|
218
|
+
if (serviceType) {
|
|
219
|
+
out.serviceType = (SERVICE_TYPE_SET.has(serviceType) ? serviceType : "OTHER");
|
|
220
|
+
}
|
|
221
|
+
const jobType = (_c = text(raw.jobType)) === null || _c === void 0 ? void 0 : _c.toLowerCase().replace(/[\s-]+/g, "_");
|
|
222
|
+
if (jobType) {
|
|
223
|
+
// hasOwnProperty, not a bare lookup: "constructor" would otherwise find Object's.
|
|
224
|
+
const variant = Object.prototype.hasOwnProperty.call(JOB_TYPE_VARIANTS, jobType) ? JOB_TYPE_VARIANTS[jobType] : undefined;
|
|
225
|
+
out.jobType = JOB_TYPE_SET.has(jobType) ? jobType : variant || "other";
|
|
226
|
+
}
|
|
227
|
+
const urgency = (_d = text(raw.urgency)) === null || _d === void 0 ? void 0 : _d.toUpperCase();
|
|
228
|
+
if (urgency) {
|
|
229
|
+
out.urgency = (URGENCY_TYPE_SET.has(urgency) ? urgency : "NOT_SPECIFIED");
|
|
230
|
+
}
|
|
231
|
+
return out;
|
|
232
|
+
}
|
|
4
233
|
//# sourceMappingURL=LeadAnalysis.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LeadAnalysis.js","sourceRoot":"","sources":["../../src/models/LeadAnalysis.ts"],"names":[],"mappings":";AAAA,kCAAkC"}
|
|
1
|
+
{"version":3,"file":"LeadAnalysis.js","sourceRoot":"","sources":["../../src/models/LeadAnalysis.ts"],"names":[],"mappings":";AAAA,kCAAkC;;;AA8QlC,kDA0BC;AAtSD;;;;;;;;;;;;;;;;;;;;GAoBG;AACU,QAAA,aAAa,GAAG;IACzB,eAAe;IACf,cAAc;IACd,WAAW;IACX,YAAY;IACZ,iBAAiB;IACjB,oBAAoB;IACpB,oBAAoB;IACpB,UAAU;IACV,eAAe;IACf,oBAAoB;IACpB,iBAAiB;IACjB,MAAM;IACN,MAAM;IACN,OAAO;CACD,CAAC;AAIX;;;;;;;;;;;;;;;;;;GAkBG;AACU,QAAA,aAAa,GAAG;IACzB,UAAU;IACV,cAAc;IACd,YAAY;IACZ,cAAc;IACd,aAAa;IACb,UAAU;IACV,SAAS;IACT,QAAQ;IACR,SAAS;IACT,WAAW;IACX,WAAW;IACX,OAAO;CACD,CAAC;AAIX;;;;;;;;;;;;;;;;;;GAkBG;AACU,QAAA,oBAAoB,GAAG;IAChC,EAAE,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,4BAA4B,EAAE;IACvE,EAAE,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,gEAAgE,EAAE;IACxG,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,iDAAiD,EAAE;IAClF,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,oCAAoC,EAAE;IACxE,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,wDAAwD,EAAE;IAC3F,EAAE,KA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,CAAC;IAED,MAAM,OAAO,GAAG,MAAA,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,0CAAE,WAAW,GAAG,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IACzE,IAAI,OAAO,EAAE,CAAC;QACV,kFAAkF;QAClF,MAAM,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC1H,GAAG,CAAC,OAAO,GAAG,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAE,OAAmB,CAAC,CAAC,CAAC,OAAO,IAAI,OAAO,CAAC;IACxF,CAAC;IAED,MAAM,OAAO,GAAG,MAAA,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,0CAAE,WAAW,EAAE,CAAC;IACjD,IAAI,OAAO,EAAE,CAAC;QACV,GAAG,CAAC,OAAO,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAgB,CAAC;IAC7F,CAAC;IAED,OAAO,GAAG,CAAC;AACf,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*! Copyright (c) 2026, XAPP AI */
|
|
2
2
|
import type { CompletionPrompt, PromptGenerator, ResponseParser } from "../models";
|
|
3
3
|
import type { EmailAnalysisInput, EmailLeadAnalysis } from "../models/EmailAnalysis";
|
|
4
|
-
export declare const ANALYZE_EMAIL_VERSION = "1.
|
|
4
|
+
export declare const ANALYZE_EMAIL_VERSION = "1.2.0";
|
|
5
5
|
export interface AnalyzeEmailProps {
|
|
6
6
|
businessDescription?: string;
|
|
7
7
|
highValueLeadDescription?: string;
|
|
@@ -6,7 +6,9 @@ exports.emailThreadToMessages = emailThreadToMessages;
|
|
|
6
6
|
const AnalyzeLead_1 = require("./AnalyzeLead");
|
|
7
7
|
const errors_1 = require("../models/errors");
|
|
8
8
|
const extractJSON_1 = require("../utils/extractJSON");
|
|
9
|
-
|
|
9
|
+
const LeadAnalysis_1 = require("../models/LeadAnalysis");
|
|
10
|
+
const leadTaxonomyPrompt_1 = require("./leadTaxonomyPrompt");
|
|
11
|
+
exports.ANALYZE_EMAIL_VERSION = "1.2.0"; // 1.2.0: the AnalyzeLead 1.3.0 taxonomy and validation, shared
|
|
10
12
|
/** Headers forwarded to the LLM to help disambiguate the actual contact from template senders. */
|
|
11
13
|
const RELEVANT_HEADERS = ["reply-to", "x-mailer", "x-original-sender", "x-source"];
|
|
12
14
|
/**
|
|
@@ -128,6 +130,7 @@ TEST: A test message, placeholder text, or internal system check (e.g., "test",
|
|
|
128
130
|
OTHER: Content cannot be reasonably determined from the email.
|
|
129
131
|
|
|
130
132
|
When multiple could apply, prefer BILLING_ISSUE, RESCHEDULE_REQUEST, CANCELLATION, or MISSED_APPOINTMENT over COMPLAINT or CONTACT_REQUEST.
|
|
133
|
+
${leadTaxonomyPrompt_1.ESTIMATING_VENDOR_SPAM_EXAMPLES}
|
|
131
134
|
|
|
132
135
|
|
|
133
136
|
The definitions of each "serviceType" value are as follows:
|
|
@@ -144,46 +147,7 @@ TRANSPORT: Requests to move, haul, or deliver items (e.g., moving services, relo
|
|
|
144
147
|
TREATMENT: Active service to resolve or prevent an issue (e.g., pest treatment, mold remediation, lawn spraying, rodent removal, recurring pest plans).
|
|
145
148
|
OTHER: Anything not covered above. If multiple apply, pick the most specific.
|
|
146
149
|
|
|
147
|
-
|
|
148
|
-
appliance_repair: Appliance repair services.
|
|
149
|
-
blinds: Window blinds and shades installation services.
|
|
150
|
-
carpentry: Carpentry or woodworking services.
|
|
151
|
-
cleaning: General cleaning services (house, carpet, duct, etc.).
|
|
152
|
-
construction: General construction services.
|
|
153
|
-
contractor: General contracting services (same as construction).
|
|
154
|
-
drywall: Drywall installation or repair.
|
|
155
|
-
electrical: Electrical work or services.
|
|
156
|
-
electrician: Electrical work or services (same as electrical).
|
|
157
|
-
fencing: Fence installation or repair.
|
|
158
|
-
flooring: Flooring installation, refinishing, or repair (hardwood, tile, etc.).
|
|
159
|
-
gutter: Gutter installation, rerouting, or cleaning.
|
|
160
|
-
gutters: Gutter services (same as gutter).
|
|
161
|
-
handyman: General home repair and maintenance services.
|
|
162
|
-
house_cleaning: House cleaning services (same as cleaning).
|
|
163
|
-
hvac: Heating, ventilation, or air conditioning services.
|
|
164
|
-
junk_removal: Junk and debris removal services.
|
|
165
|
-
landscaping: Landscaping or yard services.
|
|
166
|
-
landscaper: Landscaping services (same as landscaping).
|
|
167
|
-
legal_services: Legal services.
|
|
168
|
-
masonry: Masonry, brick, stone, or tuckpointing work.
|
|
169
|
-
mold_remediation: Mold inspection, removal, or remediation services.
|
|
170
|
-
moving: Moving or relocation services.
|
|
171
|
-
painting: Painting services.
|
|
172
|
-
painter: Painting services (same as painting).
|
|
173
|
-
pest_control: Pest control services (insects, termites, rodents).
|
|
174
|
-
plumbing: Plumbing services.
|
|
175
|
-
pressure_washing: Pressure washing and power washing services.
|
|
176
|
-
remodeling: Remodeling or renovation (kitchen, bathroom, home).
|
|
177
|
-
restoration: Water, fire, or damage restoration services.
|
|
178
|
-
roofing: Roofing services.
|
|
179
|
-
roofer: Roofing services (same as roofing).
|
|
180
|
-
siding: Siding installation or repair services.
|
|
181
|
-
tree_services: Tree removal, trimming, and care services.
|
|
182
|
-
wildlife_control: Wildlife removal or exclusion services (e.g., raccoons, squirrels, bats).
|
|
183
|
-
window_cleaning: Window cleaning services.
|
|
184
|
-
window_installation: Window installation or replacement services.
|
|
185
|
-
windows_doors: Window or door installation or replacement.
|
|
186
|
-
other: Services that do not fit above.
|
|
150
|
+
${(0, leadTaxonomyPrompt_1.jobTypeSection)(hasBusinessDescription)}
|
|
187
151
|
|
|
188
152
|
The definitions of each "urgency" value are as follows:
|
|
189
153
|
LOW: The interaction requests a service that is not time sensitive at all and can be addressed at the business's convenience.
|
|
@@ -208,7 +172,10 @@ For "extractedContact", extract any structured contact information found in the
|
|
|
208
172
|
`;
|
|
209
173
|
const messages = emailThreadToMessages(system, email);
|
|
210
174
|
const max_tokens = 768;
|
|
211
|
-
return Object.assign(Object.assign({ model: "gpt-4o-mini", max_tokens, frequency_penalty: 0,
|
|
175
|
+
return Object.assign(Object.assign({ model: "gpt-4o-mini", max_tokens, frequency_penalty: 0,
|
|
176
|
+
// A classifier should give the same message the same labels. At 1, 37% of repeated
|
|
177
|
+
// identical messages came back with a different contact type (measured 2026-09-14).
|
|
178
|
+
temperature: 0, top_p: 1, presence_penalty: 0 }, overrides), { response_format: {
|
|
212
179
|
type: "json_schema",
|
|
213
180
|
json_schema: {
|
|
214
181
|
name: "analyze_email",
|
|
@@ -230,87 +197,19 @@ For "extractedContact", extract any structured contact information found in the
|
|
|
230
197
|
properties: {
|
|
231
198
|
contactType: {
|
|
232
199
|
type: "string",
|
|
233
|
-
enum: [
|
|
234
|
-
"BILLING_ISSUE",
|
|
235
|
-
"CANCELLATION",
|
|
236
|
-
"COMPLAINT",
|
|
237
|
-
"COMPLIMENT",
|
|
238
|
-
"CONTACT_REQUEST",
|
|
239
|
-
"EMPLOYMENT_INQUIRY",
|
|
240
|
-
"MISSED_APPOINTMENT",
|
|
241
|
-
"QUESTION",
|
|
242
|
-
"QUOTE_REQUEST",
|
|
243
|
-
"RESCHEDULE_REQUEST",
|
|
244
|
-
"SERVICE_REQUEST",
|
|
245
|
-
"SPAM",
|
|
246
|
-
"TEST",
|
|
247
|
-
"OTHER"
|
|
248
|
-
]
|
|
200
|
+
enum: [...LeadAnalysis_1.CONTACT_TYPES]
|
|
249
201
|
},
|
|
250
202
|
jobType: {
|
|
251
203
|
type: "string",
|
|
252
|
-
enum: [
|
|
253
|
-
"appliance_repair",
|
|
254
|
-
"blinds",
|
|
255
|
-
"carpentry",
|
|
256
|
-
"cleaning",
|
|
257
|
-
"construction",
|
|
258
|
-
"contractor",
|
|
259
|
-
"drywall",
|
|
260
|
-
"electrical",
|
|
261
|
-
"electrician",
|
|
262
|
-
"fencing",
|
|
263
|
-
"flooring",
|
|
264
|
-
"gutter",
|
|
265
|
-
"gutters",
|
|
266
|
-
"handyman",
|
|
267
|
-
"house_cleaning",
|
|
268
|
-
"hvac",
|
|
269
|
-
"junk_removal",
|
|
270
|
-
"landscaping",
|
|
271
|
-
"landscaper",
|
|
272
|
-
"legal_services",
|
|
273
|
-
"masonry",
|
|
274
|
-
"mold_remediation",
|
|
275
|
-
"moving",
|
|
276
|
-
"painting",
|
|
277
|
-
"painter",
|
|
278
|
-
"pest_control",
|
|
279
|
-
"plumbing",
|
|
280
|
-
"pressure_washing",
|
|
281
|
-
"remodeling",
|
|
282
|
-
"restoration",
|
|
283
|
-
"roofing",
|
|
284
|
-
"roofer",
|
|
285
|
-
"siding",
|
|
286
|
-
"tree_services",
|
|
287
|
-
"wildlife_control",
|
|
288
|
-
"window_cleaning",
|
|
289
|
-
"window_installation",
|
|
290
|
-
"windows_doors",
|
|
291
|
-
"other"
|
|
292
|
-
]
|
|
204
|
+
enum: [...LeadAnalysis_1.JOB_TYPES]
|
|
293
205
|
},
|
|
294
206
|
serviceType: {
|
|
295
207
|
type: "string",
|
|
296
|
-
enum: [
|
|
297
|
-
"CLEANING",
|
|
298
|
-
"CONSULTATION",
|
|
299
|
-
"INSPECTION",
|
|
300
|
-
"INSTALLATION",
|
|
301
|
-
"MAINTENANCE",
|
|
302
|
-
"REFINISH",
|
|
303
|
-
"REMODEL",
|
|
304
|
-
"REPAIR",
|
|
305
|
-
"SUPPORT",
|
|
306
|
-
"TRANSPORT",
|
|
307
|
-
"TREATMENT",
|
|
308
|
-
"OTHER"
|
|
309
|
-
]
|
|
208
|
+
enum: [...LeadAnalysis_1.SERVICE_TYPES]
|
|
310
209
|
},
|
|
311
210
|
urgency: {
|
|
312
211
|
type: "string",
|
|
313
|
-
enum: [
|
|
212
|
+
enum: [...LeadAnalysis_1.URGENCY_TYPES]
|
|
314
213
|
},
|
|
315
214
|
highValueLead: {
|
|
316
215
|
type: "boolean"
|
|
@@ -355,15 +254,17 @@ exports.defaultEmailLeadAnalysis = {
|
|
|
355
254
|
const analyzeEmailResponseParse = (response) => {
|
|
356
255
|
try {
|
|
357
256
|
const { contactType, jobType, serviceType, urgency, highValueLead, summary, analysis, conciseSummary, extractedContact } = JSON.parse((0, extractJSON_1.extractJSON)(response));
|
|
358
|
-
|
|
257
|
+
// Checked against the allowed values: Bedrock ignores the schema, so nothing else does.
|
|
258
|
+
const labels = (0, LeadAnalysis_1.normalizeLeadLabels)({ contactType, serviceType, jobType, urgency });
|
|
259
|
+
const draftAnalysis = Object.assign(Object.assign({}, exports.defaultEmailLeadAnalysis), { contactType: labels.contactType || exports.defaultEmailLeadAnalysis.contactType, urgency: labels.urgency || exports.defaultEmailLeadAnalysis.urgency, highValueLead: (highValueLead === null || highValueLead === void 0 ? void 0 : highValueLead.toString().toLocaleLowerCase()) === "true" || exports.defaultEmailLeadAnalysis.highValueLead, summary: summary || exports.defaultEmailLeadAnalysis.summary, analysis: analysis || exports.defaultEmailLeadAnalysis.analysis });
|
|
359
260
|
if (conciseSummary) {
|
|
360
261
|
draftAnalysis.conciseSummary = conciseSummary;
|
|
361
262
|
}
|
|
362
|
-
if (jobType) {
|
|
363
|
-
draftAnalysis.jobType = jobType
|
|
263
|
+
if (labels.jobType) {
|
|
264
|
+
draftAnalysis.jobType = labels.jobType;
|
|
364
265
|
}
|
|
365
|
-
if (serviceType) {
|
|
366
|
-
draftAnalysis.serviceType = serviceType
|
|
266
|
+
if (labels.serviceType) {
|
|
267
|
+
draftAnalysis.serviceType = labels.serviceType;
|
|
367
268
|
}
|
|
368
269
|
if (extractedContact) {
|
|
369
270
|
const contact = extractedContact;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnalyzeEmail.js","sourceRoot":"","sources":["../../src/prompts/AnalyzeEmail.ts"],"names":[],"mappings":";AAAA,kCAAkC;;;
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AC;YACrB,aAAa,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;QACnD,CAAC;QAED,IAAI,gBAAgB,EAAE,CAAC;YACnB,MAAM,OAAO,GAAG,gBAAwC,CAAC;YACzD,mEAAmE;YACnE,IAAI,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;gBACrD,oEAAoE;gBACpE,OAAO,CAAC,UAAU,GAAG,OAAO,OAAO,CAAC,UAAU,KAAK,QAAQ;oBACvD,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;oBAC9C,CAAC,CAAC,CAAC,CAAC;gBACR,aAAa,CAAC,gBAAgB,GAAG,OAAO,CAAC;YAC7C,CAAC;QACL,CAAC;QAED,OAAO,aAAa,CAAC;IACzB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,uFAAuF;QACvF,yFAAyF;QACzF,0FAA0F;QAC1F,MAAM,IAAI,8BAAqB,CAAC,cAAc,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;IACjE,CAAC;AACL,CAAC,CAAC;AAhDW,QAAA,yBAAyB,6BAgDpC"}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
/*! Copyright (c) 2024, XAPP AI */
|
|
2
2
|
import type { ExternalLead, Message } from "stentor-models";
|
|
3
3
|
import type { CompletionPrompt, LeadAnalysis, PromptGenerator, ResponseParser } from "../models";
|
|
4
|
+
/**
|
|
5
|
+
* The lead analysis version, stamped on every analysis. Bump it whenever the prompt, the taxonomy or
|
|
6
|
+
* the parsing changes: it is how a re-analysis pass finds leads labelled by an older version.
|
|
7
|
+
*
|
|
8
|
+
* 1.3.0 (2026-09-14): temperature 0, labels validated against the allowed values, a single-trade
|
|
9
|
+
* business's trade used when a request names none, eleven new job types, and worked examples.
|
|
10
|
+
*/
|
|
11
|
+
export declare const ANALYZE_LEAD_VERSION = "1.3.0";
|
|
4
12
|
export interface TranscriptMessage {
|
|
5
13
|
text: string;
|
|
6
14
|
speaker: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.analyzeLeadResponseParse = exports.defaultLeadAnalysis = exports.generateAnalyzeLead = void 0;
|
|
3
|
+
exports.analyzeLeadResponseParse = exports.defaultLeadAnalysis = exports.generateAnalyzeLead = exports.ANALYZE_LEAD_VERSION = void 0;
|
|
4
4
|
exports.translateTranscript = translateTranscript;
|
|
5
5
|
exports.transcriptToMessages = transcriptToMessages;
|
|
6
6
|
exports.parseFields = parseFields;
|
|
@@ -8,6 +8,17 @@ exports.getHighValueLeadDescription = getHighValueLeadDescription;
|
|
|
8
8
|
const stentor_utils_1 = require("stentor-utils");
|
|
9
9
|
const errors_1 = require("../models/errors");
|
|
10
10
|
const extractJSON_1 = require("../utils/extractJSON");
|
|
11
|
+
const LeadAnalysis_1 = require("../models/LeadAnalysis");
|
|
12
|
+
const leadTaxonomyPrompt_1 = require("./leadTaxonomyPrompt");
|
|
13
|
+
// import { getTokens } from "../utils/getTokens";
|
|
14
|
+
/**
|
|
15
|
+
* The lead analysis version, stamped on every analysis. Bump it whenever the prompt, the taxonomy or
|
|
16
|
+
* the parsing changes: it is how a re-analysis pass finds leads labelled by an older version.
|
|
17
|
+
*
|
|
18
|
+
* 1.3.0 (2026-09-14): temperature 0, labels validated against the allowed values, a single-trade
|
|
19
|
+
* business's trade used when a request names none, eleven new job types, and worked examples.
|
|
20
|
+
*/
|
|
21
|
+
exports.ANALYZE_LEAD_VERSION = "1.3.0";
|
|
11
22
|
function getName(profile) {
|
|
12
23
|
// Sorting these based on priority.
|
|
13
24
|
return (profile === null || profile === void 0 ? void 0 : profile.name) || (profile === null || profile === void 0 ? void 0 : profile.email) || (profile === null || profile === void 0 ? void 0 : profile.phone) || "Unknown";
|
|
@@ -171,6 +182,7 @@ TEST: A test message, placeholder text, or internal system check (e.g., “test
|
|
|
171
182
|
OTHER: Content cannot be reasonably determined from the transcript.
|
|
172
183
|
|
|
173
184
|
When multiple could apply, prefer BILLING_ISSUE, RESCHEDULE_REQUEST, CANCELLATION, or MISSED_APPOINTMENT over COMPLAINT or CONTACT_REQUEST.
|
|
185
|
+
${leadTaxonomyPrompt_1.ESTIMATING_VENDOR_SPAM_EXAMPLES}
|
|
174
186
|
|
|
175
187
|
|
|
176
188
|
The definitions of each "serviceType" value are as follows:
|
|
@@ -187,46 +199,7 @@ TRANSPORT: Requests to move, haul, or deliver items (e.g., moving services, relo
|
|
|
187
199
|
TREATMENT: Active service to resolve or prevent an issue (e.g., pest treatment, mold remediation, lawn spraying, rodent removal, recurring pest plans).
|
|
188
200
|
OTHER: Anything not covered above. If multiple apply, pick the most specific.
|
|
189
201
|
|
|
190
|
-
|
|
191
|
-
appliance_repair: Appliance repair services.
|
|
192
|
-
blinds: Window blinds and shades installation services.
|
|
193
|
-
carpentry: Carpentry or woodworking services.
|
|
194
|
-
cleaning: General cleaning services (house, carpet, duct, etc.).
|
|
195
|
-
construction: General construction services.
|
|
196
|
-
contractor: General contracting services (same as construction).
|
|
197
|
-
drywall: Drywall installation or repair.
|
|
198
|
-
electrical: Electrical work or services.
|
|
199
|
-
electrician: Electrical work or services (same as electrical).
|
|
200
|
-
fencing: Fence installation or repair.
|
|
201
|
-
flooring: Flooring installation, refinishing, or repair (hardwood, tile, etc.).
|
|
202
|
-
gutter: Gutter installation, rerouting, or cleaning.
|
|
203
|
-
gutters: Gutter services (same as gutter).
|
|
204
|
-
handyman: General home repair and maintenance services.
|
|
205
|
-
house_cleaning: House cleaning services (same as cleaning).
|
|
206
|
-
hvac: Heating, ventilation, or air conditioning services.
|
|
207
|
-
junk_removal: Junk and debris removal services.
|
|
208
|
-
landscaping: Landscaping or yard services.
|
|
209
|
-
landscaper: Landscaping services (same as landscaping).
|
|
210
|
-
legal_services: Legal services.
|
|
211
|
-
masonry: Masonry, brick, stone, or tuckpointing work.
|
|
212
|
-
mold_remediation: Mold inspection, removal, or remediation services.
|
|
213
|
-
moving: Moving or relocation services.
|
|
214
|
-
painting: Painting services.
|
|
215
|
-
painter: Painting services (same as painting).
|
|
216
|
-
pest_control: Pest control services (insects, termites, rodents).
|
|
217
|
-
plumbing: Plumbing services.
|
|
218
|
-
pressure_washing: Pressure washing and power washing services.
|
|
219
|
-
remodeling: Remodeling or renovation (kitchen, bathroom, home).
|
|
220
|
-
restoration: Water, fire, or damage restoration services.
|
|
221
|
-
roofing: Roofing services.
|
|
222
|
-
roofer: Roofing services (same as roofing).
|
|
223
|
-
siding: Siding installation or repair services.
|
|
224
|
-
tree_services: Tree removal, trimming, and care services.
|
|
225
|
-
wildlife_control: Wildlife removal or exclusion services (e.g., raccoons, squirrels, bats).
|
|
226
|
-
window_cleaning: Window cleaning services.
|
|
227
|
-
window_installation: Window installation or replacement services.
|
|
228
|
-
windows_doors: Window or door installation or replacement.
|
|
229
|
-
other: Services that do not fit above.
|
|
202
|
+
${(0, leadTaxonomyPrompt_1.jobTypeSection)(hasBusinessDescription)}
|
|
230
203
|
|
|
231
204
|
The definitions of each "urgency" value are as follows:
|
|
232
205
|
LOW: The interaction requests a service that is not time sensitive at all and can be addressed at the business's convenience.
|
|
@@ -264,7 +237,10 @@ ${parsedFields}
|
|
|
264
237
|
const max_tokens = 512;
|
|
265
238
|
return Object.assign(Object.assign({ model: "gpt-4o-mini",
|
|
266
239
|
// model: "gpt-4.1-mini",
|
|
267
|
-
max_tokens, frequency_penalty: 0,
|
|
240
|
+
max_tokens, frequency_penalty: 0,
|
|
241
|
+
// A classifier should give the same message the same labels. At 1, 37% of repeated
|
|
242
|
+
// identical messages came back with a different contact type (measured 2026-09-14).
|
|
243
|
+
temperature: 0, top_p: 1, presence_penalty: 0 }, overrides), { response_format: {
|
|
268
244
|
type: "json_schema",
|
|
269
245
|
json_schema: {
|
|
270
246
|
name: "analyze_lead",
|
|
@@ -285,87 +261,19 @@ ${parsedFields}
|
|
|
285
261
|
properties: {
|
|
286
262
|
contactType: {
|
|
287
263
|
type: "string",
|
|
288
|
-
enum: [
|
|
289
|
-
"BILLING_ISSUE",
|
|
290
|
-
"CANCELLATION",
|
|
291
|
-
"COMPLAINT",
|
|
292
|
-
"COMPLIMENT",
|
|
293
|
-
"CONTACT_REQUEST",
|
|
294
|
-
"EMPLOYMENT_INQUIRY",
|
|
295
|
-
"MISSED_APPOINTMENT",
|
|
296
|
-
"QUESTION",
|
|
297
|
-
"QUOTE_REQUEST",
|
|
298
|
-
"RESCHEDULE_REQUEST",
|
|
299
|
-
"SERVICE_REQUEST",
|
|
300
|
-
"SPAM",
|
|
301
|
-
"TEST",
|
|
302
|
-
"OTHER"
|
|
303
|
-
]
|
|
264
|
+
enum: [...LeadAnalysis_1.CONTACT_TYPES]
|
|
304
265
|
},
|
|
305
266
|
jobType: {
|
|
306
267
|
type: "string",
|
|
307
|
-
enum: [
|
|
308
|
-
"appliance_repair",
|
|
309
|
-
"blinds",
|
|
310
|
-
"carpentry",
|
|
311
|
-
"cleaning",
|
|
312
|
-
"construction",
|
|
313
|
-
"contractor",
|
|
314
|
-
"drywall",
|
|
315
|
-
"electrical",
|
|
316
|
-
"electrician",
|
|
317
|
-
"fencing",
|
|
318
|
-
"flooring",
|
|
319
|
-
"gutter",
|
|
320
|
-
"gutters",
|
|
321
|
-
"handyman",
|
|
322
|
-
"house_cleaning",
|
|
323
|
-
"hvac",
|
|
324
|
-
"junk_removal",
|
|
325
|
-
"landscaping",
|
|
326
|
-
"landscaper",
|
|
327
|
-
"legal_services",
|
|
328
|
-
"masonry",
|
|
329
|
-
"mold_remediation",
|
|
330
|
-
"moving",
|
|
331
|
-
"painting",
|
|
332
|
-
"painter",
|
|
333
|
-
"pest_control",
|
|
334
|
-
"plumbing",
|
|
335
|
-
"pressure_washing",
|
|
336
|
-
"remodeling",
|
|
337
|
-
"restoration",
|
|
338
|
-
"roofing",
|
|
339
|
-
"roofer",
|
|
340
|
-
"siding",
|
|
341
|
-
"tree_services",
|
|
342
|
-
"wildlife_control",
|
|
343
|
-
"window_cleaning",
|
|
344
|
-
"window_installation",
|
|
345
|
-
"windows_doors",
|
|
346
|
-
"other"
|
|
347
|
-
]
|
|
268
|
+
enum: [...LeadAnalysis_1.JOB_TYPES]
|
|
348
269
|
},
|
|
349
270
|
serviceType: {
|
|
350
271
|
type: "string",
|
|
351
|
-
enum: [
|
|
352
|
-
"CLEANING",
|
|
353
|
-
"CONSULTATION",
|
|
354
|
-
"INSPECTION",
|
|
355
|
-
"INSTALLATION",
|
|
356
|
-
"MAINTENANCE",
|
|
357
|
-
"REFINISH",
|
|
358
|
-
"REMODEL",
|
|
359
|
-
"REPAIR",
|
|
360
|
-
"SUPPORT",
|
|
361
|
-
"TRANSPORT",
|
|
362
|
-
"TREATMENT",
|
|
363
|
-
"OTHER"
|
|
364
|
-
]
|
|
272
|
+
enum: [...LeadAnalysis_1.SERVICE_TYPES]
|
|
365
273
|
},
|
|
366
274
|
urgency: {
|
|
367
275
|
type: "string",
|
|
368
|
-
enum: [
|
|
276
|
+
enum: [...LeadAnalysis_1.URGENCY_TYPES]
|
|
369
277
|
},
|
|
370
278
|
highValueLead: {
|
|
371
279
|
type: "boolean"
|
|
@@ -395,15 +303,17 @@ exports.defaultLeadAnalysis = {
|
|
|
395
303
|
const analyzeLeadResponseParse = (response) => {
|
|
396
304
|
try {
|
|
397
305
|
const { contactType, jobType, serviceType, urgency, highValueLead, summary, analysis, conciseSummary } = JSON.parse((0, extractJSON_1.extractJSON)(response));
|
|
398
|
-
|
|
306
|
+
// Checked against the allowed values: Bedrock ignores the schema, so nothing else does.
|
|
307
|
+
const labels = (0, LeadAnalysis_1.normalizeLeadLabels)({ contactType, serviceType, jobType, urgency });
|
|
308
|
+
const draftAnalysis = Object.assign(Object.assign({}, exports.defaultLeadAnalysis), { contactType: labels.contactType || exports.defaultLeadAnalysis.contactType, urgency: labels.urgency || exports.defaultLeadAnalysis.urgency, highValueLead: (highValueLead === null || highValueLead === void 0 ? void 0 : highValueLead.toString().toLocaleLowerCase()) === "true" || exports.defaultLeadAnalysis.highValueLead, summary: summary || exports.defaultLeadAnalysis.summary, analysis: analysis || exports.defaultLeadAnalysis.analysis });
|
|
399
309
|
if (conciseSummary) {
|
|
400
310
|
draftAnalysis.conciseSummary = conciseSummary;
|
|
401
311
|
}
|
|
402
|
-
if (jobType) {
|
|
403
|
-
draftAnalysis.jobType = jobType
|
|
312
|
+
if (labels.jobType) {
|
|
313
|
+
draftAnalysis.jobType = labels.jobType;
|
|
404
314
|
}
|
|
405
|
-
if (serviceType) {
|
|
406
|
-
draftAnalysis.serviceType = serviceType
|
|
315
|
+
if (labels.serviceType) {
|
|
316
|
+
draftAnalysis.serviceType = labels.serviceType;
|
|
407
317
|
}
|
|
408
318
|
return draftAnalysis;
|
|
409
319
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnalyzeLead.js","sourceRoot":"","sources":["../../src/prompts/AnalyzeLead.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"AnalyzeLead.js","sourceRoot":"","sources":["../../src/prompts/AnalyzeLead.ts"],"names":[],"mappings":";;;AA6CA,kDAMC;AAyBD,oDAiCC;AAOD,kCAaC;AAQD,kEAEC;AAzID,iDAAkD;AAGlD,6CAAyD;AACzD,sDAAmD;AACnD,yDAAqH;AACrH,6DAAuF;AAEvF,kDAAkD;AAElD;;;;;;GAMG;AACU,QAAA,oBAAoB,GAAG,OAAO,CAAC;AAe5C,SAAS,OAAO,CAAC,OAA+C;IAC5D,mCAAmC;IACnC,OAAO,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,MAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,CAAA,KAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,CAAA,IAAI,SAAS,CAAC;AAC1E,CAAC;AAED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B,EAAC,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;QACnF,MAAM,aAAa,mCACZ,2BAAmB,KACtB,WAAW,EAAE,MAAM,CAAC,WAAW,IAAI,2BAAmB,CAAC,WAAW,EAClE,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,2BAAmB,CAAC,OAAO,EACtD,aAAa,EACT,CAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,QAAQ,GAAG,iBAAiB,EAAE,MAAK,MAAM,IAAI,2BAAmB,CAAC,aAAa,EACjG,OAAO,EAAE,OAAO,IAAI,2BAAmB,CAAC,OAAO,EAC/C,QAAQ,EAAE,QAAQ,IAAI,2BAAmB,CAAC,QAAQ,GACrD,CAAC;QAEF,IAAI,cAAc,EAAE,CAAC;YACjB,aAAa,CAAC,cAAc,GAAG,cAAc,CAAC;QAClD,CAAC;QAED,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACjB,aAAa,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QAC3C,CAAC;QAED,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;YACrB,aAAa,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;QACnD,CAAC;QAED,OAAO,aAAa,CAAC;IACzB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,uFAAuF;QACvF,yFAAyF;QACzF,0FAA0F;QAC1F,MAAM,IAAI,8BAAqB,CAAC,aAAa,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;IAChE,CAAC;AACL,CAAC,CAAC;AAnCW,QAAA,wBAAwB,4BAmCnC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The jobType section shared by the AnalyzeLead and AnalyzeEmail prompts, rendered from the one
|
|
3
|
+
* taxonomy list so the two can never disagree about which trades exist.
|
|
4
|
+
*
|
|
5
|
+
* @param hasBusinessDescription - whether the prompt carries a business description the model can
|
|
6
|
+
* fall back on when a request names no trade.
|
|
7
|
+
*/
|
|
8
|
+
export declare function jobTypeSection(hasBusinessDescription: boolean): string;
|
|
9
|
+
/**
|
|
10
|
+
* Worked examples for the estimating-vendor rule. The SPAM definition names "people offering cost
|
|
11
|
+
* estimation or takeoff services", and on analysis 1.2.0 it held for 75 of the 222 leads the model
|
|
12
|
+
* itself summarised as exactly that; the rest reached contractors as real quote requests.
|
|
13
|
+
*/
|
|
14
|
+
export declare const ESTIMATING_VENDOR_SPAM_EXAMPLES = "\nExamples of estimating and takeoff vendors, which are SPAM even when phrased as a quote or a request to talk:\n- \"We provide accurate material takeoffs and cost estimates for contractors. Send us your plans for a quick turnaround.\" \u2192 SPAM\n- \"Struggling to keep up with bids? Our estimating team prepares detailed takeoffs for roofing and siding projects at low rates.\" \u2192 SPAM\n- \"Hi, I'd like to discuss how our estimation services can help you win more projects.\" \u2192 SPAM";
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ESTIMATING_VENDOR_SPAM_EXAMPLES = void 0;
|
|
4
|
+
exports.jobTypeSection = jobTypeSection;
|
|
5
|
+
/*! Copyright (c) 2026, XAPP AI */
|
|
6
|
+
const LeadAnalysis_1 = require("../models/LeadAnalysis");
|
|
7
|
+
/**
|
|
8
|
+
* The jobType section shared by the AnalyzeLead and AnalyzeEmail prompts, rendered from the one
|
|
9
|
+
* taxonomy list so the two can never disagree about which trades exist.
|
|
10
|
+
*
|
|
11
|
+
* @param hasBusinessDescription - whether the prompt carries a business description the model can
|
|
12
|
+
* fall back on when a request names no trade.
|
|
13
|
+
*/
|
|
14
|
+
function jobTypeSection(hasBusinessDescription) {
|
|
15
|
+
const definitions = LeadAnalysis_1.JOB_TYPE_DEFINITIONS.map(({ value, definition }) => `${value}: ${definition}`).join("\n");
|
|
16
|
+
// 955 callbacks on analysis 1.2.0 were labelled "other" with no trade named; 489 came from
|
|
17
|
+
// businesses whose leads are at least 90% one trade. The description was in the prompt, but
|
|
18
|
+
// nothing told the model to use it here.
|
|
19
|
+
const noTradeNamed = hasBusinessDescription
|
|
20
|
+
? `
|
|
21
|
+
When the request names no specific trade or service (for example "please call me", or a quote request with no detail), use the business description: if it describes a single trade, use that trade's jobType. If the business offers several trades and the request does not say which, use "other".`
|
|
22
|
+
: `
|
|
23
|
+
When the request names no specific trade or service, use "other".`;
|
|
24
|
+
return `jobType definitions are as follows:
|
|
25
|
+
${definitions}
|
|
26
|
+
${noTradeNamed}
|
|
27
|
+
|
|
28
|
+
Examples of requests that fit an existing jobType:
|
|
29
|
+
- "garage floor coating" or "epoxy garage floor" → flooring
|
|
30
|
+
- "install a Level 2 EV charger" or "Tesla charger" → electrical
|
|
31
|
+
- "water heater replacement", "septic tank pumping" or "backflow test" → plumbing
|
|
32
|
+
- "dryer vent cleaning" → hvac
|
|
33
|
+
- "gas fireplace won't light" or "chimney sweep" → fireplace_chimney
|
|
34
|
+
- "French drain" or "wet basement" → drainage_waterproofing`;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Worked examples for the estimating-vendor rule. The SPAM definition names "people offering cost
|
|
38
|
+
* estimation or takeoff services", and on analysis 1.2.0 it held for 75 of the 222 leads the model
|
|
39
|
+
* itself summarised as exactly that; the rest reached contractors as real quote requests.
|
|
40
|
+
*/
|
|
41
|
+
exports.ESTIMATING_VENDOR_SPAM_EXAMPLES = `
|
|
42
|
+
Examples of estimating and takeoff vendors, which are SPAM even when phrased as a quote or a request to talk:
|
|
43
|
+
- "We provide accurate material takeoffs and cost estimates for contractors. Send us your plans for a quick turnaround." → SPAM
|
|
44
|
+
- "Struggling to keep up with bids? Our estimating team prepares detailed takeoffs for roofing and siding projects at low rates." → SPAM
|
|
45
|
+
- "Hi, I'd like to discuss how our estimation services can help you win more projects." → SPAM`;
|
|
46
|
+
//# sourceMappingURL=leadTaxonomyPrompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"leadTaxonomyPrompt.js","sourceRoot":"","sources":["../../src/prompts/leadTaxonomyPrompt.ts"],"names":[],"mappings":";;;AAUA,wCAuBC;AAjCD,kCAAkC;AAClC,yDAA8D;AAE9D;;;;;;GAMG;AACH,SAAgB,cAAc,CAAC,sBAA+B;IAC1D,MAAM,WAAW,GAAG,mCAAoB,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,GAAG,KAAK,KAAK,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAE9G,2FAA2F;IAC3F,4FAA4F;IAC5F,yCAAyC;IACzC,MAAM,YAAY,GAAG,sBAAsB;QACvC,CAAC,CAAC;sSAC4R;QAC9R,CAAC,CAAC;kEACwD,CAAC;IAE/D,OAAO;EACT,WAAW;EACX,YAAY;;;;;;;;4DAQ8C,CAAC;AAC7D,CAAC;AAED;;;;GAIG;AACU,QAAA,+BAA+B,GAAG;;;;+FAIgD,CAAC"}
|