CORTEXFLOW · FREE FOREVER

Automation

Speed-to-Lead Rescue

↓ Download workflow JSON

Import in n8n: Workflows → ⋯ → Import from file, then add your credentials. Free download with a free account.

How it works

  1. Webhook — Lead Intake catches every lead — missed-call events (Twilio/VAPI) or any web form POST a JSON payload {name, phone, email, message, source} to /lead-in.
  2. Normalize Lead cleans the input — trims whitespace and strips non-dialable characters from the phone number, so every downstream step gets consistent data.
  3. CONFIG — Lead Business holds your settings — business name, Twilio number, Telegram chat ID, sheet ID, booking link, hot-score threshold, SMS template, and services list in one editable node.
  4. Log Lead — Status NEW writes to Google Sheets — one row per lead with status NEW and empty score/priority columns.
  5. Send Welcome SMS — Twilio fires the instant text-back — the lead gets your welcome SMS within ~60 seconds of their missed call or form submit, before they call a competitor.
  6. Update Sheet — Status CONTACTED flips the status — the row moves from NEW to CONTACTED the moment the SMS goes out.
  7. AI Agent — Qualify Lead scores the lead — GPT-4o-mini reads the lead’s message and business context, then returns a strict structured verdict through the Structured Output Parser: lead_score 0–100, urgency HOT / WARM / COLD, summary, suggested_next_step, best_contact_time.
  8. Parse Qualification flattens the AI output — pulls the score, urgency, summary, next step, and contact time into clean fields for the rest of the flow.
  9. Update Sheet — Status QUALIFIED fills in the row — the sheet row moves to QUALIFIED with lead_score, priority (HOT / WARM / COLD), and ai_summary filled in.
  10. IF — Hot Lead? routes the flow — leads scoring at or above HOT_SCORE_THRESHOLD (75) go down the hot path; everything else continues quietly.
  11. Telegram — Hot Lead Alert pings you instantly — 🔥 owner alert with name, score, phone, summary, and next step so you can call back immediately.
  12. Merge — Combine Branches rejoins the paths — hot and non-hot leads merge back into one stream.
  13. Telegram — Lead Summary sends the final recap — name, phone, source, status, priority, score, summary, next step, and best contact time in one Telegram message.

Set up steps

You’ll need:

  • n8n (self-hosted or cloud) with webhook access
  • A Twilio account — sign up for a free trial at https://www.twilio.com/try-twilio (gives you a phone number, an Account SID, and an Auth Token)
  • An OpenAI account — get an API key at https://platform.openai.com/signup (used with the gpt-4o-mini model)
  • A Telegram bot — create one with BotFather at https://t.me/BotFather (send /newbot, copy the token) and get your chat ID
  • A Google account with a Google Sheet — create the sheet with a Google Sheets OAuth2 credential in n8n
  1. Create your Google Sheet — make a sheet named Leads with exactly these column headers in row 1: timestamp, name, phone, email, message, source, status, lead_score, priority, ai_summary. Share it with the Google service account n8n uses.
  2. Download the workflow JSON using the download button on this page.
  3. In n8n, go to Workflows → ⋯ → Import from file and select the JSON.
  4. Create your Twilio credential — in n8n go to Credentials → New → HTTP Basic Auth, use your Twilio Account SID as the username and your Twilio Auth Token as the password, save. Then open Send Welcome SMS — Twilio and select this credential; replace PASTE_YOUR_TWILIO_ACCOUNT_SID in the request URL with your real Account SID.
  5. Create your OpenAI credential — in n8n go to Credentials → New → OpenAI, paste your API key, save. Open OpenAI Chat Model — Qualify and select it.
  6. Create your Google Sheets credential — complete OAuth2 for Google Sheets, then open Log Lead — Status NEW, Update Sheet — Status CONTACTED, and Update Sheet — Status QUALIFIED and select it.
  7. Create your Telegram credential — in n8n go to Credentials → New → Telegram, paste your bot token, save. Open Telegram — Hot Lead Alert and Telegram — Lead Summary and select it.
  8. Fill in CONFIG — Lead Business — open the node and replace every placeholder: BUSINESS_NAME, TWILIO_FROM_NUMBER (your Twilio number), OWNER_TELEGRAM_CHAT_ID, SHEET_DOC_ID (the sheet’s ID from its URL), BOOKING_LINK, and SERVICES_LIST. Adjust HOT_SCORE_THRESHOLD (default 75) and WELCOME_SMS_TEMPLATE to taste.
  9. Activate the workflow (toggle, top-right), then test with: curl -X POST https://YOUR-N8N-DOMAIN/webhook/lead-in -H 'Content-Type: application/json' -d '{"name":"Ravi Sharma","phone":"+15551234567","email":"[email protected]","message":"AC stopped working, need someone today","source":"missed-call"}'. You should get the SMS on the test phone, a new QUALIFIED row in your sheet, and two Telegram messages.

Approval note: this workflow sends SMS automatically to anyone who submits a lead. Before going live, point it at your own phone number and confirm the welcome message, timing, and qualification verdicts look right — and check that your Twilio sender number is allowed to message your market’s numbers (some countries require registered sender IDs).

Customize it

  • Business-hours gating — add an IF node after Normalize Lead that checks the current hour (e.g. 9:00–19:00): during hours, keep the instant-SMS path; outside hours, swap the body to an “after hours” template that promises a morning callback. Edit WELCOME_SMS_TEMPLATE or add a second template in the CONFIG node.
  • Swap the SMS provider — replace Send Welcome SMS — Twilio with any other sender: a Vonage/Msg91 HTTP Request node (same form-body shape), or n8n’s native Twilio node if you prefer the UI over the raw API call.
  • Second follow-up workflow — build a companion workflow on a Schedule Trigger (daily, e.g. 10:00): read the sheet for rows stuck at CONTACTED for 24h+ without a QUALIFIED outcome, send a gentle follow-up SMS (“Still need help with…? Reply YES and I’ll call you in 10 minutes”), then flip status to FOLLOWED_UP.
  • Tune the hot threshold — if you’re drowning in 🔥 alerts, raise HOT_SCORE_THRESHOLD in the CONFIG node to 85; if you’re missing good jobs, drop it to 65.

Workflow nodes

This workflow is built from 15 nodes. Here's what each one does:

#NodeTypeWhat it does
1 Webhook — Lead Intake Webhook Entry point — receives incoming HTTP requests that trigger the workflow.
2 Normalize Lead Code Runs custom JavaScript to transform, filter, or compute data between steps.
3 CONFIG — Lead Business Set Holds editable configuration values — fill in your own settings here before activating.
4 Log Lead — Status NEW Google Sheets Reads from or writes to a Google Sheet — this workflow's log and state store.
5 Send Welcome SMS — Twilio HTTP Request Calls an external API or webhook endpoint.
6 Update Sheet — Status CONTACTED Google Sheets Reads from or writes to a Google Sheet — this workflow's log and state store.
7 AI Agent — Qualify Lead AI Agent The AI brain — reasons over the task and calls tools to get it done.
8 OpenAI Chat Model — Qualify OpenAI Chat Model The language model powering the AI agent.
9 Structured Output Parser — Qualification Structured Output Parser Forces the AI to return clean, structured JSON instead of free text.
10 Parse Qualification Code Runs custom JavaScript to transform, filter, or compute data between steps.
11 Update Sheet — Status QUALIFIED Google Sheets Reads from or writes to a Google Sheet — this workflow's log and state store.
12 IF — Hot Lead? IF Splits the flow into branches based on a condition.
13 Telegram — Hot Lead Alert Telegram Sends you a Telegram message or alert.
14 Merge — Combine Branches Merge Combines the outputs of two or more branches back into one flow.
15 Telegram — Lead Summary Telegram Sends you a Telegram message or alert.

Setup instructions

1. Add your credentials

In n8n go to Credentials → New, create each credential below, then open the named node and select it:

NodeCredential to add
Log Lead — Status NEW Google Sheets OAuth2
Send Welcome SMS — Twilio HTTP Basic Auth
Update Sheet — Status CONTACTED Google Sheets OAuth2
OpenAI Chat Model — Qualify OpenAI API
Update Sheet — Status QUALIFIED Google Sheets OAuth2
Telegram — Hot Lead Alert Telegram Bot API
Telegram — Lead Summary Telegram Bot API

2. Fill in your config values

Open the config node listed below and replace each placeholder with your own value before activating the workflow:

NodeFieldWhat to paste
CONFIG — Lead Business BUSINESS_NAME PASTE_YOUR_BUSINESS_NAME
Your business name
CONFIG — Lead Business TWILIO_FROM_NUMBER PASTE_YOUR_TWILIO_NUMBER
Your twilio number
CONFIG — Lead Business OWNER_TELEGRAM_CHAT_ID PASTE_YOUR_TELEGRAM_CHAT_ID
Your telegram chat id
CONFIG — Lead Business SHEET_DOC_ID PASTE_YOUR_SHEET_ID
Your sheet id
CONFIG — Lead Business BOOKING_LINK PASTE_YOUR_BOOKING_LINK
Your booking link
CONFIG — Lead Business SERVICES_LIST PASTE_YOUR_SERVICES
Your services
Send Welcome SMS — Twilio url PASTE_YOUR_TWILIO_ACCOUNT_SID
Your twilio account sid

How this workflow starts

  • Webhook: Listens on path /lead-in — copy the production URL from the node after activating the workflow.

Use cases

The data on lead response is unforgiving: respond in five minutes and you win the job, respond in an hour and the customer has already booked your competitor. But small businesses miss calls constantly. They are under a sink, in a fitting room, with a patient. This template makes sure a missed call is never a lost customer. A webhook catches missed calls or form submissions as a simple JSON payload. Normalize Lead trims and cleans the phone number, the lead is logged to a Leads sheet with status NEW, and a Twilio SMS goes out within about sixty seconds, before the lead calls anyone else. Then an AI Agent scores the lead: a lead score from 0 to 100, an urgency of HOT, WARM, or COLD, a summary, the suggested next step, and the best contact time. Parse Qualification flattens that into clean fields, the sheet row moves to QUALIFIED, and the IF Hot Lead node checks the score against the hot threshold, 75 by default. Hot leads trigger an instant Telegram alert so the owner can call back immediately. Every run ends with a full lead summary on Telegram. It is built for trades, clinics, agents, and dealers, anyone whose revenue walks in through the phone.

The plumbing company missing calls under sinks

A two-person plumbing outfit misses half its calls during working hours because both techs are on jobs. Now the webhook fires on the missed call, the SMS goes out in under a minute, and the AI reads the message: burst pipe and water everywhere scores HOT and the owner gets the Telegram alert mid-job, steps out, and calls back in five minutes. A slow-drain inquiry scores WARM and waits quietly in the sheet.

  • Variation: tune HOT SCORE THRESHOLD in the CONFIG node. Drowning in alerts, raise it to 85. Missing good jobs, drop it to 65.

The real-estate agent catching portal enquiries

An independent agent gets enquiries from property portals at all hours, and the pattern is brutal: the first agent to call gets the viewing. The web form POSTs straight to the webhook, the welcome SMS goes out instantly, and the qualification reads the message for intent. Someone asking for a viewing this weekend with a budget stated scores HOT, and the Telegram alert carries the summary and the suggested next step so the agent calls with context instead of cold.

  • Variation: add the companion follow-up workflow from the guide: a daily schedule that finds rows stuck at CONTACTED for over 24 hours and sends a gentle second SMS before flipping them to FOLLOWED UP.

The dental clinic during lunch hours

A dental clinic's front desk goes unmanned for an hour at lunch, and toothache calls do not respect lunch. With business-hours gating added after Normalize Lead, daytime missed calls get the instant SMS with the booking link, while after-hours calls get a different template promising a morning callback. The AI qualification separates the genuine emergencies, severe pain and swelling score HOT and the dentist gets the Telegram alert, from routine cleaning enquiries that can wait for the receptionist.

  • Variation: swap the SMS provider by replacing the Twilio HTTP node with a Vonage or Msg91 request node in the same shape, if local regulations or pricing favor a regional sender.

The car dealership's test-drive requests

A dealership's website generates test-drive requests through the day, and the sales team argues endlessly about which ones deserve an immediate call. The AI settles it: a message naming a specific model, a trade-in, and this-weekend availability scores HOT and pings the floor manager on Telegram with the summary and next step. A vague what cars do you have scores COLD and gets the SMS with the inventory link, no human time spent.

  • Variation: check that the Twilio sender number is allowed to message the dealership's market before going live, since some countries require registered sender IDs, and test the whole path against the owner's own phone first.

The coaching institute in peak admissions season

A coaching institute gets hundreds of admission enquiries in June and July, far more than the two counsellors can call back the same day. The workflow triages the flood: HOT leads, parents asking about fees and batch timings for the current session, get the instant Telegram alert and a callback within the hour. WARM and COLD leads get the welcome SMS and sit in the QUALIFIED sheet, ordered by score, so counsellors work the list top-down instead of first-come-first-served.

  • Variation: during the off-season, raise the hot threshold so only genuinely urgent enquiries ping the owner, and let the SMS plus sheet handle the rest quietly.

← All templates