使用Postgres和Gallabox个性化消息的自动化WhatsApp潜在客户培育
中级
这是一个Lead Nurturing, Multimodal AI领域的自动化工作流,包含 11 个节点。主要使用 Code, Postgres, HttpRequest, SplitInBatches, ScheduleTrigger 等节点。 使用Postgres和Gallabox个性化消息的自动化WhatsApp潜在客户培育
前置要求
- •PostgreSQL 数据库连接信息
- •可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"meta": {
"instanceId": "807c58b937f3c75f8b242bc4ac5f455a51832cabd7bcdbecd9fdc3ba6179a8c9",
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "84e5aa63-1375-4aa5-980a-b8d252d7535b",
"name": "执行 SQL 查询",
"type": "n8n-nodes-base.postgres",
"onError": "continueRegularOutput",
"position": [
4040,
520
],
"parameters": {
"query": "SELECT * FROM \"MQL\".mql_contacts\nWHERE (\n (count = 0)\n OR \n (count = 1 AND (NOW() AT TIME ZONE 'Asia/Kolkata') - webhook_time > INTERVAL '3 minutes')\n OR \n (count = 2 AND (NOW() AT TIME ZONE 'Asia/Kolkata') - webhook_time > INTERVAL '5 minutes')\n OR \n (count = 3 AND (NOW() AT TIME ZONE 'Asia/Kolkata') - webhook_time > INTERVAL '8 minutes')\n)\n AND\n disposition = 'unqualified'\n ;",
"options": {},
"operation": "executeQuery"
},
"retryOnFail": true,
"typeVersion": 2.6,
"alwaysOutputData": true
},
{
"id": "4c385ae2-6ffe-4f84-8647-cc347dd32ad4",
"name": "便签 1",
"type": "n8n-nodes-base.stickyNote",
"position": [
4000,
680
],
"parameters": {
"width": 176,
"height": 80,
"content": "获取不合格线索,分别计数0、1、2、3次"
},
"typeVersion": 1
},
{
"id": "fcdf84ff-57e4-4faa-adcb-c0e3d707e34c",
"name": "计划触发器",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
3720,
520
],
"parameters": {
"rule": {
"interval": [
{
"field": "seconds"
}
]
}
},
"typeVersion": 1.2
},
{
"id": "00e9e762-8a4a-46be-85e8-e3bbd86bfc07",
"name": "代码1",
"type": "n8n-nodes-base.code",
"position": [
4780,
540
],
"parameters": {
"jsCode": "// Define matrix with count mapping\nconst matrix = {\n nexus: {\n 0: \"🛵 sample1\",\n 1: \"⚡️ sample1\",\n 2: \"🔋 sample1\",\n 3: \"✨ sample1\"\n },\n magnus: {\n 0: \"🛵 sample2\",\n 1: \"⚡️ sample2\",\n 2: \"🔋 sample2\",\n 3: \"✨ sample2\"\n },\n reo: {\n 0: \"🛵 sample3\",\n 1: \"⚡️ sample3\",\n 2: \"🔋 sample3\",\n 3: \"✨sample3\"\n },\n general: {\n 0: \"🛵 sample4\",\n 1: \"⚡️sample4\",\n 2: \"🔋 sample4\",\n 3: \"✨ sample3\"\n }\n};\n\n// Get inputs from previous node\nconst model = $input.first().json.model// \"nexus\" / \"reo\" / \"magnus\" / \"general\"\nconst count = $input.first().json.count // 0 / 1 / 2 / 3\n\n// const model = \"general\"; \n// const count = 0; \n\n// Fetch matching content\nconst output = matrix[model]?.[count] || \"🛵 default\";\n\n// Return as output\nreturn [{ json: { model, count, output } }];"
},
"typeVersion": 2
},
{
"id": "8c5fad3d-46b3-427e-ab5a-205712394bd0",
"name": "遍历项目4",
"type": "n8n-nodes-base.splitInBatches",
"position": [
4520,
520
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "a7846d82-40fa-4f73-b22a-a100009d276c",
"name": "新线索_4",
"type": "n8n-nodes-base.httpRequest",
"onError": "continueRegularOutput",
"position": [
5000,
540
],
"parameters": {
"url": "https://server.gallabox.com/devapi/messages/whatsapp",
"method": "POST",
"options": {
"response": {
"response": {
"fullResponse": true
}
}
},
"jsonBody": "=add here your copy api for whatsapp sending\n{\n \"channelId\": \"0\",\n \"channelType\": \"whatsapp\",\n \"recipient\": {\n \"name\": \"{{ $('Execute a SQL query').item.json.name }}\",\n \"phone\": \"91{{ $('Execute a SQL query').item.json.phone }}\"\n },\n \"whatsapp\": {\n \"type\": \"template\",\n \"template\": {\n \"templateName\": \"waba_qual_21july25\",\n \"bodyValues\": {\n \"Name\": \"{{ $('Execute a SQL query').item.json.name }}\",\n \"Details\": \"{{ $json.output }}\"\n },\n \"buttonValues\": [\n {\n \"index\": 0,\n \"sub_type\": \"quick_reply\",\n \"parameters\": {\n \"type\": \"payload\",\n \"payload\": \"Show Brochure\"\n }\n },\n {\n \"index\": 1,\n \"sub_type\": \"quick_reply\",\n \"parameters\": {\n \"type\": \"payload\",\n \"payload\": \"Get Showroom Location\"\n }\n },\n {\n \"index\": 2,\n \"sub_type\": \"quick_reply\",\n \"parameters\": {\n \"type\": \"payload\",\n \"payload\": \"Not Interested\"\n }\n }\n ]\n }\n }\n}",
"sendBody": true,
"jsonHeaders": "{\n \"apiKey\": \"\",\n \"apiSecret\": \"\"\n}",
"sendHeaders": true,
"specifyBody": "json",
"authentication": "genericCredentialType",
"specifyHeaders": "json",
"genericAuthType": "httpCustomAuth"
},
"typeVersion": 4.1
},
{
"id": "505800b6-fbe6-49bd-bd97-5cfb3a34da8c",
"name": "在表4中更新行",
"type": "n8n-nodes-base.postgres",
"position": [
5500,
540
],
"parameters": {
"table": {
"__rl": true,
"mode": "list",
"value": "mql_contacts",
"cachedResultName": "mql_contacts"
},
"schema": {
"__rl": true,
"mode": "list",
"value": "MQL",
"cachedResultName": "MQL"
},
"columns": {
"value": {
"count": "={{ $('Execute a SQL query').item.json.count + 1 }}",
"phone": "={{ $('Execute a SQL query').item.json.phone }}",
"pincode": 0,
"last_message_sent": "={{ $json.last_sent }}"
},
"schema": [
{
"id": "id",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "id",
"defaultMatch": true,
"canBeUsedToMatch": true
},
{
"id": "created_at",
"type": "dateTime",
"display": true,
"removed": true,
"required": false,
"displayName": "created_at",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "updated_at",
"type": "dateTime",
"display": true,
"removed": true,
"required": false,
"displayName": "updated_at",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "name",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "phone",
"type": "number",
"display": true,
"removed": false,
"required": true,
"displayName": "phone",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "last_message_sent",
"type": "dateTime",
"display": true,
"required": false,
"displayName": "last_message_sent",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "disposition",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "disposition",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "count",
"type": "number",
"display": true,
"removed": false,
"required": false,
"displayName": "count",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "interval",
"type": "number",
"display": true,
"removed": true,
"required": false,
"displayName": "interval",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "remarks",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "remarks",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "model",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "model",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "pincode",
"type": "number",
"display": true,
"removed": false,
"required": false,
"displayName": "pincode",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "ABOS API status",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "ABOS API status",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "webhook_time",
"type": "dateTime",
"display": true,
"removed": false,
"required": false,
"displayName": "webhook_time",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [
"phone"
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "update"
},
"typeVersion": 2.6
},
{
"id": "f7729e9d-8f3b-477a-88fe-513be43997e4",
"name": "在表4中插入行",
"type": "n8n-nodes-base.postgres",
"position": [
5280,
540
],
"parameters": {
"table": {
"__rl": true,
"mode": "list",
"value": "mql_logs",
"cachedResultName": "mql_logs"
},
"schema": {
"__rl": true,
"mode": "list",
"value": "MQL",
"cachedResultName": "MQL"
},
"columns": {
"value": {
"name": "={{ $('Execute a SQL query').item.json.name }}",
"phone": "={{ $('Execute a SQL query').item.json.phone }}",
"remarks": "Workflow 1",
"last_sent": "={{ $('Execute a SQL query').item.json.last_message_sent }}",
"mes_count": "={{ $('Execute a SQL query').item.json.count }}",
"message_id": "={{ $json.body.id }}",
"disposition": "={{ $('Execute a SQL query').item.json.disposition }}",
"gb_status_code": "={{ $json.statusCode }}",
"gb_status_message": "={{ $json.body.status }}"
},
"schema": [
{
"id": "id",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "id",
"defaultMatch": true,
"canBeUsedToMatch": true
},
{
"id": "created_at",
"type": "dateTime",
"display": true,
"required": false,
"displayName": "created_at",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "updated_at",
"type": "dateTime",
"display": true,
"required": false,
"displayName": "updated_at",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "message_id",
"type": "string",
"display": true,
"required": false,
"displayName": "message_id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "name",
"type": "string",
"display": true,
"required": false,
"displayName": "name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "phone",
"type": "number",
"display": true,
"required": true,
"displayName": "phone",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "disposition",
"type": "string",
"display": true,
"required": false,
"displayName": "disposition",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "mes_count",
"type": "number",
"display": true,
"required": false,
"displayName": "mes_count",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "last_sent",
"type": "dateTime",
"display": true,
"required": false,
"displayName": "last_sent",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "gb_status_code",
"type": "number",
"display": true,
"required": false,
"displayName": "gb_status_code",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "gb_status_message",
"type": "string",
"display": true,
"required": false,
"displayName": "gb_status_message",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "message_status_meta",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "message_status_meta",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "cta",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "cta",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "remarks",
"type": "string",
"display": true,
"required": false,
"displayName": "remarks",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [
"id"
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"typeVersion": 2.6
},
{
"id": "a6bb388a-17f3-4e24-94a4-47abf67dacf4",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
4640,
420
],
"parameters": {
"width": 216,
"height": 80,
"content": "矩阵代码用于添加唯一消息,通过变量推送到消息中"
},
"typeVersion": 1
},
{
"id": "afd6a70f-80ae-4c3e-8b82-bd784dacfbe5",
"name": "便签 2",
"type": "n8n-nodes-base.stickyNote",
"position": [
5000,
420
],
"parameters": {
"width": 150,
"height": 80,
"content": "Gallabox/WhatsApp发送API"
},
"typeVersion": 1
},
{
"id": "13fe2f75-fe06-423a-9334-a4be0025624d",
"name": "便签 3",
"type": "n8n-nodes-base.stickyNote",
"position": [
5380,
420
],
"parameters": {
"width": 150,
"height": 80,
"content": "Postgres连接存储数据"
},
"typeVersion": 1
}
],
"pinData": {},
"connections": {
"Code1": {
"main": [
[
{
"node": "new_lead_4",
"type": "main",
"index": 0
}
]
]
},
"new_lead_4": {
"main": [
[
{
"node": "Insert rows in a table4",
"type": "main",
"index": 0
}
]
]
},
"Loop Over Items4": {
"main": [
[],
[
{
"node": "Code1",
"type": "main",
"index": 0
}
]
]
},
"Schedule Trigger": {
"main": [
[
{
"node": "Execute a SQL query",
"type": "main",
"index": 0
}
]
]
},
"Execute a SQL query": {
"main": [
[
{
"node": "Loop Over Items4",
"type": "main",
"index": 0
}
]
]
},
"Insert rows in a table4": {
"main": [
[
{
"node": "Update rows in a table4",
"type": "main",
"index": 0
}
]
]
},
"Update rows in a table4": {
"main": [
[
{
"node": "Loop Over Items4",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 客户培育, 多模态 AI
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
基于 Supabase、Smartlead 和 Google Gemini AI 的个性化冷邮件生成器
基于 Supabase、Smartlead 和 Google Gemini AI 的个性化冷邮件生成器
If
Code
Supabase
+8
26 节点Rahi
客户培育
GPT-4驱动的冷邮件工作流,包含完全定制的3封邮件跟进
使用GPT-4、Mailgun和Supabase自动化个性化冷邮件序列
If
Set
Code
+22
100 节点Paul
客户培育
使用Airtable、OpenAI和Unipile的自动化LinkedIn潜在客户生成与私信触达
使用Airtable、OpenAI和Unipile的自动化LinkedIn潜在客户生成与私信触达
If
Set
Code
+15
143 节点Ruben AI
客户培育
使用Gallabox API和Supabase滴灌营销的自动化WhatsApp潜在客户培育
使用Gallabox API和Supabase滴灌营销的自动化WhatsApp潜在客户培育
If
Switch
Supabase
+4
34 节点Rahi
客户培育
使用Rapiwa API从Google表格自动化发送WhatsApp欢迎消息
使用Google表格和Rapiwa为销售线索自动化发送WhatsApp欢迎消息
If
Code
Wait
+6
17 节点SpaGreen Creative
客户培育
使用GPT-5和fal.ai图像从关键词到WordPress自动化SEO博客流程
使用GPT-5和fal.ai图像从关键词到WordPress自动化SEO博客流程
Set
Code
Wait
+20
96 节点Paul
内容创作
工作流信息
难度等级
中级
节点数量11
分类2
节点类型6
作者
Rahi
@rahiuppalAI and Automation Consultant with over 1000 hours of experience building, deploying, and solving marketing and sales automation problems. I ship AI products faster by combining business acumen with AI & automation expertise and an engineering mindset. Connect with me on LinkedIn to chat.
外部链接
在 n8n.io 查看 →
分享此工作流