See llms.txt for all machine-readable content.

Back to Templates

Score and tier inbound B2B leads with OpenAI website research and email

Quick overview

This workflow accepts inbound B2B leads via a secured webhook or n8n form, researches the company website, scores fit/signal/reach with OpenAI, stores results in an n8n data table, emails sales instantly for tier A leads, and sends a weekday digest for tier B and flagged leads.

How it works

  1. Receives a new lead via a header-authenticated webhook, a basic-authenticated n8n form, or runs every weekday at 08:00 to process retries and send a digest.
  2. Normalizes and validates lead inputs, blocks unsafe website URLs, caps batch size, and generates a deduplication key per company and scoring version.
  3. Logs each new lead to the n8n Data Table (lead_scores), skips leads already scored with the same key, and enforces a daily limit on OpenAI calls.
  4. Fetches the lead’s homepage and up to a few key subpages (for example imprint/about/careers/contact) and combines the text for analysis.
  5. Flags leads that contain prompt-injection-like text and excludes them from AI scoring so they can be reviewed manually in the digest.
  6. Sends the cleaned lead data and website text to OpenAI with a structured schema, calculates a reproducible total score and tier, and stores the scoring breakdown and reasoning in the data table.
  7. Emails sales immediately for tier A leads, and on weekday mornings emails a digest of new tier B and flagged leads while marking digested rows to avoid duplicates.

Setup

  1. Run the manual “create data table” step once to create the lead_scores table (create-if-not-exists).
  2. Add an OpenAI credential for the Chat Model node and select the model you want to use.
  3. Configure SMTP (Email Send) credentials and set the sender, sales, and digest email addresses in the Configuration node.
  4. Set up and secure intake by configuring Header Auth for the webhook and Basic Auth for the form, then copy the webhook URL into your source system.
  5. Review and customize the ideal customer profile, tier thresholds, daily AI limit, and retry limits in the Configuration node before activating the workflow.

Requirements

  • n8n with Data Tables (tested with n8n 2.42)
  • An OpenAI API key or any other chat model
  • An SMTP account for the alert mails

Customization

  • Ideal customer, tiers and limits are all set in the Configuration node. Change scoring_version when you change the profile or prompt.
  • Swap the chat model for Anthropic, Mistral, Azure OpenAI or Ollama (local, nothing leaves your server).
  • Enable Send to CRM (optional) or replace it with the HubSpot, Pipedrive or Odoo node.