generate-dashboard.py payload schema
When the user opts into a visualization, write a JSON payload to /tmp/hubspot_pipeline_payload.json
with this shape, then run generate-dashboard.py (see SKILL.md for the bash invocation).
All sections are optional except title.
Example payload
{
"title": "HubSpot Sales Pipeline",
"subtitle": "Q2 2026 · Enterprise Pipeline",
"badge": "Data current as of May 20, 2026",
"kpis": [
{"label": "Open Pipeline", "value": "$2.4M", "change": "+12%", "direction": "up", "prior": "Prior quarter: $2.1M"}
],
"charts": [
{
"id": "chart1",
"title": "Pipeline by Stage",
"layout": "half",
"height": 280,
"script": "new Chart(document.getElementById('chart1'), { type: 'bar', data: { labels: [...], datasets: [{ label: 'Pipeline Value', data: [...], backgroundColor: '#0073FF', borderRadius: 4 }] }, options: { ...chartDefaults, scales: { x: { grid: { display: false } }, y: { ticks: { callback: v => '$' + (v/1000).toFixed(0) + 'K' } } } } });"
}
],
"anomalies": {"title": "Deals at Risk", "items": ["..."]},
"table": {
"title": "Stage Funnel",
"columns": [
{"key": "stage", "label": "Stage"},
{"key": "deals", "label": "Deals", "align": "right"},
{"key": "win_rate", "label": "Win Rate", "align": "right"},
{"key": "status", "label": "Status"}
],
"rows": [
{"stage": "Proposal Sent", "deals": "34", "win_rate": "41%", "status": {"html": "<span class='tier-badge tier-winner'>Healthy</span>"}},
{"stage": "Negotiation", "deals": "12", "win_rate": "8%", "status": {"html": "<span class='tier-badge tier-waste'>At Risk</span>"}, "_row_class": "highlight-waste"}
]
},
"custom_sections": [{"title": "Optional Section", "html": "<p>Any HTML</p>"}],
"footer": "Generated by Fivetran HubSpot Sales Pipeline · May 20, 2026"
}
Key rules
-
Never hardcode values. Do not type
kpis[].value, chartdata:[]arrays, or table row values by hand from terminal output. Always derive them from query results captured withbq query --format=jsonand computed in Python. See the payload-building instructions in SKILL.md's Visualization Prompt section. -
charts[].script— write the fullnew Chart(...)call as a JS string. It is injected verbatim into the page<script>block afterfivetranColorsandchartDefaultsare defined, so you can spread those. Write real JavaScript here — callbacks, dynamic per-bar colors, dual axes, tooltip formatters all work because this is actual JS, not a JSON config. -
table.rowscell values: plain string = HTML-escaped;{"html": "..."}= raw HTML (use for tier badges). -
table.rows._row_class:"highlight-waste"(red tint),"highlight-winner"(green tint),"highlight-caution"(yellow tint). -
custom_sectionsinjects raw HTML cards — use for non-Chart.js content, geographic tables, etc. -
Run
python3 generate-dashboard.py --help-schemafor the full schema reference. -
Funnel bar charts: exclude terminal stages. Never include
Closed WonorClosed Lostin a funnel bar chart. Deals can skip mid-funnel stages and arrive at terminal stages directly, so terminal entry counts routinely exceed mid-funnel counts and break the visual funnel shape (bars widen at the bottom). Show outcomes separately — use a doughnut chart for Won/Lost/No Decision proportions and a KPI card for the headline win rate. -
TRIM stage labels in table display. When rendering
pipeline_stage_labelin a dashboard table, ensure the SQL that feeds the payload usesTRIM(pipeline_stage_label). HubSpot stage names can carry trailing whitespace that renders as extra space or misaligns labels across pipelines.
Escape hatch (rare)
Only fall back to writing HTML manually if the page structure itself cannot be expressed as cards / chart grid / table / anomalies — e.g. a multi-page report or embedded iframe app. Custom chart types, axis formatters, and dynamic colors all fit in the script field.