Repository navigation
Expand file tree
/
Copy pathbuild_deck.js
More file actions
489 lines (413 loc) · 24.8 KB
/
Copy pathbuild_deck.js
File metadata and controls
489 lines (413 loc) · 24.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
/**
* build_deck.js — Renders the leadership slide deck from deck_data.json
*
* Usage: node build_deck.js [path-to-deck_data.json] [output-pptx-path]
* Defaults: ./deck_data.json -> ./Customer_Call_Intelligence_Run_Summary.pptx
*
* Requires: npm install -g pptxgenjs react-icons react react-dom sharp
*/
const fs = require("fs");
const path = require("path");
const pptxgen = require("pptxgenjs");
const React = require("react");
const ReactDOMServer = require("react-dom/server");
const sharp = require("sharp");
const {
FaExclamationTriangle, FaHeadset, FaShieldAlt, FaChartLine,
FaBolt, FaCogs, FaUsers, FaCheckCircle,
FaFileInvoiceDollar, FaServer, FaBullhorn, FaSearch, FaUserPlus
} = require("react-icons/fa");
// ============================================================================
// ARGS
// ============================================================================
const dataPath = process.argv[2] || "deck_data.json";
const outPath = process.argv[3] || "Customer_Call_Intelligence_Run_Summary.pptx";
if (!fs.existsSync(dataPath)) {
console.error(`ERROR: data file not found: ${dataPath}`);
process.exit(1);
}
const data = JSON.parse(fs.readFileSync(dataPath, "utf-8"));
// ============================================================================
// PALETTE — "Midnight Executive" (navy / ice blue / white) with amber/red
// accent for risk callouts.
// ============================================================================
const NAVY = "1E2761";
const ICE = "CADCFC";
const WHITE = "FFFFFF";
const SLATE = "475569";
const MUTED = "64748B";
const TEAL = "0D9488";
const AMBER = "D97706";
const RED = "B91C1C";
const LIGHT_BG = "F4F6FB";
const makeShadow = () => ({ type: "outer", color: "000000", blur: 6, offset: 2, angle: 45, opacity: 0.10 });
// ============================================================================
// ICON GENERATION — render react-icons to PNG, cached in ./icons/
// ============================================================================
const ICON_DIR = path.join(__dirname, "icons");
function renderIconSvg(IconComponent, color, size = 256) {
return ReactDOMServer.renderToStaticMarkup(
React.createElement(IconComponent, { color, size: String(size) })
);
}
async function iconToPng(IconComponent, color, name) {
const outFile = path.join(ICON_DIR, `${name}.png`);
if (fs.existsSync(outFile)) return; // cache
const svg = renderIconSvg(IconComponent, color, 256);
const pngBuffer = await sharp(Buffer.from(svg)).png().toBuffer();
fs.writeFileSync(outFile, pngBuffer);
}
async function generateIcons() {
fs.mkdirSync(ICON_DIR, { recursive: true });
const white = "#FFFFFF";
const navy = "#1E2761";
const teal = "#0D9488";
const amber = "#D97706";
const red = "#B91C1C";
await iconToPng(FaExclamationTriangle, white, "warn_white");
await iconToPng(FaExclamationTriangle, red, "warn_red");
await iconToPng(FaHeadset, white, "headset_white");
await iconToPng(FaShieldAlt, white, "shield_white");
await iconToPng(FaChartLine, white, "chart_white");
await iconToPng(FaChartLine, navy, "chart_navy");
await iconToPng(FaBolt, white, "bolt_white");
await iconToPng(FaBolt, amber, "bolt_amber");
await iconToPng(FaBolt, navy, "bolt_navy");
await iconToPng(FaCogs, white, "cogs_white");
await iconToPng(FaCogs, navy, "cogs_navy");
await iconToPng(FaUsers, white, "users_white");
await iconToPng(FaUsers, navy, "users_navy");
await iconToPng(FaCheckCircle, teal, "check_teal");
await iconToPng(FaCheckCircle, white, "check_white");
await iconToPng(FaFileInvoiceDollar, white, "invoice_white");
await iconToPng(FaServer, white, "server_white");
await iconToPng(FaServer, navy, "server_navy");
await iconToPng(FaBullhorn, white, "bullhorn_white");
await iconToPng(FaSearch, white, "search_white");
await iconToPng(FaSearch, navy, "search_navy");
await iconToPng(FaHeadset, navy, "headset_navy");
await iconToPng(FaUserPlus, white, "userplus_white");
}
const icon = (name) => path.join(ICON_DIR, `${name}.png`);
// ============================================================================
// HELPERS — safe accessors with fallbacks for missing LLM fields
// ============================================================================
function arr(x, fallback = []) {
return Array.isArray(x) && x.length ? x : fallback;
}
function str(x, fallback = "") {
return (typeof x === "string" && x.trim()) ? x : fallback;
}
// ============================================================================
// MAIN
// ============================================================================
async function main() {
await generateIcons();
const sc = data.slide_content || {};
const stats = data.statistics || {};
let pres = new pptxgen();
pres.layout = "LAYOUT_WIDE"; // 13.3 x 7.5
pres.author = "Transcript Intelligence Agent";
pres.title = "Customer Call Intelligence — Run Summary";
// --------------------------------------------------------------------
// SLIDE 1 — TITLE
// --------------------------------------------------------------------
{
let s = pres.addSlide();
s.background = { color: NAVY };
s.addText("Customer Call Intelligence", {
x: 0.7, y: 2.5, w: 11.9, h: 1.1, fontSize: 44, bold: true, color: WHITE, fontFace: "Cambria", margin: 0,
});
s.addText(str(sc.title_subtitle, `Findings from ${stats.total_calls || "N"} Calls — Run Analysis`), {
x: 0.7, y: 3.6, w: 11.9, h: 0.6, fontSize: 20, color: ICE, fontFace: "Calibri", margin: 0,
});
s.addShape(pres.shapes.LINE, {
x: 0.7, y: 4.6, w: 4.0, h: 0, line: { color: ICE, width: 0.75 },
});
s.addText([
{ text: "Prepared for Product & Engineering Leadership", options: { breakLine: true } },
{ text: "Agent: Transcript Intelligence Agent v3 (Hybrid Local + LLM)" },
], { x: 0.7, y: 6.5, w: 9, h: 0.7, fontSize: 12, color: ICE, fontFace: "Calibri", margin: 0 });
s.addText(str(data.run_date, ""), { x: 11.3, y: 6.7, w: 1.6, h: 0.4, fontSize: 12, color: ICE, align: "right", fontFace: "Calibri", margin: 0 });
}
// --------------------------------------------------------------------
// SLIDE 2 — EXECUTIVE SUMMARY
// --------------------------------------------------------------------
{
let s = pres.addSlide();
s.background = { color: WHITE };
s.addText("Executive Summary", { x: 0.7, y: 0.45, w: 11.9, h: 0.7, fontSize: 32, bold: true, color: NAVY, fontFace: "Cambria", margin: 0 });
const headlineStats = arr(sc.headline_stats, [
{ value: String(stats.total_calls || "-"), label: "Calls Analyzed", sub: `${stats.calls_with_errors || 0} load error(s)` },
{ value: String((stats.call_types || {}).support || "-"), label: "Support Calls", sub: "Customer-reported issues" },
{ value: String(stats.risk_count != null ? stats.risk_count : "-"), label: "Risk Signals Flagged", sub: "Across all calls" },
{ value: String(stats.total_speakers || "-"), label: "Unique Speakers", sub: `${(stats.total_word_count || 0).toLocaleString()} words analyzed` },
]).slice(0, 4);
headlineStats.forEach((st, i) => {
const x = 0.7 + i * 3.05;
s.addShape(pres.shapes.ROUNDED_RECTANGLE, {
x, y: 1.35, w: 2.85, h: 1.7, fill: { color: LIGHT_BG }, rectRadius: 0.08, shadow: makeShadow(),
});
s.addText(str(st.value, "-"), { x, y: 1.45, w: 2.85, h: 0.85, fontSize: 40, bold: true, color: NAVY, align: "center", fontFace: "Cambria", margin: 0 });
s.addText(str(st.label, ""), { x, y: 2.35, w: 2.85, h: 0.35, fontSize: 13, bold: true, color: SLATE, align: "center", fontFace: "Calibri", margin: 0 });
s.addText(str(st.sub, ""), { x, y: 2.68, w: 2.85, h: 0.35, fontSize: 9.5, color: MUTED, align: "center", fontFace: "Calibri", margin: 0 });
});
// Narrative summary card
s.addShape(pres.shapes.ROUNDED_RECTANGLE, {
x: 0.7, y: 3.35, w: 11.9, h: 3.4, fill: { color: NAVY }, rectRadius: 0.08, shadow: makeShadow(),
});
s.addImage({ path: icon("search_white"), x: 0.95, y: 3.6, w: 0.4, h: 0.4 });
s.addText("What the data is telling us", { x: 1.5, y: 3.58, w: 8, h: 0.45, fontSize: 16, bold: true, color: WHITE, fontFace: "Calibri", margin: 0 });
const keyFindings = arr(sc.key_findings, [str(data.executive_summary, "No executive summary available.")]);
const findingTextArr = keyFindings.map((f, idx) => ({
text: f, options: { bullet: true, breakLine: idx < keyFindings.length - 1, paraSpaceAfter: 8 }
}));
s.addText(findingTextArr, { x: 1.5, y: 4.05, w: 11.0, h: 2.6, fontSize: 13, color: ICE, fontFace: "Calibri", margin: 0, lineSpacingMultiple: 1.05 });
s.addNotes("Open by framing this as a run summary. Walk through the headline stats, then the key findings card.");
}
// --------------------------------------------------------------------
// SLIDE 3 — TOPIC & SENTIMENT LANDSCAPE
// --------------------------------------------------------------------
{
let s = pres.addSlide();
s.background = { color: WHITE };
s.addText("Topic & Sentiment Landscape", { x: 0.7, y: 0.45, w: 11.9, h: 0.7, fontSize: 32, bold: true, color: NAVY, fontFace: "Cambria", margin: 0 });
// Topic distribution - pie chart (sourced directly from statistics, not LLM)
const topicDist = stats.topic_distribution || {};
const topicLabels = Object.keys(topicDist);
const topicValues = Object.values(topicDist);
s.addText("Primary Topic Distribution", { x: 0.7, y: 1.25, w: 6, h: 0.4, fontSize: 16, bold: true, color: SLATE, fontFace: "Calibri", margin: 0 });
if (topicLabels.length) {
s.addChart(pres.charts.PIE, [{
name: "Topics", labels: topicLabels, values: topicValues,
}], {
x: 0.5, y: 1.7, w: 6.0, h: 4.6,
chartColors: [NAVY, TEAL, "5B7FD4", AMBER, MUTED, "8B5CF6", "EC4899", "10B981"],
showPercent: true, showLegend: true, legendPos: "b",
chartArea: { fill: { color: "FFFFFF" } },
dataLabelColor: WHITE, dataLabelFontSize: 11,
});
} else {
s.addText("No topic distribution data available.", { x: 0.7, y: 3.5, w: 6, h: 0.5, fontSize: 12, color: MUTED, fontFace: "Calibri", margin: 0 });
}
// Call type breakdown (sourced directly from statistics)
const callTypes = stats.call_types || {};
const ctLabels = Object.keys(callTypes);
const ctValues = Object.values(callTypes);
s.addText("Call Type Breakdown", { x: 7.0, y: 1.25, w: 5.6, h: 0.4, fontSize: 16, bold: true, color: SLATE, fontFace: "Calibri", margin: 0 });
if (ctLabels.length) {
s.addChart(pres.charts.BAR, [{
name: "Calls", labels: ctLabels, values: ctValues,
}], {
x: 7.0, y: 1.7, w: 5.6, h: 2.1, barDir: "bar",
chartColors: [NAVY], showValue: true, dataLabelPosition: "outEnd", dataLabelColor: SLATE,
catAxisLabelColor: MUTED, valAxisLabelColor: MUTED,
valGridLine: { color: "E2E8F0", size: 0.5 }, catGridLine: { style: "none" },
showLegend: false, chartArea: { fill: { color: "FFFFFF" } },
});
}
// Sentiment by call type (sourced directly from statistics)
const sentByType = stats.avg_sentiment_by_call_type || {};
const sLabels = Object.keys(sentByType);
const sValues = Object.values(sentByType);
s.addText("Avg. Sentiment Score by Call Type (-5 to +5)", { x: 7.0, y: 4.0, w: 5.6, h: 0.4, fontSize: 16, bold: true, color: SLATE, fontFace: "Calibri", margin: 0 });
if (sLabels.length) {
s.addChart(pres.charts.BAR, [{
name: "Sentiment", labels: sLabels, values: sValues,
}], {
x: 7.0, y: 4.45, w: 5.6, h: 2.0, barDir: "col",
chartColors: [TEAL], showValue: true, dataLabelPosition: "outEnd", dataLabelColor: SLATE,
catAxisLabelColor: MUTED, valAxisLabelColor: MUTED,
valAxisMaxVal: 5.5, valAxisMinVal: -5,
valGridLine: { color: "E2E8F0", size: 0.5 }, catGridLine: { style: "none" },
showLegend: false, chartArea: { fill: { color: "FFFFFF" } },
});
}
s.addNotes("Topic/call-type/sentiment charts are sourced directly from the statistics block, not the LLM, so they always match the underlying numbers exactly.");
}
// --------------------------------------------------------------------
// SLIDE 4 — TOP RISK THEME
// --------------------------------------------------------------------
{
let s = pres.addSlide();
s.background = { color: WHITE };
const theme = sc.top_risk_theme || {};
s.addText(str(theme.slide_title, "Risk Spotlight: Top Theme"), { x: 0.7, y: 0.45, w: 11.9, h: 0.7, fontSize: 30, bold: true, color: NAVY, fontFace: "Cambria", margin: 0 });
// Left: severity card
s.addShape(pres.shapes.ROUNDED_RECTANGLE, { x: 0.7, y: 1.35, w: 4.0, h: 5.5, fill: { color: RED }, rectRadius: 0.08, shadow: makeShadow() });
s.addImage({ path: icon("warn_white"), x: 1.0, y: 1.6, w: 0.55, h: 0.55 });
s.addText(str(theme.headline_stat, "-"), { x: 1.0, y: 2.25, w: 3.4, h: 0.9, fontSize: 20, bold: true, color: WHITE, fontFace: "Cambria", margin: 0 });
s.addText(str(theme.headline_label, ""), { x: 1.0, y: 3.15, w: 3.4, h: 0.6, fontSize: 13, color: WHITE, fontFace: "Calibri", margin: 0 });
const facts = arr(theme.facts, []);
const factTextArr = facts.map((f, idx) => ({
text: f, options: { bullet: true, breakLine: idx < facts.length - 1, paraSpaceAfter: 6 }
}));
if (factTextArr.length) {
s.addText(factTextArr, { x: 1.0, y: 3.95, w: 3.5, h: 2.7, fontSize: 11, color: WHITE, fontFace: "Calibri", margin: 0, valign: "top", lineSpacingMultiple: 1.05, autoFit: false, shrinkText: false });
}
// Right: customer-by-customer impact table
s.addText("Customer Impact Tracker", { x: 5.0, y: 1.35, w: 7.6, h: 0.4, fontSize: 16, bold: true, color: SLATE, fontFace: "Calibri", margin: 0 });
const impactRows = arr(theme.impact_table, []);
if (impactRows.length) {
const headerRow = [
{ text: "Customer", options: { fill: { color: NAVY }, color: WHITE, bold: true } },
{ text: "Call Type", options: { fill: { color: NAVY }, color: WHITE, bold: true } },
{ text: "Signal", options: { fill: { color: NAVY }, color: WHITE, bold: true } },
{ text: "Status / Risk", options: { fill: { color: NAVY }, color: WHITE, bold: true } },
];
const dataRows = impactRows.slice(0, 4).map(r => [
str(r.customer, "-"), str(r.call_type, "-"), str(r.signal, "-"), str(r.status, "-")
]);
const rowH = [0.45, ...dataRows.map(() => 0.85)];
s.addTable([headerRow, ...dataRows], {
x: 5.0, y: 1.85, w: 7.6, colW: [1.9, 1.6, 2.9, 1.2],
fontSize: 10.5, color: SLATE, fontFace: "Calibri",
border: { pt: 0.5, color: "E2E8F0" },
rowH, valign: "middle",
});
} else {
s.addText("No customer impact data available for this theme.", { x: 5.0, y: 1.9, w: 7.6, h: 0.5, fontSize: 12, color: MUTED, fontFace: "Calibri", margin: 0 });
}
// Bottom callout
const urgencyNote = str(theme.highest_urgency_note, "");
if (urgencyNote) {
s.addShape(pres.shapes.ROUNDED_RECTANGLE, { x: 5.0, y: 5.85, w: 7.6, h: 1.0, fill: { color: LIGHT_BG }, rectRadius: 0.08 });
s.addImage({ path: icon("bolt_amber"), x: 5.25, y: 6.12, w: 0.45, h: 0.45 });
s.addText(urgencyNote, {
x: 5.85, y: 5.95, w: 6.55, h: 0.8, fontSize: 11.5, color: SLATE, fontFace: "Calibri", margin: 0, valign: "middle",
});
}
s.addNotes("Top risk theme, derived from the LLM's cross-call synthesis using per-call digests.");
}
// --------------------------------------------------------------------
// SLIDE 5 — SECONDARY RISK THEME
// --------------------------------------------------------------------
{
let s = pres.addSlide();
s.background = { color: WHITE };
const theme = sc.secondary_risk_theme || {};
s.addText(str(theme.slide_title, "Risk Spotlight: Secondary Theme"), { x: 0.7, y: 0.45, w: 11.9, h: 0.7, fontSize: 28, bold: true, color: NAVY, fontFace: "Cambria", margin: 0 });
// Left big stat
s.addShape(pres.shapes.ROUNDED_RECTANGLE, { x: 0.7, y: 1.4, w: 3.6, h: 5.4, fill: { color: NAVY }, rectRadius: 0.08, shadow: makeShadow() });
s.addImage({ path: icon("bolt_white"), x: 1.0, y: 1.65, w: 0.5, h: 0.5 });
s.addText(str(theme.headline_stat, "-"), { x: 1.0, y: 2.25, w: 3.0, h: 0.9, fontSize: 20, bold: true, color: WHITE, fontFace: "Cambria", margin: 0 });
s.addText(str(theme.headline_label, ""), { x: 1.0, y: 3.15, w: 3.0, h: 0.6, fontSize: 12, color: ICE, fontFace: "Calibri", margin: 0 });
const facts = arr(theme.facts, []);
const factTextArr = facts.map((f, idx) => ({
text: f, options: { bullet: true, breakLine: idx < facts.length - 1, color: ICE, paraSpaceAfter: 6 }
}));
if (factTextArr.length) {
s.addText(factTextArr, { x: 1.0, y: 3.85, w: 3.2, h: 2.8, fontSize: 10.5, fontFace: "Calibri", margin: 0, valign: "top", lineSpacingMultiple: 1.05, autoFit: false, shrinkText: false });
}
// Right - commitments / response cards
s.addText("Key Facts & Commitments", { x: 4.6, y: 1.4, w: 8.0, h: 0.4, fontSize: 16, bold: true, color: SLATE, fontFace: "Calibri", margin: 0 });
const commitments = arr(theme.commitments, []).slice(0, 3);
const cardIcons = ["bolt_amber", "check_white", "check_white"];
const cardCircleColors = [NAVY, NAVY, NAVY];
commitments.forEach((c, i) => {
const y = 1.95 + i * 1.65;
s.addShape(pres.shapes.ROUNDED_RECTANGLE, { x: 4.6, y, w: 8.0, h: 1.45, fill: { color: LIGHT_BG }, rectRadius: 0.08, shadow: makeShadow() });
s.addShape(pres.shapes.OVAL, { x: 4.85, y: y + 0.35, w: 0.75, h: 0.75, fill: { color: cardCircleColors[i % cardCircleColors.length] } });
s.addImage({ path: icon(cardIcons[i % cardIcons.length]), x: 5.05, y: y + 0.55, w: 0.35, h: 0.35 });
s.addText(str(c.title, "-"), { x: 5.8, y: y + 0.2, w: 6.6, h: 0.4, fontSize: 14, bold: true, color: NAVY, fontFace: "Calibri", margin: 0 });
s.addText(str(c.body, ""), { x: 5.8, y: y + 0.6, w: 6.6, h: 0.7, fontSize: 11.5, color: SLATE, fontFace: "Calibri", margin: 0 });
});
if (!commitments.length) {
s.addText("No additional facts available for this theme.", { x: 4.6, y: 2.0, w: 8.0, h: 0.5, fontSize: 12, color: MUTED, fontFace: "Calibri", margin: 0 });
}
s.addNotes("Secondary risk theme. If this is an open/active issue, this is the slide to ask for a live status update on before presenting.");
}
// --------------------------------------------------------------------
// SLIDE 6 — EXPANSION & POSITIVE SIGNALS
// --------------------------------------------------------------------
{
let s = pres.addSlide();
s.background = { color: WHITE };
s.addText("Beyond Risk: Expansion & Retention Signals", { x: 0.7, y: 0.45, w: 11.9, h: 0.7, fontSize: 30, bold: true, color: NAVY, fontFace: "Cambria", margin: 0 });
const highlights = arr(sc.expansion_highlights, []).slice(0, 3);
const cardColors = [NAVY, TEAL, "5B7FD4"];
const cardIcons = ["invoice_white", "shield_white", "userplus_white"];
if (highlights.length) {
highlights.forEach((c, i) => {
const x = 0.7 + i * 4.05;
const color = cardColors[i % cardColors.length];
s.addShape(pres.shapes.ROUNDED_RECTANGLE, { x, y: 1.4, w: 3.8, h: 4.6, fill: { color: LIGHT_BG }, rectRadius: 0.08, shadow: makeShadow() });
s.addShape(pres.shapes.OVAL, { x: x + 0.3, y: 1.7, w: 0.7, h: 0.7, fill: { color } });
s.addImage({ path: icon(cardIcons[i % cardIcons.length]), x: x + 0.475, y: 1.875, w: 0.35, h: 0.35 });
s.addText(str(c.title, "-"), { x: x + 0.3, y: 2.55, w: 3.2, h: 0.6, fontSize: 16, bold: true, color: NAVY, fontFace: "Calibri", margin: 0 });
s.addText(str(c.body, ""), { x: x + 0.3, y: 3.2, w: 3.2, h: 2.4, fontSize: 12, color: SLATE, fontFace: "Calibri", margin: 0, lineSpacingMultiple: 1.1 });
if (str(c.tag, "")) {
s.addShape(pres.shapes.ROUNDED_RECTANGLE, { x: x + 0.3, y: 5.55, w: 2.6, h: 0.35, fill: { color }, rectRadius: 0.18 });
s.addText(c.tag, { x: x + 0.3, y: 5.55, w: 2.6, h: 0.35, fontSize: 10, bold: true, color: WHITE, align: "center", valign: "middle", fontFace: "Calibri", margin: 0 });
}
});
} else {
s.addText("No expansion/retention highlights identified in this run.", { x: 0.7, y: 1.6, w: 11.9, h: 0.5, fontSize: 13, color: MUTED, fontFace: "Calibri", margin: 0 });
}
s.addNotes("Positive signals from this batch -- upsell, reference customers, new-logo onboarding health.");
}
// --------------------------------------------------------------------
// SLIDE 7 — STAKEHOLDER RECOMMENDATIONS
// --------------------------------------------------------------------
{
let s = pres.addSlide();
s.background = { color: WHITE };
s.addText("Recommended Actions by Stakeholder", { x: 0.7, y: 0.45, w: 11.9, h: 0.7, fontSize: 32, bold: true, color: NAVY, fontFace: "Cambria", margin: 0 });
const sa = data.stakeholder_actions || {};
const quadDefs = [
{ key: "Sales", icon: "chart_white", color: NAVY },
{ key: "Product", icon: "bullhorn_white", color: TEAL },
{ key: "Support", icon: "headset_white", color: "5B7FD4" },
{ key: "Engineering", icon: "server_white", color: AMBER },
];
quadDefs.forEach((q, i) => {
const items = arr(sa[q.key], [`No actions identified for ${q.key}.`]);
const col = i % 2, row = Math.floor(i / 2);
const x = 0.7 + col * 6.05, y = 1.35 + row * 3.0;
s.addShape(pres.shapes.ROUNDED_RECTANGLE, { x, y, w: 5.85, h: 2.75, fill: { color: LIGHT_BG }, rectRadius: 0.08, shadow: makeShadow() });
s.addShape(pres.shapes.OVAL, { x: x + 0.25, y: y + 0.25, w: 0.6, h: 0.6, fill: { color: q.color } });
s.addImage({ path: icon(q.icon), x: x + 0.4, y: y + 0.4, w: 0.3, h: 0.3 });
s.addText(q.key, { x: x + 1.0, y: y + 0.22, w: 3, h: 0.55, fontSize: 18, bold: true, color: NAVY, fontFace: "Calibri", margin: 0, valign: "middle" });
const itemTextArr = items.slice(0, 3).map((it, idx) => ({
text: it, options: { bullet: true, breakLine: idx < Math.min(items.length, 3) - 1, paraSpaceAfter: 6 }
}));
s.addText(itemTextArr, {
x: x + 0.3, y: y + 0.95, w: 5.3, h: 1.7, fontSize: 11.5, color: SLATE, fontFace: "Calibri", margin: 0, lineSpacingMultiple: 1.05,
});
});
s.addNotes("Stakeholder action items, sourced from the cross-call insights' stakeholder_actions block.");
}
// --------------------------------------------------------------------
// SLIDE 8 — METHODOLOGY / APPENDIX
// --------------------------------------------------------------------
{
let s = pres.addSlide();
s.background = { color: NAVY };
s.addText("Appendix: How This Analysis Was Built", { x: 0.7, y: 0.45, w: 11.9, h: 0.7, fontSize: 30, bold: true, color: WHITE, fontFace: "Cambria", margin: 0 });
const pipeline = [
{ icon: "search_navy", title: "Local: Topic Mapping", body: "Embedding-similarity match (all-MiniLM-L6-v2) of granular call tags \u2192 fixed taxonomy. Cached for reuse." },
{ icon: "chart_navy", title: "Local: Sentiment", body: "DistilBERT sentiment, overall + per-sentence \u201ckey moments\u201d, rescaled to a -5..+5 range." },
{ icon: "users_navy", title: "Local: Action Items & Risks", body: "spaCy NER for action-item entities (gated by verb heuristics); regex keyword scoring for risk signals." },
{ icon: "cogs_navy", title: "Local: Call Type & Engagement", body: "Rule-based call-type detection (email domain + title/summary keywords); pure-Python speaker turn/word-share stats." },
{ icon: "bolt_navy", title: "LLM: Cross-Call Insights", body: "Single LLM call synthesizes aggregated statistics + per-call digests into executive summary, risks, opportunities, and slide content." },
];
pipeline.forEach((p, i) => {
const x = 0.7 + i * 2.5;
s.addShape(pres.shapes.ROUNDED_RECTANGLE, { x, y: 1.5, w: 2.3, h: 4.6, fill: { color: "2A3672" }, rectRadius: 0.08 });
s.addShape(pres.shapes.OVAL, { x: x + 0.75, y: 1.8, w: 0.8, h: 0.8, fill: { color: ICE } });
s.addImage({ path: icon(p.icon), x: x + 0.95, y: 2.0, w: 0.4, h: 0.4 });
s.addText(p.title, { x: x + 0.15, y: 2.75, w: 2.0, h: 0.7, fontSize: 13, bold: true, color: WHITE, align: "center", fontFace: "Calibri", margin: 0 });
s.addText(p.body, { x: x + 0.15, y: 3.5, w: 2.0, h: 2.4, fontSize: 10, color: ICE, align: "center", fontFace: "Calibri", margin: 0, lineSpacingMultiple: 1.05 });
});
s.addText(str(sc.appendix_note, "Cost model: most per-call analysis runs on local, free, offline models. The cross-call LLM step is the only network-dependent call and costs O(1) regardless of dataset size."), {
x: 0.7, y: 6.5, w: 11.9, h: 0.6, fontSize: 11, italic: true, color: ICE, fontFace: "Calibri", margin: 0,
});
s.addNotes("Use this slide if asked 'how did you build this.' Emphasize the hybrid local-vs-LLM cost philosophy.");
}
await pres.writeFile({ fileName: outPath });
console.log(`Deck written to: ${outPath}`);
}
main().catch(err => {
console.error(err);
process.exit(1);
});