Meet Sunny β an agentic AI solar sales rep that qualifies, sizes, quotes, and books a survey, live in chat.
π FlowZint AI Hackathon 2026 Β· Sales Bot track
Not a chat box over an FAQ. An agent that takes real actions β and proves it sells.
TL;DR β Most "sales bots" answer questions. Sunny runs the funnel. It qualifies a homeowner, sizes a real system, handles objections with grounded facts, builds a quote, and books a site survey β through 6 tools and multi-step tool-calling, with every action streaming into the chat as a bespoke interactive card. It's measured against one number: booked surveys from genuinely qualified homeowners, via a reproducible A/B eval.
| π Live | sunpath-beige.vercel.app β answers even during provider brownouts (automatic failover) |
| π€ Agent | 6 typed tools Β· multi-step tool-calling Β· every action renders as generative UI |
| π Proof | reproducible A/B conversion-lift eval β /results |
| π§― Reliability | 3-layer tool-call defense Β· 12s primary budget β Groq failover β each defense born from a failure hit live |
| β Tests | 26 unit tests pinning the economics engine and the schema hardening |
Qualify β Design β Quote β Book β and an honest "not a fit" when that's the truth.
- Why this exists
- What makes it agentic
- System architecture
- How the agent works
- The 6 tools
- The sales funnel as a state machine
- Generative UI
- Trust by construction
- Reliability engineering
- Does it actually sell? The eval
- Tech stack & why
- Project structure
- Quickstart
- Deployment
- How it maps to the rubric
- Design system
- Roadmap
- Disclaimer & license
Residential solar is a high-consideration, high-ticket sale. The bottleneck is rarely the panels β it's the funnel:
| Stage | Where deals die |
|---|---|
| Qualification | Reps waste hours on renters, tiny bills, and people who won't move β or worse, pressure a bad-fit homeowner and burn trust. |
| Education | Buyers don't understand sizing, incentives, or payback, so they stall. |
| Objections | "Too expensive," "what about my roof," "I'm moving" β answered inconsistently, often with made-up numbers. |
| Conversion | The single highest-value action β booking a site survey β gets lost in a thread of Q&A. |
A generic FAQ chatbot answers questions. It doesn't qualify, it doesn't size, it doesn't quote, and it almost never closes. SunPath's thesis: the win is an agent that drives the funnel end-to-end while staying honest β and can prove it lifts conversion.
flowchart LR
A["π£οΈ Plain-English<br/>homeowner message"] --> B["π§ Sunny reasons<br/>over a sales methodology"]
B --> C{"Decide an action"}
C -->|"qualify"| T1["scoreLead"]
C -->|"size"| T2["recommendSystem"]
C -->|"incentives"| T3["lookupIncentives"]
C -->|"quote"| T4["generateQuote"]
C -->|"close"| T5["bookSurvey"]
C -->|"record"| T6["logToCRM"]
T1 & T2 & T3 & T4 & T5 & T6 --> D["π¦ Structured result"]
D --> E["π΄ Streams in as a<br/>live interactive card"]
D --> B
E --> F["Funnel rail advances:<br/>Qualify β Design β Quote β Book"]
Three things make this an agent, not a wrapper:
- It acts. Tools have side effects (a quote is generated, a survey is booked, the CRM is updated) β not just retrieval.
- It chains. One user turn can fire several tools in sequence (
scoreLeadβrecommendSystemβ reply) via multi-step tool-calling (stopWhen: stepCountIs(10)). - It renders itself. Each tool result streams into the UI as a purpose-built component β the agent's reasoning becomes a tangible artifact.
flowchart TB
subgraph Client["π₯οΈ Browser β Next.js 16 Β· React 19"]
UI["Chat UI<br/>useChat + DefaultChatTransport"]
Cards["Generative-UI cards<br/>score Β· system Β· incentives Β· quote Β· booking"]
Rail["Funnel rail<br/>Qualify β Design β Quote β Book"]
end
subgraph Server["β‘ Route Handler β app/api/chat"]
Stream["streamText( )<br/>multi-step: stopWhen stepCountIs(10)"]
Tools["6 agentic tools<br/>Zod-typed input + execute( )"]
end
subgraph KB["π Knowledge base β lib/"]
Catalog["Catalog Β· incentives<br/>financing Β· objection playbook"]
Econ["Economics engine<br/>sizing Β· ITC Β· payback Β· 25-yr savings"]
end
Model["π§ Gemini Flash β auto-failover β Groq<br/>(env-swap β Claude Opus 4.8)"]
UI -->|"UIMessage stream"| Stream
Stream <-->|"reason Β· generate"| Model
Stream <-->|"tool calls / results"| Tools
Tools --> Catalog
Tools --> Econ
Stream -.->|"streamed tool parts"| Cards
Cards --> Rail
Separation of concerns is deliberate: the model decides what to do, the tools decide how (and enforce the rules), the knowledge base owns the facts, and the UI turns each action into something a homeowner can see and trust. Swapping the model touches exactly one line.
A genuine exchange, captured from the running app:
sequenceDiagram
actor H as π Homeowner
participant UI as Chat UI
participant S as Sunny (agent)
participant T as Tools
participant G as Gemini
H->>UI: "I own my home in CA, bill ~$260/mo, want solar this year"
UI->>S: stream request (system prompt + history)
S->>G: reason
G-->>S: tool call Β· scoreLead(homeowner, 260, CA)
S->>T: execute scoreLead
T-->>S: { score: 83, tier: "hot", qualified: true }
Note over UI: π’ Lead-score gauge streams in (83/100, "Hot lead")
S->>G: continue (multi-step)
G-->>S: tool call Β· recommendSystem(260, CA)
S->>T: execute recommendSystem
T-->>S: { SunPath Whole-Home, net $23,700, 9.6-yr payback, $2,464/yr }
Note over UI: βοΈ System card streams in (grounded numbers)
S-->>H: "Whole-Home, ~$23.7k net after the $10.8k ITC⦠payback ~9.6 yrs"
S->>H: "Cash, loan, or lease? I can put together a quote."
Note what happened: from one plain-English sentence, the agent extracted { homeowner, bill, state }, scored the lead, sized a system with real economics, and drove toward a quote β two tool calls, two cards, one coherent reply.
Every tool is a typed function (Zod input schema + execute) the model can call. The names below are exactly what the model sees.
| Tool | Purpose | Renders as |
|---|---|---|
π― scoreLead |
BANT-style qualification β 0β100 score, tier, what's still missing | Animated score gauge |
βοΈ recommendSystem |
Picks the right package for the bill + computes full economics | System card (net price Β· payback Β· yr-1 savings) |
πΈ lookupIncentives |
Federal ITC (30%) + state-specific programs | Incentives card |
π generateQuote |
Formal quote with a price waterfall + financing + monthly estimate | Quote card (25-yr savings hero) |
π
bookSurvey |
Books the on-site survey β the conversion | Booking confirmation |
ποΈ logToCRM |
Records the lead + pipeline stage | System log line |
Tools are the security and honesty boundary: the model can ask for a price, but only
recommendSystem/generateQuotecan produce one β and they read it from the knowledge base, never invent it.
stateDiagram-v2
[*] --> Qualify
Qualify --> Design: scoreLead passes
Qualify --> Exit: not a fit, honest exit
Design --> Quote: recommendSystem + lookupIncentives
Quote --> Book: generateQuote, interested
Book --> Logged: bookSurvey + logToCRM
Logged --> [*]
Exit --> [*]
The Exit path is a feature, not a bug. Sunny is scored on booked surveys from well-fit homeowners β so a polite "solar won't pay off for you yet" is a success, and the eval rewards it.
This is the showpiece. In most chatbots, a tool call is invisible plumbing. Here, the AI SDK v7 UI message stream carries typed tool parts, and the client maps each to a bespoke React component (with Motion entrance animations):
flowchart LR
TR["Tool result<br/>(typed JSON)"] --> P["UI message part<br/>type: tool-<name>, state: output-available"]
P --> D{"Dispatcher<br/>components/tool-cards.tsx"}
D -->|scoreLead| C1["β±οΈ Score gauge"]
D -->|recommendSystem| C2["βοΈ System card"]
D -->|lookupIncentives| C3["πΈ Incentives"]
D -->|generateQuote| C4["π Quote waterfall"]
D -->|bookSurvey| C5["β
Booking"]
D -->|logToCRM| C6["ποΈ CRM log"]
D -->|"input-available"| SK["β¨ Live skeleton"]
The homeowner doesn't read about a quote β they watch the quote assemble itself, line by line, with a 25-year-savings number that animates in. That tangibility is the difference between "a chatbot told me" and "I saw my numbers."
The fastest way to lose a high-ticket sale is a number that turns out to be wrong. SunPath makes that structurally hard:
flowchart LR
M["π§ Model wants to<br/>state a price / saving / incentive"] --> G{Grounding gate}
G -->|"must call a tool"| T["Tool reads lib/solar-data.ts<br/>+ economics engine"]
T -->|"exact, reproducible figures"| M
G -.->|"β blocked by system prompt"| X["invented numbers"]
OBJ["Homeowner objection"] --> PB["Approved objection playbook<br/>(7 grounded rebuttals)"]
PB --> M
- Numbers come from the catalog + economics engine (gross β βITC β βstate = net; payback = net Γ· annual savings; 25-yr savings with rate inflation). Same inputs β same outputs, every time.
- Objections are answered from an approved playbook of 7 grounded rebuttals (cost, payback, roof, moving, aesthetics, reliability, maintenance) β not improvised.
- Honesty is a hard rule: the system prompt forbids inventing figures, over-promising utility approval, or pushing a bad-fit homeowner.
Free-tier LLM infrastructure fails in real, observed ways. Every row below is a failure we actually hit while building β each one became a shipped defense plus a regression test, not a disclaimer:
| Failure we hit (for real) | Defense in the code |
|---|---|
Gemini free tier: 503 β model experiencing high demand, mid-conversation |
Automatic provider failover (lib/model.ts): the call transparently retries on Groq before any tokens stream β the homeowner just gets an answer |
| A congested primary stalled long enough to eat the route's whole 60s window β killing the turn even though the backup was healthy | 12-second start budget: the primary races a timer on every call; miss it and the fallback serves. Worst-case time-to-first-token is bounded |
429 RESOURCE_EXHAUSTED (daily quota) |
Quota-aware error UX: the route maps 429s to friendly, in-character copy and the chat UI surfaces it with a retry β never a raw stack trace |
Models emit null, "240", or free text where schemas expected enums/numbers (crashed two eval runs) |
Nullable-everything tool schemas β .nullish(), z.coerce.number(), fallback ids β a tool-input validation crash is now structurally impossible |
| Models call tools before collecting prerequisites (sizing with no bill, booking with no contact) | Needs-info steering: the tool returns { needsInfo, message } so the agent asks the homeowner and retries β the turn is guided, not killed |
gpt-oss garbled a tool name: logToCRM<|channel|>commentary β NoSuchToolError |
Tool-call repair hook strips the token leak and re-targets the real tool; genuinely unknown names still fail loudly |
| Token-per-day caps abort long eval runs | Resumable eval: every conversation checkpoints to disk, re-runs skip finished work, and retries honor the provider's try again in Xs hint |
flowchart LR
R["Chat request"] --> P["Primary model<br/>(Gemini, 12s start budget)"]
P -->|"streams"| OK["Reply streams to the homeowner"]
P -->|"429 / 5xx / 401 / 403<br/>or budget exceeded"| F["Groq gpt-oss-120b<br/>(fallback)"]
F -->|"streams"| OK
F -.->|"also down"| E["Friendly, quota-aware<br/>error + retry in the UI"]
Verified live β not just written:
- π Blanked the Google key (surfaces as
403 PERMISSION_DENIED) β failover served the reply. - π©οΈ During a real Gemini brownout, a dead-primary request completed via Groq in 1.9 seconds end-to-end.
- π°οΈ The production deployment rode out that same brownout serving real traffic from the fallback β invisibly to users.
Failover chain: primary (SUNPATH_PROVIDER, default Gemini) β Groq gpt-oss-120b whenever GROQ_API_KEY is set. Kill switch: SUNPATH_FAILOVER=0. 26 unit tests (npm test) pin the economics engine and every schema-hardening lesson above.
Claims are cheap. eval/run.ts is a controlled A/B experiment that measures whether the agent converts better than a baseline FAQ bot.
flowchart LR
P["16 simulated leads<br/>eval/personas.ts<br/>(ground-truth: qualified?)"]
P --> AG["Arm A β Sunny<br/>agent + 6 tools + methodology"]
P --> BL["Arm B β Baseline<br/>plain FAQ bot, no tools"]
AG --> CV["Same lead-simulator drives both<br/>identical discerning-buyer protocol"]
BL --> CV
CV --> MET["Metrics per arm:<br/>β’ completed bookings among qualified leads<br/>β’ stated willingness (for contrast)<br/>β’ false-push rate (unqualified)<br/>β’ qualification accuracy"]
MET --> OUT["eval/results.json β live /results dashboard"]
What counts as a conversion β completed bookings, not compliments. A pilot run scored lead-stated willingness and the metric saturated: a polite FAQ bot hit 100% willingness while being unable to book anything. So the headline metric counts bookings that exist: for Sunny, a verified bookSurvey tool execution (appointment created, name + contact captured); for the baseline, explicit agreement plus a contact captured in-chat β it can still convert, it just has to do real funnel work. Willingness is still recorded per arm and shown alongside, because the saturation itself is a finding.
Why the design is fair: both arms use the same model and the same lead-simulator, with one identical discerning-buyer protocol β leads book only after concrete case-specific numbers, their concern addressed, and a proposed next step, and they hand over contact info when agreeing. The only variable is the rep. The 16 personas carry a ground-truth qualified flag (incl. a renter and a tiny-bill household), so we score not just did it book but did it book the right people.
Run it:
npm run eval # β writes eval/results.json, surfaced at /resultsIt outputs the shape below (run it for live numbers):
β»οΈ Built to survive free tiers: the run is resumable β every finished conversation checkpoints to
eval/.eval-cache.json, so a quota interruption resumes instead of restarting, and retries honor the provider'stry again in Xshint. The harness is provider-agnostic (AGENT_PROVIDER/LEAD_PROVIDER/AGENT_MODEL/LEAD_MODEL), so the full 32-conversation A/B runs free on Groq;PERSONA_LIMITsupports smaller smoke runs.
Every dependency is bleeding-edge on purpose β and chosen for a reason, not novelty.
| Layer | Choice | Why |
|---|---|---|
| Framework | Next.js 16 (App Router, Turbopack) Β· React 19.2 | Streaming-native route handlers; Server Components; one runtime for API + UI |
| Agent runtime | Vercel AI SDK v7 (streamText, stopWhen: stepCountIs, convertToModelMessages) |
First-class multi-step tool-calling + provider-agnostic (swap models in 1 line) |
| Generative UI | AI SDK UI message stream β typed tool-* parts β React |
Tool calls become interactive components, not invisible plumbing |
| Model | Gemini Flash Β· auto-failover β Groq gpt-oss-120b Β· env-swap β Claude Opus 4.8 |
Strong tool-calling at zero cost, resilient to free-tier outages, trivially upgraded |
| Schemas | Zod 4 | Typed tool inputs the model must satisfy; doubles as runtime validation |
| Styling | Tailwind v4 (@theme) + Motion 12 |
A custom design system, not a component library; tasteful, GPU-friendly motion |
| Icons / type | lucide-react Β· Fraunces display + Geist | Distinctive, non-generic visual identity |
Note for reviewers: the codebase was written against the installed type definitions (AI SDK v7, Next 16, Zod 4 differ materially from older majors) β not from memory. It builds clean on the first try (
npm run build).
sunpath/
βββ app/
β βββ api/chat/route.ts # the agent loop β streamText + tools + multi-step
β βββ page.tsx # the chat experience (+ measured-lift badge)
β βββ opengraph-image.tsx # generated social share card (next/og)
β βββ results/page.tsx # conversion-lift dashboard (reads eval/results.json)
βββ components/
β βββ chat.tsx # useChat client Β· message + tool-part rendering Β· funnel rail
β βββ tool-cards.tsx # generative UI β one bespoke card per tool
β βββ ticker-number.tsx # count-up numerals (score, savings) β reduced-motion aware
β βββ stage-rail.tsx # Qualify β Design β Quote β Book progress
β βββ atmosphere.tsx # starfield dusk + solar-glow backdrop
βββ lib/
β βββ agent-prompt.ts # Sunny's system prompt (composed from the KB)
β βββ model.ts # provider selection + automatic failover chain
β βββ tools.ts # the 6 agent tools (hardened Zod schemas + execute)
β βββ tools.test.ts # regression tests for the schema hardening
β βββ solar-data.ts # catalog Β· incentives Β· financing Β· objections Β· economics
β βββ solar-data.test.ts # economics engine unit tests
β βββ tool-types.ts # shared types mirroring tool outputs
β βββ utils.ts # formatting + cn()
βββ eval/
β βββ personas.ts # 16 simulated leads (ground-truth qualified flag)
β βββ run.ts # the conversion-lift harness (resumable, provider-agnostic)
βββ DEMO.md # shot-for-shot demo-video script
# 1. Install
npm install
# 2. Add a model key (free β Google AI Studio: https://aistudio.google.com/apikey)
cp .env.example .env.local # paste your key as GOOGLE_GENERATIVE_AI_API_KEY
# 3. Run
npm run dev # β http://localhost:3000
# 4. (optional) run the test suite β economics engine + tool-schema hardening
npm test
# 5. (optional) generate the conversion-lift numbers β free on Groq (console.groq.com)
# add GROQ_API_KEY to .env.local, then:
AGENT_PROVIDER=groq LEAD_PROVIDER=groq LEAD_MODEL=llama-3.3-70b-versatile npm run evalBuild: npm run build. The app needs GOOGLE_GENERATIVE_AI_API_KEY (default provider); adding GROQ_API_KEY enables automatic failover.
GitHub-linked Vercel import (auto-redeploys on push):
- vercel.com/new β import this repo.
- Framework auto-detects Next.js β keep defaults.
- Add env vars:
GOOGLE_GENERATIVE_AI_API_KEY(primary model) and, optionally,GROQ_API_KEY(turns on automatic failover). Keys are not in the repo, by design. - Deploy β public URL in ~90s.
| Criterion | Weight | How SunPath earns it |
|---|---|---|
| Model Innovation | 30% | Genuine multi-step agentic tool-use + generative UI β the agent acts and renders itself, not a Q&A wrapper |
| Real-World Applicability | 25% | A measurable business outcome (booking lift) on a real funnel, grounded in defensible economics |
| Technical Architecture | 25% | Clean separation (agent / tools / data / UI / eval), typed end-to-end, public repo, builds clean on a 2026 stack |
| Documentation | 20% | This README + a shot-for-shot demo script + a self-explanatory /results dashboard + a reproducible eval |
A deliberate, non-generic aesthetic β no Inter, no purple-on-white:
- Canvas: deep dusk sky with a warm solar glow rising from the horizon, drifting energy rings, a fine grain overlay.
- Type: Fraunces (optical display serif) against Geist β warmth + precision.
- Accent: a sun/ember gradient; a single cool sky tone; a leaf green reserved for savings.
- Motion: staggered card entrances, an animating score ring, a celebratory booking check β high-impact moments,
prefers-reduced-motionrespected.
- Publish the headline conversion-lift number on
/results(full A/B run in progress β the harness is resumable) - Shot-for-shot demo script (
DEMO.md) β video recording next - Final demo on Claude Opus 4.8 (already wired β
SUNPATH_PROVIDER=anthropic) - Bilingual (AR/EN) toggle β the agent already replies in the user's language
- Voice input (Web Speech) for a hands-free funnel
- Real CRM / calendar integration behind the
logToCRM/bookSurveytools
SunPath Solar is a fictional installer. The company, catalog, and customers are invented; all figures are realistic US-market estimates used to keep the demo honest, and are confirmed at survey in the narrative. Nothing here is solar financial advice.
Licensed under the MIT License β see LICENSE.
Built for the FlowZint AI Hackathon 2026 Β· Sales Bot track
{ "metric": "completed-booking-v2: β¦", "agentic": { "convQualifiedPct": __, "willingQualifiedPct": __, "falsePushPct": __, "qualAccuracyPct": __ }, "baseline": { "convQualifiedPct": __, "willingQualifiedPct": __, "falsePushPct": __, "qualAccuracyPct": __ }, "liftPoints": __, "relativeLiftPct": __ }