Back to all articles
Why I Built a Rule Engine Before Teaching It to Learn
SalesforceRevOpsBuild In PublicDeal RiskAIAppExchange

Why I Built a Rule Engine Before Teaching It to Learn

When building a native Salesforce deal-risk tool, we chose a rule engine over ML. Here is the real reason, and what it taught us about AI adoption in CRM.

Mitesh Jain June 24, 2026 7 min read

When we started building a native Salesforce deal-risk tool, the obvious first question was: rule engine or machine learning?

Everyone in the AI space gives you the same answer. Train a model on your closed-won and closed-lost history. Let it find patterns humans miss. Let the data decide what risk looks like.

It is a compelling pitch. We went a different direction and it turned out to be the right call. Here is why.

The ML trap: confidence without context

Picture this. You deploy a deal-scoring model. The sales team logs in for the first time, eager to see which deals are at risk. The model returns a verdict on every open opportunity.

Every single one: Medium Risk.

Reps shrug. Leaders lose interest within three weeks. The tool gets quietly switched off and filed under did not work.

This is not a hypothetical. It is a pattern we saw repeatedly before building our own solution.

The model was not broken. It was starving.

ML deal-scoring models need one thing above everything else: years of clean, labelled, closed-deal history. Closed-won records with consistent field hygiene. Closed-lost records with honest loss reasons. Enough volume that the model can find genuine signal, not noise dressed up as patterns.

Most Salesforce orgs do not have that. They have a few quarters of data, some of it clean, most of it inconsistent. The model ingests it, finds nothing meaningful, and hedges every prediction toward the centre of the distribution. Medium. Medium. Medium.

The tool is not lying. It genuinely does not know yet.

What rules give you that ML cannot: day-one value

We decided to name risk ourselves. Not because rules are smarter than ML, they are not, but because rules are honest in a way a cold-start model cannot be.

We picked eight signals already sitting in every Salesforce org:

  1. Days since last activity: No completed task or event in 14 or more days. The conversation has gone quiet.

  2. Close date push count: A close date pushed twice or more is a deal telling you something the forecast is not.

  3. Stage regression: Any backward stage move. A deal that has moved to Needs Analysis from Proposal is not progressing.

  4. Open high-priority cases: An unresolved support fire on the account while a deal is in negotiation is a material risk signal.

  5. Contact engagement ratio: If fewer than half the opportunity contacts have been active in the last 30 days, someone is not talking to the right people.

  6. Next step blank: An open deal with no defined next action, within 30 days of its close date, is a deal nobody is actually driving.

  7. Amount drop: A deal amount that has dropped more than 20% signals scope reduction, negotiation pressure, or both.

  8. Competitor flagged: A populated competitor field means the deal is contested. That context belongs in every risk assessment.

The scoring logic is simple. Two or more HIGH conditions trigger a High Risk tier. One HIGH condition, or a significant amount drop, or a blank next step alone triggers Medium. Everything else is Low.

No training data required. Works on day one, in any org, regardless of how long they have been on Salesforce.

The explainability dividend

Here is the thing nobody tells you about rule engines: the explainability is not just a nice-to-have. It is the entire adoption strategy.

When a rep sees High Risk on a deal, their first question is not what does that mean. It is why. And they need an answer they can defend in a forecast call.

A rule engine gives them that instantly. This deal is High Risk because there has been no activity in 18 days, the close date has slipped twice, and the next step is blank with 12 days until close date.

That, a rep will act on. They can argue with it. They can say the activity gap is because the champion was on holiday and update accordingly. They can use it to coach their AE.

A black-box ML score, even a good one, does not give you that. 62% at risk is a number you cannot interrogate, cannot explain to your VP in a QBR, and cannot use to run a coaching conversation.

Explainability is not a feature. It is the difference between a tool that gets adopted and one that gets abandoned.

When we ran it for the first time

When we processed 117 open opportunities through the rule engine in a cold-start batch run, a few things stood out.

The Apex batch completed in roughly three minutes: 117 opportunities, 16 chunks, zero errors, zero duplicate briefs on rerun. Every brief was factually accurate, referenced specific signal counts, and included a concrete recommended action.

One High Risk brief read: This deal is classified as High Risk due to 4 open high-priority support cases; no next step defined; only 0% of contacts engaged in the last 30 days. To clear the flag: coordinate with support to resolve the open cases, and add a next step to keep the deal moving.

A Low Risk brief on a healthy deal read: Activity is recent, a clear next step is in place, the stage is progressing, the close date is holding steady. This deal is healthy, keep up the momentum.

No ML. No training data. No external API calls. Just Salesforce data, read by Apex, turned into something a sales manager would actually say.

Does ML have a role? Absolutely.

We are not anti-ML. The system is designed to layer in AI narrative generation once Einstein is configured, a prompt template that takes the signal map and writes a richer brief than Apex string interpolation alone can produce.

The architecture degrades gracefully: if Einstein is not configured or hits its callout limit, the Apex engine handles the narrative automatically. The signal scoring never depends on AI. Only the prose layer does.

That is the right separation. Rules for the logic that must be explainable. AI for the layer that benefits from natural language.

Start with rules. Add intelligence when you have the data and the trust to back it up.

The broader lesson

The AI adoption conversation in Salesforce right now is almost entirely focused on Agentforce, prompt templates, and generative AI. Those are genuinely powerful tools.

But the question underneath all of them is the same one we faced: what does your AI act on?

If the answer is messy, inconsistent CRM data, the AI will be confidently wrong at machine speed. If the answer is clean, named, explainable signals, you get something a team will actually use.

The rule engine was not a compromise on our way to ML. It was the thing that made everything else possible: real signal, honest outputs, and a team that trusted the system enough to act on it.

Build explainable first. The intelligence follows.

We are building a native Salesforce deal-risk tool, free, no external APIs, works day one. More soon.

MJ

Mitesh Jain

Salesforce consultant with 10 years of Sales and Service Cloud implementation experience.

Want to Learn More About Our Salesforce Solutions?

Explore how our expertise can help your business grow.

Get in Touch