dashboard-schema.md

Part of the marketing-automation-analysis skill

generate-dashboard.py payload schema

When the user opts into a visualization, write a JSON payload to /tmp/marketing_automation_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": "Marketing Automation",
  "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 Marketing Automation · May 20, 2026"
}

Key rules

  • Never hardcode values. Do not type kpis[].value, chart data:[] arrays, or table row values by hand from terminal output. Always derive them from query results captured with bq query --format=json and computed in Python. See the payload-building instructions in SKILL.md's Visualization Prompt section.

  • charts[].script — write the full new Chart(...) call as a JS string. It is injected verbatim into the page <script> block after fivetranColors and chartDefaults are 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.rows cell 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_sections injects raw HTML cards — use for non-Chart.js content, geographic tables, etc.

  • Run python3 generate-dashboard.py --help-schema for the full schema reference.

  • Funnel bar charts: exclude terminal stages. Never include Closed Won or Closed Lost in 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 program_name in a dashboard table, ensure the SQL that feeds the payload uses TRIM(program_name). Marketo program and template 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.

Skills Mixer