Quick overview
Takes a website form webhook enquiry, checks required fields, scores the lead with AI (mock AI in dry-run mode, or your own OpenAI or Anthropic key), logs a row to Google Sheets, and can alert you in Slack and Gmail for hot leads. Dry-run and mock AI on.
How it works
- Receives a POST request on a webhook endpoint containing a lead form payload.
- Validates required fields, normalizes values (including parsing budget), silently accepts honeypot spam, and returns a 422 response for invalid submissions.
- Builds a prompt and sends the lead details to the selected AI provider (mock mode, OpenAI Chat Completions, or Anthropic Messages) to produce a JSON score, tier, summary, red flags, and suggested reply.
- Parses the AI response (or falls back to a rule-based score if the AI output is unusable) and flags leads that meet the hot threshold.
- Prepares a Google Sheets row with the lead details, AI results, and metadata, then either returns a dry-run plan or appends the row to the configured Google Sheets tab.
- If the lead is hot, posts an alert to the configured Slack channel and sends an email alert via Gmail, then responds to the original webhook request with a success JSON response.
Setup
- Configure your lead source to POST to the workflow webhook URL (test or production) and include fields like name, email, message, and an optional honeypot field named
hp_field.
- Create a Google Sheet with a tab (for example, “Leads”) whose header row matches the columns expected by the workflow, then paste the Sheet ID and tab name into the Config node.
- Add Google Sheets credentials in n8n, and (optional) add Slack and Gmail credentials if you want hot-lead alerts.
- Choose your AI mode in Config (mock, openai, or anthropic) and add the corresponding OpenAI or Anthropic credentials if not using mock.
- Update alert destinations in Config (Slack channel name and alert email), then set
dry_run to false when you are ready to write to Google Sheets and send alerts.