8
n8n 中文网amn8n.com

通过短信使用 GPT-4o、Twilio 和 Google Sheets 筛选房地产潜在客户

高级

这是一个Lead Nurturing, AI Chatbot领域的自动化工作流,包含 23 个节点。主要使用 If, Wait, Twilio, Postgres, Aggregate 等节点。 通过短信使用 GPT-4o、Twilio 和 Google Sheets 筛选房地产潜在客户

前置要求
  • PostgreSQL 数据库连接信息
  • Google Sheets API 凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "efb474b59b0341d7791932605bd9ff04a6c7ed9941fdd53dc4a2e4b99a6f9439"
  },
  "nodes": [
    {
      "id": "5a9086c7-c006-4797-9cf6-808e496eb683",
      "name": "表单提交时",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -3220,
        1360
      ],
      "webhookId": "9f4798d9-1e3a-48fc-9f76-96998bf7c102",
      "parameters": {
        "options": {},
        "formTitle": "Real Estate Inquiry",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Phone"
            }
          ]
        },
        "formDescription": "Please enter your phone number with country code (example +1)"
      },
      "typeVersion": 2.2
    },
    {
      "id": "879f41da-4a3d-492a-8b09-f5f8e5bc9a68",
      "name": "Postgres 聊天记忆",
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "position": [
        -2720,
        1900
      ],
      "parameters": {
        "sessionKey": "{{ $('Twilio Trigger').item.json.data.from }}",
        "sessionIdType": "customKey"
      },
      "credentials": {
        "postgres": {
          "id": "VtuOpLe0hNlGoVRM",
          "name": "Real Estate"
        }
      },
      "notesInFlow": false,
      "typeVersion": 1
    },
    {
      "id": "ab202e50-c344-47ca-a279-0850eb444a21",
      "name": "OpenAI 聊天模型1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -1540,
        1840
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "ghJTvay8CvwXDsXz",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "4dffd5d2-f53d-4b19-b386-efb1eb3dd8df",
      "name": "等待",
      "type": "n8n-nodes-base.wait",
      "position": [
        -3120,
        1740
      ],
      "webhookId": "789f5ae5-c8b6-4dac-ae55-363b23cc2d9a",
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "58c0ea8f-d5c2-48fb-9137-4a79db9cbe3c",
      "name": "OpenAI 聊天模型2",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -2920,
        1880
      ],
      "parameters": {
        "model": "gpt-4o",
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "ghJTvay8CvwXDsXz",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "7c2d3782-03d8-4f92-8b3f-9ad4bb080594",
      "name": "结构化输出解析器1",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -1340,
        1840
      ],
      "parameters": {
        "jsonSchemaExample": "{\n\t\"transcript\": \"transcript\",\n\t\"summary\": \"summary\"\n}"
      },
      "typeVersion": 1.2
    },
    {
      "id": "1d36cb2c-b6cd-4eda-b052-38950603a25c",
      "name": "便签 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3400,
        1200
      ],
      "parameters": {
        "width": 920,
        "height": 320,
        "content": "## 表单提交后的初始短信"
      },
      "typeVersion": 1
    },
    {
      "id": "6e55dc34-0d89-42dd-853c-56dcb8722d3b",
      "name": "便签 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3400,
        1560
      ],
      "parameters": {
        "width": 920,
        "height": 680,
        "content": "## 等待短信回复并回复"
      },
      "typeVersion": 1
    },
    {
      "id": "53ecc0f7-43a7-4570-b1ce-3b50ad365828",
      "name": "房地产资质审核器",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -2880,
        1680
      ],
      "parameters": {
        "text": "={{ $json.data.body }}",
        "options": {
          "systemMessage": "=You are a friendly real estate assistant helping qualify new leads for a realtor. Ask only three brief questions, then end the conversation politely. Keep the tone warm and professional. Your goal is to gather basic information to help the realtor follow up later.\n\n1. Ask for their name.\n2. Ask what type of property they’re looking for (e.g., house, condo, rental).\n3. Ask what city or neighborhood they’re interested in.\n\nOnce all three answers are collected, thank them and let them know a realtor will follow up soon. also add *** to the response\n"
        },
        "promptType": "define"
      },
      "typeVersion": 1.6
    },
    {
      "id": "88e9c3eb-dc7c-40e6-b483-2ca6009210bd",
      "name": "便签 5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2420,
        1380
      ],
      "parameters": {
        "width": 1720,
        "height": 860,
        "content": "## 对话结束后,总结并向业主发送潜在客户信息"
      },
      "typeVersion": 1
    },
    {
      "id": "6891b278-3cdd-4c10-93dd-d9d12b137a39",
      "name": "等待5秒",
      "type": "n8n-nodes-base.wait",
      "position": [
        -3000,
        1360
      ],
      "webhookId": "f92de33c-ade9-48c2-97cb-3e865bd44b15",
      "parameters": {
        "amount": 10
      },
      "typeVersion": 1.1
    },
    {
      "id": "6162dad2-af40-4bcb-a08f-cb4b1b33b275",
      "name": "初始短信",
      "type": "n8n-nodes-base.twilio",
      "position": [
        -2760,
        1340
      ],
      "parameters": {
        "to": "={{ $json.Phone }}",
        "from": "+17179155475",
        "message": "Thanks for submitting the form on our site realestate.com. Do you have a few minutes to answer a few questions?",
        "options": {}
      },
      "credentials": {
        "twilioApi": {
          "id": "wiGQkqdtj51l0DId",
          "name": "Twilio account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e189af10-316c-402b-ae09-c5a4940d8cb9",
      "name": "等待短信回复",
      "type": "n8n-nodes-base.twilioTrigger",
      "position": [
        -3340,
        1700
      ],
      "webhookId": "128ba8ce-d358-4c25-9094-760619c97a9e",
      "parameters": {
        "updates": [
          "com.twilio.messaging.inbound-message.received"
        ]
      },
      "credentials": {
        "twilioApi": {
          "id": "wiGQkqdtj51l0DId",
          "name": "Twilio account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "2aa67f37-6e9f-4a30-91ce-ae9338413a1b",
      "name": "检查对话是否完成",
      "type": "n8n-nodes-base.if",
      "position": [
        -2340,
        1600
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "717941a7-5fbd-4256-9983-e766ef34b8bb",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $json.output }}",
              "rightValue": "***"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "c1d78c94-e4ac-44be-ac8f-957b338b89cb",
      "name": "感谢短信",
      "type": "n8n-nodes-base.twilio",
      "position": [
        -2020,
        1460
      ],
      "parameters": {
        "to": "={{ $('Wait for Text Response').item.json.data.from }}",
        "from": "+17179155475",
        "message": "=Thanks, I'll give you a call soon.",
        "options": {}
      },
      "credentials": {
        "twilioApi": {
          "id": "wiGQkqdtj51l0DId",
          "name": "Twilio account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "b01e4aec-ce25-465d-97f0-e1b35e076249",
      "name": "来自代理的回复短信",
      "type": "n8n-nodes-base.twilio",
      "position": [
        -2120,
        1900
      ],
      "parameters": {
        "to": "={{ $('Wait for Text Response').item.json.data.from }}",
        "from": "+17179155475",
        "message": "={{ $json.output }}",
        "options": {}
      },
      "credentials": {
        "twilioApi": {
          "id": "wiGQkqdtj51l0DId",
          "name": "Twilio account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "b232d078-8780-490a-9389-e30eca969ec8",
      "name": "查询 Supabase 获取对话历史",
      "type": "n8n-nodes-base.postgres",
      "position": [
        -1880,
        1760
      ],
      "parameters": {
        "query": "SELECT *\nFROM n8n_chat_histories\nWHERE session_id = '{{ $('Twilio Trigger').item.json.data.from }}';\n",
        "options": {},
        "operation": "executeQuery"
      },
      "credentials": {
        "postgres": {
          "id": "VtuOpLe0hNlGoVRM",
          "name": "Real Estate"
        }
      },
      "typeVersion": 2.5
    },
    {
      "id": "c18d8a47-f4df-419c-a904-c86b5418925c",
      "name": "合并行",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        -1720,
        1500
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "8cbed657-22f6-4c4a-bc62-c7e2bfe383de",
      "name": "总结对话记录",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1520,
        1560
      ],
      "parameters": {
        "text": "={{ $json.data }}",
        "options": {
          "systemMessage": "=output two fields a clean transcript of the conversation and a summary of the conversation"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.6
    },
    {
      "id": "ecf7fdc7-9d63-40af-8b22-37cf988da9bf",
      "name": "将结果存储到 Google",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -1080,
        1480
      ],
      "parameters": {
        "columns": {
          "value": {
            "Phone": "={{ $('Wait for Text Response').item.json.data.from }}",
            "Summary": "={{ $json.output.summary }}",
            "Transcript": "={{ $json.output.transcript }}"
          },
          "schema": [
            {
              "id": "Phone",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Phone",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Transcript",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Transcript",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Summary",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Summary",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1jSlYXSBA9BJvSuMiqFUJo3omztNJtbejNYEopfbGWN8/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1jSlYXSBA9BJvSuMiqFUJo3omztNJtbejNYEopfbGWN8",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1jSlYXSBA9BJvSuMiqFUJo3omztNJtbejNYEopfbGWN8/edit?usp=drivesdk",
          "cachedResultName": "Real Estate Calls"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "WsgMg14OYooIdvn7",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "50dbd5e4-3b38-4448-aa58-2e44974d9875",
      "name": "向业主发送潜在客户",
      "type": "n8n-nodes-base.twilio",
      "position": [
        -920,
        1760
      ],
      "parameters": {
        "to": "={{ $('Wait for Text Response').item.json.data.from }}",
        "from": "+17179155475",
        "message": "=*** You just got a new lead. Here's a transcript of the interaction with our AI Bot. ***{{ $json.Summary }}***",
        "options": {}
      },
      "credentials": {
        "twilioApi": {
          "id": "wiGQkqdtj51l0DId",
          "name": "Twilio account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "b2849c48-337a-4a4c-b104-6842e525e25a",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2420,
        1200
      ],
      "parameters": {
        "color": 5,
        "width": 1720,
        "height": 120,
        "content": "## AI 驱动的房地产潜在客户响应与资质审核器(n8n 工作流)"
      },
      "typeVersion": 1
    },
    {
      "id": "54444b6d-415d-4078-91c9-019af6aad790",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -4140,
        1200
      ],
      "parameters": {
        "color": 5,
        "width": 700,
        "height": 1040,
        "content": "## 实施方法"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "Real Estate Qualifier",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Combine Rows": {
      "main": [
        [
          {
            "node": "Summarize Transcript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 5 Seconds": {
      "main": [
        [
          {
            "node": "Initial Text Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "Wait 5 Seconds",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Summarize Transcript",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "Real Estate Qualifier",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Postgres Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "Real Estate Qualifier",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Summarize Transcript": {
      "main": [
        [
          {
            "node": "Store results in google ",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Real Estate Qualifier": {
      "main": [
        [
          {
            "node": "Check if Conversation Completed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for Text Response": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Store results in google ": {
      "main": [
        [
          {
            "node": "Send Lead to owner",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser1": {
      "ai_outputParser": [
        [
          {
            "node": "Summarize Transcript",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Check if Conversation Completed": {
      "main": [
        [
          {
            "node": "Query Supabase for conversation history",
            "type": "main",
            "index": 0
          },
          {
            "node": "Thank Your Text",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Response Text from Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Query Supabase for conversation history": {
      "main": [
        [
          {
            "node": "Combine Rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 客户培育, AI 聊天机器人

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量23
分类2
节点类型13
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
Robert Breen

Robert Breen

@rbreen

Professional services consultant with over 10 years of experience solving complex business problems across industries. I specialize in n8n and process automation—designing custom workflows that integrate tools like Google Calendar, Airtable, GPT, and internal systems. Whether you need to automate scheduling, sync data, or streamline operations, I build solutions that save time and drive results.

外部链接
在 n8n.io 查看

分享此工作流