Telegram Lead-Capture Bot: From Form to AI Reply in n8n
The Problem With Manual Lead Follow-Up
A new inquiry lands in your contact form at 11 PM. By the time you reply the next morning, the prospect has already booked a call with a competitor.
Automating first response is table stakes in 2026 — but most tutorials end with "add your OpenAI API key here," leaving you with a per-message bill that grows with every lead. This guide shows you how to build the full flow — form capture → AI qualification → Telegram notification + reply — on your own n8n instance where the AI node is already paid for.
What You're Building
A webhook-triggered workflow that:
- Receives a form submission (any form tool works: Typeform, Tally, a plain HTML form)
- Parses the lead's name, email, company, and message
- Sends the raw data to you in Telegram so you see it immediately
- Runs the lead through an AI/LLM node that scores intent (hot / warm / cold) and drafts a personalised first-reply email
- Stores the scored lead in a Google Sheet (or Airtable) for pipeline tracking
- Optionally sends the drafted reply to the lead's email via Gmail or SMTP
You own every piece of this. The workflow lives in your n8n instance. The data never touches a third-party "automation platform" you can't inspect.
Step-by-Step Build
1. Create a Webhook Trigger
Add a Webhook node. Set the HTTP Method to POST and note the generated URL — it will look like https://<your-id>.agentroost.app/webhook/lead-capture.
Point your form's submission endpoint at this URL. In Tally: Form settings → Integrations → Webhooks → Add webhook URL. In Typeform: Connect → Webhooks.
Tip: In n8n, click Test webhook before submitting a test form. The editor captures one live payload so you can map fields in subsequent nodes without guessing the structure.
2. Parse and Normalise the Payload
Different form tools send slightly different JSON shapes. A Set node lets you extract exactly what you need:
{
"name": "{{ $json.body.answers[0].text }}",
"email": "{{ $json.body.answers[1].email }}",
"company": "{{ $json.body.answers[2].text }}",
"message": "{{ $json.body.answers[3].text }}"
}
Adjust the field paths to match your form's actual payload (visible in the webhook test capture). After this node, every downstream node works with clean name, email, company, message fields.
3. Send Instant Telegram Notification
Add a Telegram node. Set:
- Operation: Send Message
- Chat ID: your personal Telegram ID (get it from @userinfobot)
- Text:
🔔 New lead!
Name: {{ $json.name }}
Company: {{ $json.company }}
Email: {{ $json.email }}
Message: {{ $json.message }}
You'll get a push notification within seconds of each form submission. No dashboard polling needed.
4. Score and Draft a Reply With the AI Node
This is where most DIY setups fall apart — they need an OpenAI account, a key, a billing method, and then they worry every month about runaway costs. On AgentRoost, the AI/LLM node is already connected to included credits. You skip all of that.
Add a Basic LLM Chain (or AI Agent) node. Connect a Language Model sub-node (the node uses your plan's included credits automatically). Write a system prompt like:
You are a sales qualifier for a B2B agency.
Given a lead's message, do two things:
1. Score their buying intent as HOT, WARM, or COLD with one sentence of reasoning.
2. Write a friendly, human-sounding first-reply email (3-5 sentences) that:
- Acknowledges what they asked about
- Mentions one specific next step (e.g., a 20-minute discovery call)
- Does NOT oversell or use marketing jargon
Output as JSON: { "score": "HOT|WARM|COLD", "reason": "...", "draftReply": "..." }
And a user prompt:
Lead name: {{ $json.name }}
Company: {{ $json.company }}
Message: {{ $json.message }}
The node returns structured JSON. Add another Set node to extract score, reason, and draftReply from the response.
5. Send the Score Back to Telegram
Add a second Telegram node:
🤖 AI Score: {{ $json.score }}
Reason: {{ $json.reason }}
Draft reply ready — check your Google Sheet or email drafts.
Now you have both the raw lead and the AI's assessment in your Telegram within ~5 seconds of the form submission.
6. Log to Google Sheets
Add a Google Sheets node. Set Operation to Append Row. Map the columns:
| Sheet Column | n8n Value |
|---|---|
| Timestamp | {{ $now.toISO() }} |
| Name | {{ $json.name }} |
{{ $json.email }} |
|
| Company | {{ $json.company }} |
| Score | {{ $json.score }} |
| Reason | {{ $json.reason }} |
| Draft Reply | {{ $json.draftReply }} |
Your entire pipeline is now logged and sortable. Filter by score = HOT to see who needs a call today.
7. (Optional) Auto-Send or Draft the Reply
For HOT leads, you might want the reply sent immediately. Add an IF node:
- Condition:
{{ $json.score }}equalsHOT - True branch: Gmail node → Send Email, body set to
{{ $json.draftReply }} - False branch: No action (you review WARM/COLD manually)
For WARM leads you can create a draft in Gmail instead of sending, giving you one-click approval before it goes out.
Pitfalls and Tips
Webhook security: Anyone who finds your webhook URL can submit fake leads. Add a header auth check in n8n (Webhook node → Authentication → Header Auth) and set a secret header in your form tool's webhook config.
Duplicate submissions: Forms can fire twice on slow connections. Add a Duplicate Prevention node or check your Google Sheet for an existing email before appending.
AI output parsing: LLMs occasionally return prose instead of JSON, especially with longer messages. Wrap your AI node's output in a Code node that does JSON.parse(...) with a try/catch fallback so the workflow doesn't break on a malformed response.
Testing with real data: n8n's webhook test captures exactly one payload. After you activate the workflow, submit a few test leads through your form to verify the live path behaves the same as the test path.
Running This on AgentRoost
Building this yourself means: a VPS, Docker, an n8n installation, SSL certs, an OpenAI account with billing set up, and ongoing maintenance every time n8n releases a breaking update.
On AgentRoost you skip the entire infrastructure layer:
- Sign up at agentroost.app
- Pick the n8n framework, name your instance
- Your private n8n editor opens at
https://<your-id>.agentroost.app— it's your instance, your login, your data - Build the workflow above — the AI/LLM node already has credits wired in, no API key required
- The webhook URL is public HTTPS from day one, no Cloudflare tunnel or reverse-proxy setup
The plan starts at $19.99/month all-in — that covers the server, your n8n instance, and AI credits for the qualification node. Cancel any time, 14-day money-back guarantee if it's not for you.
Agencies: because this is your own n8n instance (not a shared platform), you can white-label the workflow, export it as a JSON template, and redeploy it for clients on their own instances.
Compare plans and get started →
Who This Is For
This workflow is a good fit if you:
- Run a freelance or agency business where lead response time affects conversion
- Are already using Telegram day-to-day and want notifications there rather than yet another dashboard
- Want AI qualification without a per-call API bill that scales unpredictably with lead volume
- Need to own the data — no leads stored on a third-party automation platform
It's not the right fit if your form volume is less than ~20 leads/month and you're happy checking email manually. Automation has a setup cost; make sure the time saved justifies it.
Frequently asked questions
Do I need an OpenAI API key to use the AI node?
No. On AgentRoost, AI/LLM credits are included in your subscription plan. The AI node is pre-configured — you write your prompt and run the workflow. No external API key, no separate billing account.
Which Telegram bot do I use for this — BotFather?
For an n8n workflow you'll create one bot token yourself via BotFather (it takes about 60 seconds). Paste the token into n8n's Telegram credential and you're done. If you'd rather have a bot auto-provisioned for you without any setup, the Hermes and OpenClaw frameworks on AgentRoost handle that automatically.
Can I export the workflow if I ever want to move it?
Yes. Your n8n instance is yours. Go to the workflow, click the three-dot menu, and choose Download. You get a JSON file you can import into any other n8n instance — self-hosted or otherwise.
What happens if my n8n instance goes down while a lead submits?
n8n stores webhook events in a queue and processes them when the instance recovers. AgentRoost keeps your instance running 24/7, so downtime is not expected during normal operation. For mission-critical flows, enable n8n's Execution History so you can replay any missed runs.
Can I cancel if the workflow doesn't work for my business?
Yes. AgentRoost plans are monthly with no lock-in, and there's a 14-day money-back guarantee. Cancel from the billing dashboard at any time.