Score, route, and reply to inbound leads with GPT-4o-mini, Gmail and Sheets
Ready for 3.0Ready for 3.0. This template uses no nodes that n8n 3.0 removes. No removed nodes, versions or helpers found. Static check, last run 2026-10-19.
Nodes used (13)
- Webhook
n8n-nodes-base.webhook - Respond to Webhook
n8n-nodes-base.respondToWebhook - Edit Fields (Set)
n8n-nodes-base.set - Filter
n8n-nodes-base.filter - AI Agent
@n8n/n8n-nodes-langchain.agent - OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi - Structured Output Parser
@n8n/n8n-nodes-langchain.outputParserStructured - Code
n8n-nodes-base.code - Switch
n8n-nodes-base.switch - Gmail
n8n-nodes-base.gmail - Telegram
n8n-nodes-base.telegram - Google Sheets
n8n-nodes-base.googleSheets - Schedule Trigger
n8n-nodes-base.scheduleTrigger
What it does
Quick overview This workflow receives inbound leads via a webhook, filters spam, and uses OpenAI GPT-4o-mini to score and draft replies. It routes hot leads to Gmail and Telegram alerts, logs all leads to Google Sheets, and sends a weekly Telegram digest from the sheet. How it works 1. Receives a POST request from a form via a webhook and immediately returns a JSON acknowledgment to the submitter. 2. Normalizes incoming lead fields (name, email, message, etc.) and filters out spam and empty submissions using email validation, disposable-domain checks, a honeypot field, and a required message. 3. Sends the cleaned lead details to OpenAI (GPT-4o-mini) to score budget, authority, need, and timeline against a structured JSON schema and to generate a summary, reasons, language code, and a suggested reply. 4. Calculates a transparent 0–100 lead score from the AI sub-scores and adds bonus points for a business email domain and a provided phone number. 5. Routes the lead into Hot (≥70), Warm (40–69), or Cold (<40) and logs the lead (with tier, score, summary, reasons, and next steps) to a Google Sheets “Leads” tab. 6. For Hot leads, sends a Gmail alert and a Telegram message to the sales team and creates a Gmail draft reply to the lead; for Warm leads, creates only the Gmail draft reply. 7. If AI scoring fails, flags the lead for manual review, appends it to Google Sheets with tier “Review,” and pings Telegram with the error details. 8. Every Monday at 9:00, reads the last 7 days of rows from Google Sheets, composes a weekly summary (counts by tier, average score, and top hot leads), and sends it to Telegram. Setup 1. Add OpenAI credentials and customize the GPT-4o-mini system message to describe your business, ideal customer, and qualification rules. 2. Add Gmail credentials and replace the alert recipient email address used for hot-lead notifications. 3. Add Telegram credentials and set your Telegram chat ID for hot-lead pings, manual-review alerts, and the weekly digest. 4. Add Google Sheets credentials, set the spreadsheet ID, and create a “Leads” sheet with columns matching the fields written by the logging steps (for example: Timestamp, Lead ID, Name, Email, Company, Phone, Score, Tier, Next step, AI summary, Reasons, Budget, Timeline, Source, Message). 5. Copy the webhook URL for the “lead-intake” endpoint and configure your form tool to POST submissions to it (including a message field and optional honeypot field). Requirements - OpenAI API key (GPT-4o-mini: fractions of a cent per lead) - Google credentials with Gmail and Google Sheets scopes - A Google Sheet with a "Leads" tab and this header row: Timestamp | Lead ID | Name | Email | Company | Phone | Score | Tier | Next step | AI summary | Reasons | Budget | Timeline | Source | Message - Telegram bot token and your chat ID (free, via @BotFather) - Any form builder that can POST JSON to a webhook (Tally, Typeform, Webflow, WordPress, Framer, Jotform or a plain HTML form) Customization - Thresholds live in the Switch (Hot 70+, Warm 40-69); weights and bonuses in the "Compute Lead Score" Code node - Map extra form fields in "Set Lead Fields"; adjust the spam rules in the Filter (add your own honeypot field name) - Swap Telegram for Slack or SMS, send the draft automatically once you trust the replies, change the digest day or time, or switch the model to GPT-4o for harder cases Additional info The workflow is built to run unattended: the form always gets an instant reply, spam never reaches the AI, the final score is plain arithmetic over the model's four criteria, and a failed AI call flags the lead for manual review instead of dropping it. Drafts are never sent automatically - review them in Gmail and hit send. Test it before wiring up your form: curl -X POST https://YOUR-N8N/webhook/lead-intake -H "Content-Type: application/json" -d '{"name":"Anna Berg","email":"[email protected]","company":"Berg Trading","phone":"+47 900 00 000","budget":"5k EUR","timeline":"this month",