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
- 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.
- Normalizes and validates lead inputs, blocks unsafe website URLs, caps batch size, and generates a deduplication key per company and scoring version.
- 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.
- Fetches the lead’s homepage and up to a few key subpages (for example imprint/about/careers/contact) and combines the text for analysis.
- Flags leads that contain prompt-injection-like text and excludes them from AI scoring so they can be reviewed manually in the digest.
- 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.
- 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
- Run the manual “create data table” step once to create the lead_scores table (create-if-not-exists).
- Add an OpenAI credential for the Chat Model node and select the model you want to use.
- Configure SMTP (Email Send) credentials and set the sender, sales, and digest email addresses in the Configuration node.
- 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.
- 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.