使用Apollo、GPT-4和Telegram的AI驱动潜在客户生成至数据库
高级
这是一个Lead Generation, AI Summarization领域的自动化工作流,包含 26 个节点。主要使用 Set, Code, Limit, Filter, Switch 等节点。 基于AI的潜在客户生成:使用Apollo、GPT-4和Telegram输出到数据库
前置要求
- •PostgreSQL 数据库连接信息
- •Supabase URL 和 API Key
- •Telegram Bot Token
- •OpenAI API Key
使用的节点 (26)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "qq6HaoOUegL8M8xk",
"meta": {
"instanceId": "e7ccf4281d5afb175c79c02db95b45f15d5b53862cb6bc357c5e5bc26567f35c",
"templateCredsSetupCompleted": true
},
"name": "使用 Apollo、GPT-4 和 Telegram 的 AI 驱动潜在客户生成至数据库",
"tags": [],
"nodes": [
{
"id": "e180e9bb-30ed-447e-b89b-1089850392e6",
"name": "创建 URL",
"type": "n8n-nodes-base.code",
"position": [
-1340,
-200
],
"parameters": {
"jsCode": "/************************************************************\n * Build Apollo People-search URL from parser output\n * Handles both shapes:\n * { query: [ { … } ] } ← array\n * { query: { … } } ← object\n ************************************************************/\n\n// 1. Obtener el JSON que llega del nodo anterior\nconst inputData = $json;\n\n// 2. Normalizar para que paramsData siempre sea un objeto\nlet paramsData;\n\nif (Array.isArray(inputData.query)) {\n // Caso antiguo: query es un array\n paramsData = inputData.query[0];\n} else if (inputData.query) {\n // Caso nuevo: query es un objeto\n paramsData = inputData.query;\n} else {\n throw new Error('Falta la propiedad \"query\" en el input');\n}\n\n// 3. URL base de Apollo (interfaz web)\n// Para llamar a la API REST cambia a https://api.apollo.io/v1/mixed_people/search\nconst baseURL = 'https://app.apollo.io/#/people';\n\n// 4. Construir los parámetros dinámicos\nconst queryParts = [\n 'sortByField=recommendations_score',\n 'sortAscending=false',\n 'page=1',\n];\n\n// Helper para arrays → personTitles[]=ceo\nconst addArrayParams = (paramName, values) => {\n values.forEach((val) => {\n const decoded = val.replace(/\\+/g, ' '); // “barcelona+spain” ⇒ “barcelona spain”\n queryParts.push(`${paramName}[]=${encodeURIComponent(decoded)}`);\n });\n};\n\n// job_title → personTitles[]\nif (Array.isArray(paramsData.job_title)) {\n addArrayParams('personTitles', paramsData.job_title);\n}\n\n// location → personLocations[]\nif (Array.isArray(paramsData.location)) {\n addArrayParams('personLocations', paramsData.location);\n}\n\n// business → qOrganizationKeywordTags[]\nif (Array.isArray(paramsData.business)) {\n addArrayParams('qOrganizationKeywordTags', paramsData.business);\n}\n\n// campos estáticos\nqueryParts.push('includedOrganizationKeywordFields[]=tags');\nqueryParts.push('includedOrganizationKeywordFields[]=name');\n\n// 5. Montar la URL final\nconst finalURL = `${baseURL}?${queryParts.join('&')}`;\n\n// 6. Devolver resultado\nreturn [{ json: { finalURL } }];\n"
},
"typeVersion": 2
},
{
"id": "03a4bd71-1c8b-4f5b-9c91-739715d9364b",
"name": "提取信息",
"type": "n8n-nodes-base.set",
"position": [
-900,
-200
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "336074e3-b3b9-4dde-92d7-fb5af51b8ffa",
"name": "firstName",
"type": "string",
"value": "={{ $json.first_name }}"
},
{
"id": "da8362c5-75a5-4431-847d-fd4e02112bcc",
"name": "emailAddress",
"type": "string",
"value": "={{ $json.email }}"
},
{
"id": "3c99e0e0-4184-4e85-baa0-8bb85e4e227b",
"name": "linkedInURL",
"type": "string",
"value": "={{ $json.linkedin_url }}"
},
{
"id": "a45af1ff-7026-47a0-a42c-bdb3b27c8e3d",
"name": "seniority ",
"type": "string",
"value": "={{ $json.seniority }}"
},
{
"id": "fa551406-a981-4fbb-babc-aa78ab10010d",
"name": "jobTitle",
"type": "string",
"value": "={{ $json.employment_history[0].title }}"
},
{
"id": "2e8d8d61-bd02-4f24-91f1-707152d99806",
"name": "companyName",
"type": "string",
"value": "={{ $json.employment_history[0].organization_name }}"
},
{
"id": "1295a702-636a-48bd-8bcd-df92162237fb",
"name": "location",
"type": "string",
"value": "={{ $json.city }}, {{ $json.state }}"
},
{
"id": "0072b657-0296-4858-b190-621831943816",
"name": "country",
"type": "string",
"value": "={{ $json.country }}"
},
{
"id": "22ce107c-30ef-4abe-9fab-8d49482da87c",
"name": "Number",
"type": "string",
"value": "={{ $json.organization.primary_phone && $json.organization.primary_phone.sanitized_number && $json.organization.primary_phone.sanitized_number ? $json.organization.primary_phone.sanitized_number : null }}"
},
{
"id": "302b9529-e16b-49ce-bbb6-ae2de90fed93",
"name": "websiteURL",
"type": "string",
"value": "={{ $json.organization_website_url }}"
},
{
"id": "13026de1-0927-44f7-8388-4d525f44974d",
"name": "businessIndustry",
"type": "string",
"value": "={{ $json.industry }}"
},
{
"id": "1a8ae803-f0bd-48d5-bf85-89b91c2e9c64",
"name": "lastName",
"type": "string",
"value": "={{ $json.last_name }}"
},
{
"id": "03cb9c0d-4c05-4d00-88a4-de33e34e7c16",
"name": "emailStatus",
"type": "string",
"value": "={{ $json.email_status }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "11c65a93-97d9-439f-803a-a25322842976",
"name": "仅保留已验证邮箱",
"type": "n8n-nodes-base.filter",
"position": [
-680,
-200
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "c49e7377-db5e-4458-bea5-9e297e19f620",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.emailStatus }}",
"rightValue": "verified"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "0917fa22-1695-403a-9cb4-530a111295f2",
"name": "限制",
"type": "n8n-nodes-base.limit",
"position": [
240,
-120
],
"parameters": {},
"typeVersion": 1
},
{
"id": "78c35016-b023-41e0-8e22-21bed4ca62d2",
"name": "下载文件1",
"type": "n8n-nodes-base.telegram",
"position": [
-2420,
-380
],
"webhookId": "00c7755c-cd84-4aa4-89fe-c56f1f0cb50d",
"parameters": {
"fileId": "={{ $json.message.voice.file_id }}",
"resource": "file"
},
"credentials": {
"telegramApi": {
"id": "U8xdVwgLeiKDKbuS",
"name": "lead chat"
}
},
"typeVersion": 1.2
},
{
"id": "5f6b4e2e-9ae5-49ae-9bc3-049179d29ca6",
"name": "转录1",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
-2200,
-380
],
"parameters": {
"options": {},
"resource": "audio",
"operation": "transcribe"
},
"credentials": {
"openAiApi": {
"id": "OQJASLp1qn1StvpI",
"name": "OpenAi account"
}
},
"typeVersion": 1.6
},
{
"id": "8966e2c9-09da-4aba-8f8b-7e005b05595e",
"name": "文本1",
"type": "n8n-nodes-base.set",
"position": [
-2300,
-120
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "fe7ecc99-e1e8-4a5e-bdd6-6fce9757b234",
"name": "text",
"type": "string",
"value": "={{ $json.message.text }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "ee032f59-9dcb-4136-953d-a4e73fbb1b21",
"name": "语音或文本1",
"type": "n8n-nodes-base.switch",
"position": [
-2640,
-280
],
"parameters": {
"rules": {
"values": [
{
"outputKey": "Voice",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.message.voice.file_id }}",
"rightValue": ""
}
]
},
"renameOutput": true
},
{
"outputKey": "Text",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "8c844924-b2ed-48b0-935c-c66a8fd0c778",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.message.text }}",
"rightValue": ""
}
]
},
"renameOutput": true
}
]
},
"options": {}
},
"typeVersion": 3.2
},
{
"id": "0555b1fe-c6d3-4fcf-9949-087bda07b5f4",
"name": "OpenAI 聊天模型1",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
-1980,
-60
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-nano",
"cachedResultName": "gpt-4.1-nano"
},
"options": {}
},
"credentials": {
"openAiApi": {
"id": "OQJASLp1qn1StvpI",
"name": "OpenAi account"
}
},
"typeVersion": 1.2
},
{
"id": "cca9f664-e7fd-489f-ab76-357e69ee8521",
"name": "简单记忆",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"position": [
-1860,
-60
],
"parameters": {},
"typeVersion": 1.3
},
{
"id": "e7ae31f1-d91f-4df2-b98c-3405a62d3e8f",
"name": "结构化输出解析器",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
-1740,
-60
],
"parameters": {
"jsonSchemaExample": "{\n \"location\": [\"barcelona+spain\"],\n \"business\": [\"ecommerce\"],\n \"job_title\": [\"ceo\"]\n}"
},
"typeVersion": 1.2
},
{
"id": "549bb2c5-f726-43e1-b997-4b0921a00223",
"name": "选择已抓取的邮件",
"type": "n8n-nodes-base.postgres",
"position": [
-1140,
-480
],
"parameters": {
"table": {
"__rl": true,
"mode": "list",
"value": "Leads_n-mail",
"cachedResultName": "Leads_n-mail"
},
"schema": {
"__rl": true,
"mode": "list",
"value": "public"
},
"options": {
"outputColumns": [
"emailAddress"
]
},
"operation": "select",
"returnAll": true
},
"credentials": {
"postgres": {
"id": "6uE1gPELXSqR1Wgn",
"name": "Postgres accou"
}
},
"typeVersion": 2.6
},
{
"id": "1c082972-95d9-4218-8d55-398a5f8bc006",
"name": "仅保留新潜在客户",
"type": "n8n-nodes-base.compareDatasets",
"position": [
-440,
-240
],
"parameters": {
"options": {},
"mergeByFields": {
"values": [
{}
]
}
},
"typeVersion": 2.3
},
{
"id": "76f9769d-7c61-43c7-8bea-5006d965df16",
"name": "已抓取",
"type": "n8n-nodes-base.noOp",
"position": [
-100,
-340
],
"parameters": {},
"typeVersion": 1
},
{
"id": "7b7c68cd-0b3f-4b7e-ac52-a527743f359a",
"name": "创建新潜在客户行",
"type": "n8n-nodes-base.supabase",
"position": [
-160,
-120
],
"parameters": {
"tableId": "Leads_n-mail",
"fieldsUi": {
"fieldValues": [
{
"fieldId": "firstName",
"fieldValue": "={{ $json.firstName }}"
},
{
"fieldId": "emailAddress"
},
{
"fieldId": "linkedInURL"
},
{
"fieldId": "jobTitle",
"fieldValue": "={{ $json.jobTitle }}"
},
{
"fieldId": "companyName",
"fieldValue": "={{ $json.companyName }}"
},
{
"fieldId": "location",
"fieldValue": "={{ $json.location }}"
},
{
"fieldId": "country",
"fieldValue": "={{ $json.country }}"
},
{
"fieldId": "websiteURL",
"fieldValue": "={{ $json.websiteURL }}"
},
{
"fieldId": "businessIndustry",
"fieldValue": "={{ $json.businessIndustry }}{{ $('Apollo Scraper').item.json.organization.industry }}"
},
{
"fieldId": "lastName",
"fieldValue": "={{ $json.lastName }}"
}
]
}
},
"credentials": {
"supabaseApi": {
"id": "eqUdbvoR05KcHhf7",
"name": "Supabase test 1"
}
},
"typeVersion": 1
},
{
"id": "46d24870-39b3-41ad-b8d5-e0c8f7d3dc13",
"name": "设置 Telegram 消息",
"type": "n8n-nodes-base.set",
"position": [
40,
-120
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "feb577bf-b3fb-40da-b37b-41d82345c627",
"name": "output",
"type": "string",
"value": "={{ $input.all().length }} new contacts have been added to the Google Sheet!"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "44f85035-a144-470d-9e9e-f518664ae8f0",
"name": "确认消息",
"type": "n8n-nodes-base.telegram",
"position": [
460,
-120
],
"webhookId": "20bb0a77-76bc-4d9a-bdb4-f5e53a80d299",
"parameters": {
"text": "={{ $input.all().length }} new contacts have been added to the Google Sheet!",
"chatId": "5656980243",
"additionalFields": {
"appendAttribution": false
}
},
"credentials": {
"telegramApi": {
"id": "U8xdVwgLeiKDKbuS",
"name": "lead chat"
}
},
"typeVersion": 1.2
},
{
"id": "6b01d34b-a969-4da6-82b0-74b88ba1b45b",
"name": "用户消息",
"type": "n8n-nodes-base.telegramTrigger",
"position": [
-2860,
-280
],
"webhookId": "75096a78-a466-4f4e-bc0d-f68e9e952231",
"parameters": {
"updates": [
"message"
],
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"id": "U8xdVwgLeiKDKbuS",
"name": "lead chat"
}
},
"typeVersion": 1.1
},
{
"id": "94c7143e-4b6a-48a5-bfa8-1533f99ed78e",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-2880,
-520
],
"parameters": {
"color": 3,
"width": 860,
"height": 600,
"content": "# 第一步:通过语音或文本接收消息"
},
"typeVersion": 1
},
{
"id": "e6f0b89f-c519-4d5a-9c0a-c226636f7144",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-2000,
-520
],
"parameters": {
"width": 580,
"height": 600,
"content": "# 创建 URL 的 JSON"
},
"typeVersion": 1
},
{
"id": "34f4f9e6-570a-4379-b2a7-740b420d66ac",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-2860,
100
],
"parameters": {
"color": 6,
"width": 1400,
"height": 800,
"content": "## 适用对象"
},
"typeVersion": 1
},
{
"id": "d07f9e36-b9ff-4531-b78b-df2c6c554caa",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1380,
-280
],
"parameters": {
"color": 5,
"width": 880,
"height": 280,
"content": "## 从 Apify 执行器抓取潜在客户"
},
"typeVersion": 1
},
{
"id": "e712997f-35f4-45b3-a07b-1b4f38967292",
"name": "便签4",
"type": "n8n-nodes-base.stickyNote",
"position": [
-200,
40
],
"parameters": {
"height": 240,
"content": "## 将新潜在客户插入数据库"
},
"typeVersion": 1
},
{
"id": "06f13dd9-ba24-47d5-b3be-7f5c3ab95b47",
"name": "生成查询载荷",
"type": "n8n-nodes-base.set",
"position": [
-1540,
-180
],
"parameters": {
"mode": "raw",
"options": {},
"jsonOutput": "={\n \"query\": {{ $json.output }}\n}\n\n"
},
"typeVersion": 3.4
},
{
"id": "20b67f44-e172-4e68-ba98-d26aad440cc9",
"name": "采集器智能体",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
-1940,
-280
],
"parameters": {
"text": "={{ $json.text }}",
"options": {
"systemMessage": "=# Role\nYou are LeadChat. Your single job is to return a **JSON array of one object** that tells the sub-workflow what to scrape.\n\n# Required JSON schema\n```json\n[\n {\n \"location\": [\"city+country\"], // lowercase, spaces→+\n \"business\": [\"industry\"], // lowercase, words→+\n \"job_title\": [\"role\"] // lowercase, words→+\n }\n]\n"
},
"promptType": "define",
"hasOutputParser": true
},
"typeVersion": 1.9
},
{
"id": "e71f90ea-9a6e-4617-b321-4eb3f54b3613",
"name": "运行执行器",
"type": "@apify/n8n-nodes-apify.apify",
"position": [
-1120,
-200
],
"parameters": {
"build": "latest",
"actorId": {
"__rl": true,
"mode": "list",
"value": "jljBwyyQakqrL1wae",
"cachedResultUrl": "https://console.apify.com/actors/jljBwyyQakqrL1wae/input",
"cachedResultName": "🔥Apollo Scraper - Scrape upto 50k Leads"
},
"timeout": 10000,
"operation": "Run actor",
"customBody": "{\n \"getPersonalEmails\": true,\n \"getWorkEmails\": true,\n \"totalRecords\": 500,\n \"url\": \"{{ $json.finalURL }}\"\n}",
"waitForFinish": 60
},
"credentials": {
"apifyApi": {
"id": "kGpCkYtjk8FTQpbt",
"name": "Apify account"
}
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "c66f7c4b-73c5-41c1-8594-87c8eb5100c7",
"connections": {
"Limit": {
"main": [
[
{
"node": "Confirmation message",
"type": "main",
"index": 0
}
]
]
},
"Text1": {
"main": [
[
{
"node": "Scraper agent",
"type": "main",
"index": 0
}
]
]
},
"Create URL": {
"main": [
[
{
"node": "Run an Actor",
"type": "main",
"index": 0
}
]
]
},
"Transcribe1": {
"main": [
[
{
"node": "Scraper agent",
"type": "main",
"index": 0
}
]
]
},
"Extract Info": {
"main": [
[
{
"node": "Only Keep Verified Emails ",
"type": "main",
"index": 0
}
]
]
},
"Run an Actor": {
"main": [
[
{
"node": "Extract Info",
"type": "main",
"index": 0
}
]
]
},
"User message": {
"main": [
[
{
"node": "Voice or Text1",
"type": "main",
"index": 0
}
]
]
},
"Scraper agent": {
"main": [
[
{
"node": "Generate query payload",
"type": "main",
"index": 0
},
{
"node": "Select already scraped mails",
"type": "main",
"index": 0
}
]
]
},
"Simple Memory": {
"ai_memory": [
[
{
"node": "Scraper agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"Download File1": {
"main": [
[
{
"node": "Transcribe1",
"type": "main",
"index": 0
}
]
]
},
"Voice or Text1": {
"main": [
[
{
"node": "Download File1",
"type": "main",
"index": 0
}
],
[
{
"node": "Text1",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model1": {
"ai_languageModel": [
[
{
"node": "Scraper agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Set Telegram message": {
"main": [
[
{
"node": "Limit",
"type": "main",
"index": 0
}
]
]
},
"Generate query payload": {
"main": [
[
{
"node": "Create URL",
"type": "main",
"index": 0
}
]
]
},
"Keep only the new leads": {
"main": [
[
{
"node": "Already scraped",
"type": "main",
"index": 0
}
],
[
{
"node": "Already scraped",
"type": "main",
"index": 0
}
],
[
{
"node": "Already scraped",
"type": "main",
"index": 0
}
],
[
{
"node": "Create rows with new leads",
"type": "main",
"index": 0
}
]
]
},
"Structured Output Parser": {
"ai_outputParser": [
[
{
"node": "Scraper agent",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"Create rows with new leads": {
"main": [
[
{
"node": "Set Telegram message",
"type": "main",
"index": 0
}
]
]
},
"Only Keep Verified Emails ": {
"main": [
[
{
"node": "Keep only the new leads",
"type": "main",
"index": 1
}
]
]
},
"Select already scraped mails": {
"main": [
[
{
"node": "Keep only the new leads",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 潜在客户开发, AI 摘要总结
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
GPT-4驱动的冷邮件工作流,包含完全定制的3封邮件跟进
使用GPT-4、Mailgun和Supabase自动化个性化冷邮件序列
If
Set
Code
+22
100 节点Paul
客户培育
完整的 B2B 销售流程:Apollo 潜在客户生成、Mailgun 外展和 AI 回复管理
完整的 B2B 销售流程:Apollo 潜在客户生成、Mailgun 外展和 AI 回复管理
If
Set
Code
+26
116 节点Paul
内容创作
基于 GPT、LangChain 和智能路由的 AI 驱动客户服务自动化
AI驱动客户服务自动化,基于GPT、LangChain和智能路由
Set
Gmail
Merge
+19
46 节点Paul
客户支持
使用Perplexity和GPT为WordPress创建SEO优化博客,包含关键词和媒体
使用Perplexity和GPT为WordPress创建SEO优化博客,包含关键词和媒体
Set
Code
Limit
+22
124 节点Paul
内容创作
使用特定工具为WordPress创建SEO优化博客
使用特定工具为WordPress创建SEO优化博客
Set
Code
Limit
+22
124 节点Paul
内容创作
使用GPT-5和fal.ai图像从关键词到WordPress自动化SEO博客流程
使用GPT-5和fal.ai图像从关键词到WordPress自动化SEO博客流程
Set
Code
Wait
+20
96 节点Paul
内容创作
工作流信息
难度等级
高级
节点数量26
分类2
节点类型18
作者
Paul
@diagoplAutomation expert & n8n power user. I build advanced workflows combining AI, outbound, and business logic. Grab my templates or reach out for custom builds.
外部链接
在 n8n.io 查看 →
分享此工作流