Quick overview
This workflow receives inbound lead submissions via webhook, standardizes contact fields, uses OpenRouter to score buyer intent, logs each lead to Google Sheets, emails your sales inbox via Gmail for high-priority leads, and returns a structured JSON qualification response.
How it works
- Receives a POST request on a webhook with lead details (name, email, company, message, and optional source).
- Normalizes the inbound payload into consistent lead fields with fallback values.
- Sends the lead details to OpenRouter (GPT-4o-mini or any model of your choice) to generate a JSON score, tier, summary, and suggested reply.
- Parses and validates the AI output into structured fields, applying safe defaults if the response is not valid JSON.
- Appends the qualified lead record to a Google Sheets document in the “Leads” sheet.
- If the score is 7 or higher, sends a notification email with the summary and suggested reply using Gmail.
- Responds to the original webhook caller with a JSON payload containing the qualification status, score, tier, and summary.
Setup
- Copy the webhook Production URL from the webhook trigger and configure your form/app to send a POST JSON payload to it.
- Add an OpenRouter API key credential for the OpenRouter chat model (or replace it with another supported chat model).
- Add Google Sheets and Gmail credentials, replace YOUR_GOOGLE_SHEET_ID with your spreadsheet ID, and ensure a sheet named “Leads” exists.
- Update the recipient address (YOUR_SALES_EMAIL) in the Gmail step to your sales inbox and adjust the high-priority threshold if needed.
Customization
- Adjust the scoring rubric (1–10) in Qualify Inbound Lead (LLM) or change the score >= 7 threshold in Is High-Priority Lead? to match your sales pipeline.
Swap the OpenRouter Chat Model node with an Ollama Chat Model node to run lead scoring 100% locally.
Additional info
Built by Autafy AI Automation (https://autafy.ca). You can also trigger this webhook directly from MCP-compatible AI agents (AIDA, Claude Desktop, Cursor) using our open-source MCP server: https://github.com/autafyai-code/autafy-n8n-mcp