AWS Builder Center
Lead Scoring Examples: Build an Explainable B2B Lead Scoring Model with AWS Lambda

Lead Scoring Examples: Build an Explainable B2B Lead Scoring Model with AWS Lambda

Build an explainable B2B lead scoring model with AWS Lambda. Score three example enquiries by buyer fit and buying intent, then store the reasons alongside each score.

Series: CRM (9 articles)

  1. 2
    Lead Scoring Examples: Build an Explainable B2B Lead Scoring Model with AWS Lambda This article
Love to Learn Tech especially AI things.
Two enquiries arrive on the same afternoon. One comes from a company in your target market asking for a CRM integration demo. The other comes from a company in the same market that is still researching options. Both fit your services, but they call for different follow-up.
An explainable scoring model makes that difference visible. This example uses a small ruleset in AWS Lambda and stores the score, reasons, and rules version in DynamoDB.

1. Score fit and intent separately

Buyer fit measures how well the company and request match the team’s services. Buying intent measures the actions or timing the prospect has expressed. Keep both values visible to sales. The total helps sort a queue, while the component scores explain how to respond.
Dimension
Rule
Points
Fit
Requested service is supported
+30
Fit
Company is in a target segment
+20
Intent
Prospect asks for a demo
+25
Intent
Prospect states a timeline of 30 days or less
+15
Intent
Prospect views pricing within the last seven days
+10
Each rule applies once. A missing timeline earns zero timeline points and can be stored as unknown. Count a pricing visit only when it can be associated with the enquiry through an appropriate first-party signal. Repeated visits do not add extra points in this model.

2. Apply the rules to three enquiries

Enquiry
Fit
Intent
Total
Suggested next step
Target-segment company asks for a supported CRM integration, requests a demo, needs a 30-day start, and recently viewed pricing
50
50
100
Prioritize for sales follow-up
Target-segment company requests a supported CRM build and recently viewed pricing, with no demo request or stated timeline
50
10
60
Ask about timeline and project scope
Company outside the target segment requests a demo for an unsupported service and states a 30-day timeline
0
40
40
Send to triage to confirm the requirement
The third enquiry shows why the action should consider both scores. Strong urgency does not make an unsupported request suitable for the same sales queue. Start with a rule such as fit of at least 30 and intent of at least 25 for priority follow-up, then evaluate it against sales outcomes.

3. Store the reasons that produced the score

The Lambda worker reads normalized fields from the lead, evaluates the rules, and writes a record like this:
{
"leadId": "lead-demo-17",
"fit": 50,
"intent": 10,
"total": 60,
"reasonCodes": [
"SUPPORTED_SERVICE",
"TARGET_SEGMENT",
"RECENT_PRICING_VISIT"
],
"rulesVersion": "v1",
"inputRevision": 4
}
On a retry, recompute the score from the current inputs. Avoid incrementing a stored total each time an event arrives. Use a conditional write so an older input revision cannot replace a newer result. When rules change, recalculate against the active version and keep the version available for reporting.
If the seven-day pricing signal can expire without any new lead activity, run a scheduled refresh or recalculate when the queue is read. Otherwise, a stale visit can keep a lead ranked above newer enquiries.

4. Compare the model with actual sales outcomes

Track qualified meetings and sales acceptance by fit and intent band. Review leads that sales upgraded or downgraded and record why. If many low-intent, high-fit leads become qualified after one conversation, the team can adjust its follow-up policy for that group without changing what the score means.
Test duplicate events, missing fields, an older revision arriving late, and a pricing visit aging out of the scoring window. A salesperson should be able to open any scored lead and see which facts drove its priority.

Series: CRM (9 articles)

  1. 2
    Lead Scoring Examples: Build an Explainable B2B Lead Scoring Model with AWS Lambda This article
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article