Reusable AI lead qualification and routing automation built on n8n.
This repository contains a client-ready demo package for an automation that accepts inbound leads, normalizes the data, enriches company context, qualifies the lead with rules or AI-assisted analysis, routes the result, and records an audit-friendly outcome.
The demo is safe to run locally. It uses a local webhook receiver and mock/template persistence paths by default. No secrets or API keys are committed.
The automation can connect to website forms, spreadsheets, CRMs, manual API calls, or webhook sources. A lead moves through this flow:
Lead Intakevalidates the incoming payload and preserves the raw source data.Lead Normalizermaps source-specific fields into the Canonical Lead Object.Company Intelligence Enginepreserves and enriches company context such as industry, size, website, and domain.Lead Qualification Enginescores the lead inrules_only,ai_only, orhybridmode.Routing Enginechooses destinations for qualified, nurture, or disqualified leads.- Dispatchers can send qualified leads to CRM, Slack/email-style notifications, webhook destinations, email tasks, or audit storage.
Master Orchestratorreturns one final payload containing the core lead, intelligence, qualification, routing, dispatch, and audit results.
- Rules-only demo mode: deterministic, no paid provider required, best for client walkthroughs and offline validation.
- Hybrid AI mode: combines deterministic rules with OpenRouter AI analysis. If configured with
ai_failure_policy: "fallback_to_rules", the workflow can still produce a rules-based decision when the AI adapter is unavailable. - Webhook receiver demo: routes qualified demo leads to
target_key: "demo_sink", resolved by the Webhook HTTP Adapter to a local receiver.
Run the validation suite before importing workflows into n8n:
node scripts/demo-doctor.js
node scripts/n8n-runtime-check.js
node tests/e2e/run-e2e.jsThen follow:
Rules-only mode does not require provider credentials.
Hybrid AI mode with OpenRouter requires this variable in the n8n runtime environment:
OPENROUTER_API_KEY
Optional:
OPENROUTER_HTTP_REFERER
Do not paste secrets into workflow JSON, demo config files, or screenshots.
demo/tenant-config.demo.json: safe demo tenant config used by the local demo.demo/sample-client-config.js: editable client-facing config example.demo/leads/qualified.json: expected to qualify and route to webhook.demo/leads/nurture.json: expected to route to nurture.demo/leads/disqualified.json: expected to disqualify.demo-webhook-receiver/receiver.js: local webhook receiver for demo delivery.
Import workflow JSON files into n8n, publish them, then update the workflow IDs used by Master Orchestrator and provider adapters in the demo config:
workflow_refs.*qualification.ai_provider_adapter.workflow_idwebhook_dispatcher.provider_adapter.workflow_id- dispatcher provider adapter workflow IDs
n8n may assign new workflow IDs during import. The demo config must use the IDs from your n8n instance.
A successful demo run returns master.orchestration.completed and includes:
canonical_leadcompany_intelligencequalification_decisionrouting_decision- dispatcher result objects for enabled dispatchers
- persistence/audit result when configured
For expected lead outcomes, see demo/EXPECTED_RESULTS.md.