Opportunity Scoring

A deal sheet from your own history: win odds with $why, effort in person-days, and reference projects, the numbers an LLM or a gut call would otherwise invent.

Opportunity Scoring: screenshot from the Agent demo
🤖 Agent_predict_estimateCross-vertical
In the demoWin odds via _predict with $why drivers, effort via _estimate in person-days, and matching reference engagements, built live from 1,800 past deals in the agent demo.

The problem

When a new opportunity comes in, the questions are always the same. How likely is this to close? How big is the job? What similar work have we won? Sales answers them with gut feel and whatever the CRM remembers, and an LLM assistant asked the same questions will produce confident numbers it has invented, because it has never seen the firm's deal history.

The history answers all three. Past deals of this shape, from this lead source, with this relationship, closed at a knowable rate. The effort they took is in the records. The references are the won deals that look like this one. The work is conditioning on the right attributes, which is a query, not a model project.

How it works

_predict the outcome of the new deal conditioned on its shape (industry, service line, deal size, lead source, relationship) and read the calibrated win probability with the $why drivers behind it. In the live demo a referral from an existing client predicts about 0.56 to close against a 21% base rate, and switching the lead source to outbound drops it to about 0.24, because the history is what conditions the number. _estimate returns the effort in person-days from the same shape, and a query over won deals returns the reference engagements for the proposal.

The same numbers also work as agent tools: the demo's sales agent calls them in chat and quantifies its recommendation against the unoptimised baseline. Every closed deal writes back into the history, so the next score reflects it without any retraining step.

{
  "from": "engagements",
  "where": {
    "client_industry": "SaaS",
    "client_size": "Mid-market",
    "service_line": "Data Platform",
    "deal_size_band": "L",
    "complexity": "Medium",
    "team_seniority": "balanced",
    "lead_source": "Referral",
    "relationship": "Existing client",
    "competitive": "Sole-source",
    "region": "Helsinki"
  },
  "predict": "outcome",
  "limit": 2,
  "select": [
    "$p",
    "$value",
    "$why"
  ]
}

For the full architecture, see the technology overview. For the broader narrative across multiple use cases, read The Predictive Application.

See it live

This use case runs in the 🤖 Agent demo today. Click through to the live application and inspect the queries that produce the result.

Open the live demo →

Build it with Claude Code

Paste this prompt into Claude Code, or another coding agent, in your own codebase. It runs Aito locally from the Docker image, reads the API docs written for agents, and follows a working reference implementation.

Opportunity scoring: a prompt for Claude Code
Add opportunity scoring to this codebase using Aito, a predictive database. The feature: for each new opportunity, predict the win odds with the reasons, estimate the effort, and find similar past projects as references, from our own deal history.

1. Run Aito locally: `docker pull ghcr.io/aitohq/aito`, then follow https://aito.ai/docker/ to start it with your own API keys (keep them in the environment, never in code).
2. Read https://aito.ai/docs/api/llms.txt for the v2 query shapes before writing any query.
3. Read the use-case guide: https://aito.ai/use-cases/opportunity-scoring/
4. Use this reference implementation as the pattern (schema, data load and queries): https://github.com/AitoDotAI/aito-agent-demo/blob/main/src/app.py and https://github.com/AitoDotAI/aito-agent-demo/blob/main/scripts/seed_sales.py
5. Find the matching tables in this codebase, design the Aito schema for them (links between tables where we have foreign keys), and load a sample.
6. Measure before wiring the UI: hold out recent closed rows and report the calibration per probability band against the base rate, and the error of the effort estimate against the actual effort.
7. In the UI, show the probability ($p) and the reasons ($why) on each row, and flag the rows beyond a threshold I choose for review. Never write the score back as a decision.

Ask me before changing anything outside the new feature.

Frequently asked

How is this different from CRM lead scoring?

Most CRM scoring is a hand-tuned point system: +10 for a referral, +5 for the right title. _predict computes the probability from the actual outcome history, calibrated, with the drivers visible in $why. When the market shifts and referrals stop converting, the score follows the data without anyone re-tuning weights.

How much deal history does this need?

Hundreds of closed deals give usable calibration on the common deal shapes; the demo runs on 1,800. Rare shapes return low confidence rather than a made-up number, which is itself the signal to treat the deal as unscored.

Can the same scoring run inside an AI sales assistant?

Yes. The demo's sales agent calls win odds, effort, and references as tools mid-conversation. The LLM handles the dialogue and drafts the email; the numbers come from Aito queries over the firm's history, so the assistant cites grounded figures instead of inventing them.

What about the effort estimate, is that a separate model?

No. _estimate is the same engine returning a number instead of a class: expected effort_days conditioned on the deal shape. One dataset serves the win odds, the effort, and the references, which is the point of querying instead of building per-question models.