Workflow 01 / Sales
AI Lead Qualification
Every demo request scored against your ICP, routed to HubSpot and answered within a minute.
- Trigger
- Webhook from your form
- Size
- 12 nodes, 5 credentials
- Typical build
- 6 working days
- Tools
- n8n, OpenAI API, HubSpot, Slack, Gmail, Google Sheets
Example scenario: B2B SaaS, about 400 inbound demo requests a month, two SDRs
The problem
Two SDRs read every form by hand. Hot leads waited most of a working day for a reply while students and agencies took up half of the demo calendar, and nobody could say which lead source actually produced revenue.
What the workflow does
The solution
A webhook receives every form submission and an LLM scores it against your written ideal customer profile, explaining the score in one sentence. HubSpot is updated instantly. Leads scoring 70 or more open a deal and alert the sales channel; the rest get a helpful nurture email. Each decision is logged to a sheet that sales reviews weekly to tune the prompt.
The flow
Drawn from the real JSON
Node names, order and branches are read from the exported file at build time, so this diagram can never drift from what n8n will show you. Dashed lines are connections; amber ones leave an IF, a Switch or an error output.
Download n8n JSONScroll sideways to see all branches
Node by node
| # | Node | Type | What it does |
|---|---|---|---|
| 01 | Webhook: Demo Form | Trigger | POST /webhook/lead-intake |
| 02 | Normalize Lead | Transform | Sets 8 fields: email, firstName, lastName, company… |
| 03 | LLM: Score Lead | AI step | Chat completion (gpt-4o-mini), JSON-only output |
| 04 | Parse Score | Transform | Validates the LLM answer. Any invalid output leaves through the error output for manual review. |
| 05 | HubSpot: Upsert Contact | App action | Creates or updates a contact |
| 06 | Slack: Manual Review | App action | Posts a message to #sales-hot |
| 07 | IF: Score ≥ 70 | Branch | True if score >= 70 |
| 08 | HubSpot: Create Deal | App action | Creates a deal |
| 09 | Gmail: Nurture Email | App action | Sends an email |
| 10 | Slack: #sales-hot | App action | Posts a message to #sales-hot |
| 11 | Sheets: Lead Log | App action | Appends a row to the "Leads" tab |
| 12 | Respond 200 | Response | Returns the JSON response to the caller |
How a run goes
Webhook receives the demo form: name, company, size, budget, message and UTM source.
A Set node normalises the email and fields so HubSpot never creates duplicates.
An HTTP Request calls the LLM (3 tries) with the ICP prompt and gets back score, tier, reason and next step as JSON.
A Code node validates the answer: score 0 to 100, a known tier, a reason. Anything invalid leaves through the error output and lands in Slack for manual review.
The HubSpot contact is upserted with ai_lead_score and ai_score_reason custom properties.
IF score is 70 or more: create a deal in "Appointment scheduled" and post a Slack alert.
Otherwise: send a personalised nurture email from Gmail.
Everything is appended to the Lead Log sheet and the form gets a 200 response.
Tools and credentials
Credentials are referenced by name inside the JSON. Create each one in n8n under Credentials, using these names, and the nodes connect automatically.
| Credential name | What you need |
|---|---|
| OpenAI – Flowforge | API key from platform.openai.com |
| Slack – Flowforge Bot | Bot token with the chat:write scope |
| HubSpot – Private App | Private app token with contacts and deals write scopes |
| Gmail – support@ | Google OAuth client with the Gmail API enabled |
| Google Sheets – Ops | Google OAuth client with the Sheets API enabled |
Setup in about 30 minutes
Import the file. In n8n open Workflows, then Import from file, and pick
lead-qualification.json. The workflow arrives inactive.Create the 5 credentials listed above with exactly those names.
Replace the placeholders with your own IDs:
REPLACE_WITH_LEAD_LOG_SHEET_IDin “Sheets: Lead Log”
Adapt it to your business.
- In HubSpot create two contact properties: ai_lead_score (number) and ai_score_reason (multi-line text).
- Edit the system prompt in "LLM: Score Lead" so it describes your own ideal customer: company size, roles, budget, disqualifiers.
- Change the score threshold in "IF: Score ≥ 70" if sales wants a longer or shorter hot list.
- Point your website form at the production webhook URL and set the allowed origin on the webhook node to your domain.
Connect error reporting. Import
error-reporter.jsononce, then open this workflow’s Settings and choose it as the Error workflow. Failed runs are posted to Slack and logged, with a link to retry.Test, then activate. Run the first node with sample data, check each output in the execution view, then switch the workflow to active. Keep the test run for your records.
Example figures for the scenario above, not guarantees
What this kind of build changes
Use it, or have it built for you
The JSON is free to import and adapt. If you would rather have it wired to your own stack and tested on your data, a single flow like this is a fixed-price project.