Dealops demo AI quote flow
Adds a Dealops 2 demo-only AI quote path that can create an approval-safe Yappatron quote from Salesforce context, packaged fallbacks, benchmark deals, and deterministic pricing rules.
A hard-gated Dealops demo quote path for org 15aaa862-... and opportunity 006Dp00000Zf5HxIAJ.
It bypasses pre-flow term selection and generates a quote for the Yappatron AI demo scenario.
New dealopsDemoQuote.ts supplies SFDC fallback context, similar accounts, historical deals, list-price overrides, minimum-commitment math, and V3 approval preflight.
Voice AI list price is forced to $0.20/min, stale L1 floors can be capped at list, and the minimum commitment becomes 100% usage - Enterprise Support.
The modal streams demo-specific progress and the quote view shows Deal Thesis plus Usage Minimum reasoning in the AI header.
1. Why this exists
- The generic AI quote flow depends on modal-selected pricebook/currency terms.
- The demo needs a fast, reliable Yappatron quote path that looks complete even when live SFDC context is sparse or unavailable.
- The demo quote must not accidentally trigger V3 approvals.
- Gate the special behavior to one Dealops org + one SFDC opportunity.
- Use live Salesforce when possible, then fall back to packaged account, note, task, event, and transcript fixtures.
- Generate a deterministic recommendation instead of relying on a generic LLM pass for the demo package.
2. What changes
The AI quote modal always waited for pricebook and currency terms before starting the SSE quote stream.
The specific Dealops demo org/opportunity skips term selection and posts an empty body to the existing AI quote stream.
| Area | Files | Meaningful change |
|---|---|---|
| Client modal | AIQuoteModal.tsxuseAIQuoteStream.ts |
Looks up organizationId, detects the demo org/opportunity, skips Configure Quote, and allows terms? on the stream request. |
| Demo pipeline | dealopsDemoQuote.tsorchestrator.tsorchestratorStream.ts |
Adds the demo-only context builders, comparable accounts/deals, deterministic recommendation, list-price overrides, progress pauses, and branch points in both normal and SSE orchestrators. |
| Rule validation | validateAiRecommendationAgainstRules.ts |
Adds configurable minimum commitment formulas and optional capL1AtListPrice so list can win when L1 metadata is stale. |
| Finalize / approvals | finalizeAiQuote.ts |
Runs V3 approval preflight before creating the demo quote, injects no-approval terms, and blocks quote creation if approvals are required. |
| Reasoning display | AIReasoningTooltip.tsxCategoryStep.tsx |
Surfaces opportunityContext.dealOverview as Deal Thesis and minimumCommitmentReasoning as Usage Minimum. |
| Pricing spec/UI minimum | minimumCommitmentTable.tsxpricingSpec.json |
Marks enterprise-support as a support offset for the demo org and changes Dealops onboarding minimum percentage from 70 to 100. |
File-level diff map
apps/server/src/dealops2/aiQuoting/pipeline/dealopsDemoQuote.ts+1680apps/server/src/dealops2/aiQuoting/pipeline/orchestratorStream.ts+382 / -205apps/server/src/dealops2/aiQuoting/pipeline/validateAiRecommendationAgainstRules.ts+187 / -35apps/server/src/dealops2/aiQuoting/pipeline/orchestrator.ts+87 / -52apps/server/src/dealops2/aiQuoting/pipeline/finalizeAiQuote.ts+51 / -10apps/client/src/dashboard/PricingFlowV2/components/AIReasoningTooltip.tsx+38 / -93. How it works
start(..., undefined). The stream sends {} as the body.
isDealopsDemoQuote(organizationId, opportunityId) accepts the 18-char and 15-char SFDC opportunity ID variants.
The gate is used in the modal, orchestrators, and finalization path.
Live SFDC fetch uses the org’s Ampersand Salesforce connection.
If that fails, the server logs a warning and builds packaged Yappatron account, notes, tasks, events, and Gong-like summaries.
The demo recommendation returns the fixed launch package: Voice AI, seats, platform access, implementation, Highway integration, and Enterprise Support.
For the target scenario: 250,000 minutes × $0.20 = $50,000/mo; $60,000 support / 12 = $5,000/mo; result is $45,000/mo.
applyDealopsDemoListPriceOverrides()setsvoice-ai-per-minuteto0.2.capL1AtListPricelets list price win when stale L1 is above list.- Validation still rejects prices below the effective L1 floor or above list.
- Injects
subscriptionTerms=12,paymentTerms=net_30,billingFrequency=annual, andautoRenewal=Yes. - Calls
evaluateV3ForPredictionbefore quote creation. - Throws a formatted error if any approval group is required.
4. What it doesn't change
- No new database tables, Prisma migrations, or schema columns.
- No new REST/tRPC surface area is introduced in this diff; it reuses the existing AI quote stream path.
- The generic AI quoting path still requires pre-flow pricebook and currency terms.
- The packaged Yappatron fallback data is gated to the Dealops demo org/opportunity, not general tenant behavior.
- Generic demo-mode virtual display accounts/deals are explicitly disabled for this Dealops demo path.
- The client still renders the normal Configure Quote screen for every non-demo opportunity.
5. Validation
pnpm exec mocha --no-config --node-option import=tsx src/dealops2/aiQuoting/pipeline/__tests__/validateAiRecommendationAgainstRules.test.ts --timeout 10000 --exit
git diff --check origin/main...HEAD
pnpm run typecheck is blocked by upstream src/trpc/router/v3Admin/getPreviewConfig.ts(36,31) on latest main.
| Test area | Coverage added |
|---|---|
validateAiRecommendationAgainstRules.test.ts |
Demo minimum commitment formula, Enterprise Support offset, stale L1 above list, and updated ramp wording. |
resolvePricebookFromTerms.test.ts |
Fallback to modal terms and row name when selector metadata is sparse; stricter missing currency/type cases. |
6. Risks / rollback / open questions
- Hardcoded demo IDs: behavior is intentionally narrow, but the constants exist in both client and server code.
- Large fixture file:
dealopsDemoQuote.tscarries substantial packaged demo context; future demo edits will likely concentrate there. - Approval preflight dependency: finalization depends on V3 approval prediction and CRM spec loading; failure blocks quote creation for the demo path.
- Environment dependency: live SFDC context requires Ampersand env vars, but fallback context keeps the demo usable when that fails.
Fastest rollback is to disable the demo gate by changing or removing the org/opportunity constants, which returns the modal to the generic Configure Quote path. Full rollback is reverting the demo file plus the orchestrator/finalize branches.