Automated Lead Processing, Enrichment & Reporting Pipeline

Hey n8n Community! :waving_hand:

I built an automated lead management workflow designed to ingest raw lead submissions, clean/enrich the data, and distribute formatted output files alongside clean Google Sheets syncs.

What this workflow does:

  • Trigger: Runs on a scheduled basis using Schedule Trigger.

  • Data Ingestion: Reads raw incoming submissions using Read Raw Submissions (Google Sheets).

  • Cleaning & Enrichment: Processes and standardizes raw lead data with the Clean & Enrich Leads Code node.

  • Multi-Branch Output:

    • Appends structured records to Google Sheets via Write Clean Leads to Sheet.

    • Converts clean CRM leads into spreadsheet format via Export clean_crm_leads.xlsx (Convert to XLSX).

    • Calculates key statistics via Summary Metrics (Code node) and exports summary output via Convert to File (Convert to XLSX).

Workflow JSON

{
“nodes”: [
{
“parameters”: {
“rule”: {
“interval”: [
{
“field”: “hours”,
“hoursInterval”: 24
}
]
}
},
“type”: “n8n-nodes-base.scheduleTrigger”,
“typeVersion”: 1.2,
“position”: [
0,
0
],
“id”: “schedule-trigger”,
“name”: “Schedule Trigger”
},
{
“parameters”: {
“operation”: “read”,
“documentId”: {
“__rl”: true,
“mode”: “list”
},
“sheetName”: {
“__rl”: true,
“mode”: “list”
}
},
“type”: “n8n-nodes-base.googleSheets”,
“typeVersion”: 4.5,
“position”: [
220,
0
],
“id”: “read-raw-submissions”,
“name”: “Read Raw Submissions”
},
{
“parameters”: {
“jsCode”: “// Clean and enrich leads logic\nconst items = $input.all();\nreturn items.map(item => {\n const json = item.json;\n return {\n json: {\n …json,\n email: json.email ? json.email.toLowerCase().trim() : ‘’,
name: json.name ? json.name.trim() : ‘’,
processed_at: new Date().toISOString()\n }\n };\n});”
},
“type”: “n8n-nodes-base.code”,
“typeVersion”: 2,
“position”: [
440,
0
],
“id”: “clean-enrich-leads”,
“name”: “Clean & Enrich Leads”
},
{
“parameters”: {
“operation”: “append”,
“documentId”: {
“__rl”: true,
“mode”: “list”
},
“sheetName”: {
“__rl”: true,
“mode”: “list”
}
},
“type”: “n8n-nodes-base.googleSheets”,
“typeVersion”: 4.5,
“position”: [
660,
-180
],
“id”: “write-clean-leads”,
“name”: “Write Clean Leads to Sheet”
},
{
“parameters”: {
“operation”: “toFile”,
“fileFormat”: “xlsx”,
“options”: {}
},
“type”: “n8n-nodes-base.convertToFile”,
“typeVersion”: 1.1,
“position”: [
660,
-20
],
“id”: “export-clean-crm-leads”,
“name”: “Export clean_crm_leads.xlsx”
},
{
“parameters”: {
“jsCode”: “// Calculate summary metrics\nconst items = $input.all();\nconst totalLeads = items.length;\n\nreturn [{\n json: {\n total_leads_processed: totalLeads,\n summary_generated_at: new Date().toISOString()\n }\n}];”
},
“type”: “n8n-nodes-base.code”,
“typeVersion”: 2,
“position”: [
660,
140
],
“id”: “summary-metrics”,
“name”: “Summary Metrics”
},
{
“parameters”: {
“operation”: “toFile”,
“fileFormat”: “xlsx”,
“options”: {}
},
“type”: “n8n-nodes-base.convertToFile”,
“typeVersion”: 1.1,
“position”: [
880,
140
],
“id”: “convert-to-file”,
“name”: “Convert to File”
}
],
“connections”: {
“Schedule Trigger”: {
“main”: [
[
{
“node”: “Read Raw Submissions”,
“type”: “main”,
“index”: 0
}
]
]
},
“Read Raw Submissions”: {
“main”: [
[
{
“node”: “Clean & Enrich Leads”,
“type”: “main”,
“index”: 0
}
]
]
},
“Clean & Enrich Leads”: {
“main”: [
[
{
“node”: “Write Clean Leads to Sheet”,
“type”: “main”,
“index”: 0
},
{
“node”: “Export clean_crm_leads.xlsx”,
“type”: “main”,
“index”: 0
},
{
“node”: “Summary Metrics”,
“type”: “main”,
“index”: 0
}
]
]
},
“Summary Metrics”: {
“main”: [
[
{
“node”: “Convert to File”,
“type”: “main”,
“index”: 0
}
]
]
}
}
}

1 Like