Lead Qualification
A Mastra workflow triages and qualifies leads received through a JSON API or Attio CRM. It researches each company, compares the findings with your sales team's ideal customer profile (ICP), and produces a score and qualification outcome with supporting sources. Results go to a local report or Attio; uncertain cases go to human review.
Why we built this
Sales teams need to know whether incoming leads match their ICP. Manually researching every company and checking it against the qualification criteria is tedious, so we built this template to automate the initial research and triage.
Demo
Prerequisites
- OpenAI API key: set
OPENAI_API_KEYfor the default GPT-6 Luna research provider, which searches company sources and checks extracted facts. - Attio workspace token: optional. Set
ATTIO_API_TOKENand generate the list mapping to use Attio output. Attio input also requiresATTIO_WEBHOOK_SECRET. See Attio configuration.
Quickstart π
- Create the project
- Run
npx create-mastra@latest lead-qualification --template lead-qualification, thencd lead-qualificationandnpm install.
- Run
- Add your API key
- Run
cp .env.example .envand fill in the key described under Prerequisites. Both providers default tolocal.
- Run
- Start the server
- Run
npm run devand open Mastra Studio. - Submit the request below, then open the returned
statusUrlto read the assessment andbusiness.state. Inspect the run under Workflows β lead-intake in Studio. The result explains the company's fit and flags facts that need review.
- Run
curl http://localhost:4111/lead-qualification/events \
-H 'Content-Type: application/json' \
-d '{"version":1,"type":"lead.received","eventId":"company-1","lead":{"reference":"mastra","domain":"mastra.ai"}}'Try it out
- Add a genuine
lead.inquiryusing the input contract. Its date and request type contribute to buying intent; a company's own demo offer doesn't. - For an uncertain result, open Tools β reviewLead in Studio and copy the current packet's references from the run response. Approve, reject, or request changes, then read
/lead-qualification/runs/<runId>/outputfor the local Markdown report. - Select Attio input and output to qualify new Triage entries and review uncertain cases by moving Stage.
- Resend an event with the same ID to retrieve its existing run. To research a completed lead again, submit a new ID and its latest
supersedesAssessmentId.
Customization
- Ask your coding agent: βExplore the code and propose a plan to qualify companies for my target market. Adjust the criteria, score weights, and review policy while preserving sourced evidence.β Start with qualification configuration.
- Choose separate input and output providers, add a research source, or adapt reports and telemetry. Operations covers deployment and recovery.
About Mastra templates
This is an official Mastra template. Official templates live in the Mastra monorepo and are synchronized to standalone repositories.
