Lead Scoring Pipeline with Telegram and Box
This workflow ingests incoming lead data from a form submission webhook, enriches each lead with external data sources, applies a custom scoring algorithm, and automatically stores the enriched record in Box while notifying your sales team in Telegram. It is designed to give you a real-time, end-to-end lead-qualification pipeline without writing any glue code.
Pre-conditions/Requirements
Prerequisites
n8n instance (self-hosted or n8n.cloud)
ScrapeGraphAI community node installed
(not directly used in this template but required by marketplace listing rules)
Telegram Bot created via BotFather
Box account (Developer App or User OAuth2)
Publicly accessible URL (for the Webhook trigger)
Optional: Enrichment API account (e.g., Clearbit, PDL) for richer scoring data
Required Credentials
| Credential | Scope | Purpose |
|------------|-------|---------|
| Telegram Bot Token | Bot | Send scored-lead alerts |
| Box OAuth2 Credentials | App Level | Upload enriched lead JSON/CSV |
| (Optional) Enrichment API Key | REST | Append firmographic & technographic data |
Environment Variables (Recommended)
| Variable | Example | Description |
|---------|----------|-------------|
| LEAD_SCORE_THRESHOLD | 75 | Minimum score that triggers a Telegram alert |
| BOX_FOLDER_ID | 123456789 | Destination folder for lead files |
How it works
This workflow listens for new form submissions, enriches each contact with external data, calculates a lead score based on configurable criteria, and routes the lead through one of two branches: high-value leads trigger an instant Telegram alert and are archived to Box, while low-value leads are archived only. Errors are captured by an Error Trigger for post-mortem analysis.
Key Steps:
Webhook Trigger**: Receives raw form data (name, email, company, etc.).
Set node – Normalization**: Renames fields and initializes default values.
HTTP Request – Enrichment**: Calls an external enrichment API to augment data.
Merge node**: Combines original and enriched data into a single object.
Code node – Scoring**: Runs JavaScript to calculate a numeric lead score.
If node – Qualification Gate**: Checks if score ≥ LEAD_SCORE_THRESHOLD.
Telegram node**: Sends alert message to your sales channel for high-scoring leads.
Box node**: Uploads the enriched JSON (or CSV) file into a specified folder.
Error Trigger**: Captures any unhandled errors and notifies ops (optional).
Sticky Notes**: Explain scoring logic and credential placement (documentation aids).
Set up steps
Setup Time: 15-25 minutes
Create Telegram Bot & Get Token
Talk to BotFather → /newbot → copy the provided token.
Create a Box Developer App
Enable OAuth2 → add https://api.n8n.cloud/oauth2-credential/callback (or your own) as redirect URI.
Install Required Community Nodes
From n8n editor → “Install” → search “ScrapeGraphAI” → install.
Import the Workflow JSON
Click “Import” → paste the workflow file → save.
Configure the Webhook URL in Your Form Tool
Copy the production URL generated by the Webhook node → add it as form action.
Set Environment Variables
In n8n (Settings → Environment) add LEAD_SCORE_THRESHOLD and BOX_FOLDER_ID.
Fill in All Credentials
Telegram: paste bot token.
Box: complete OAuth2 flow.
Enrichment API: paste key in the HTTP Request node headers.
Activate Workflow
Toggle “Activate”. Submit a test form to verify Telegram/Box outputs.
Node Descriptions
Core Workflow Nodes:
Webhook** – Entry point; captures incoming JSON payload from the form.
Set (Normalize Fields)** – Maps raw keys to standardized ones (firstName, email, etc.).
HTTP Request (Enrichment)** – Queries external service for firmographic data.
Merge (Combine Data)** – Merges the two JSON objects (form + enrichment).
Code (Scoring)** – Calculates lead score using weighted attributes.
If (Score Check)** – Branches flow based on the score threshold.
Telegram** – Sends high-score alerts to a specified chat ID.
Box** – Saves a JSON/CSV file of the enriched lead to cloud storage.
Error Trigger** – Executes if any preceding node fails.
Sticky Notes** – Inline documentation for quick reference.
Data Flow:
Webhook → Set → HTTP Request → Merge → Code → If
If (true) → Telegram
If (always) → Box
Error (from any node) → Error Trigger
Customization Examples
Change Scoring Logic
// Inside the Code node
const { jobTitle, companySize, technologies } = items[0].json;
let score = 0;
if (jobTitle.match(/(CTO|CEO|Founder)/i)) score += 50;
if (companySize > 500) score += 20;
if (technologies.includes('AWS')) score += 10;
// Bonus: subtract points if free email domain
if (items[0].json.email.endsWith('@gmail.com')) score -= 30;
return [{ json: { ...items[0].json, score } }];
Use a Different Storage Provider (e.g., Google Drive)
// Replace Box node with Google Drive node
{
"node": "Google Drive",
"operation": "upload",
"fileName": "lead_{{$json.email}}.json",
"folderId": "1A2B3C..."
}
Data Output Format
The workflow outputs structured JSON data:
{
"firstName": "Ada",
"lastName": "Lovelace",
"email": "
[email protected]",
"company": "Analytical Engines Inc.",
"companySize": 250,
"jobTitle": "CTO",
"technologies": ["AWS", "Docker", "Node.js"],
"score": 82,
"qualified": true,
"timestamp": "2024-04-07T12:34:56.000Z"
}
Troubleshooting
Common Issues
Telegram messages not received – Ensure the bot is added to the group and chat_id/token are correct.
Box upload fails with 403 – Check folder permissions; verify OAuth2 tokens have not expired.
Webhook shows 404 – The workflow is not activated or the URL was copied in “Test” mode instead of “Production”.
Performance Tips
Batch multiple form submissions using the “SplitInBatches” node to reduce API-call overhead.
Cache enrichment responses (Redis, n8n Memory) to avoid repeated lookups for the same domain.
Pro Tips:
Add an n8n “Wait” node between enrichment calls to respect rate limits.
Use Static Data to store domain-level enrichment results for even faster runs.
Tag Telegram alerts with emojis based on score (🔥 Hot Lead for >90).
This is a community-contributed n8n workflow template provided “as-is.” Always test thoroughly in a non-production environment before deploying to live systems.