Property Lead Contact Enrichment from CRM
工作流概述
这是一个包含16个节点的复杂工作流,主要用于自动化处理各种任务。
工作流源代码
{
"id": "RGVS0tHJV7Wh6aX4",
"meta": {
"instanceId": "bb9853d4d7d87207561a30bc6fe4ece20b295264f7d27d4a62215de2f3846a56"
},
"name": "Property Lead Contact Enrichment from CRM",
"tags": [],
"nodes": [
{
"id": "518b14de-23b9-4821-930c-8fa55eb4cfb4",
"name": "When clicking \"Execute Workflow\"",
"type": "n8n-nodes-base.manualTrigger",
"position": [
-340,
280
],
"parameters": {},
"typeVersion": 1
},
{
"id": "939df2a3-f6dd-40c9-a01a-460923a332a6",
"name": "Daily Schedule",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
-340,
100
],
"parameters": {
"rule": {
"interval": [
{}
]
}
},
"typeVersion": 1.1
},
{
"id": "3228372f-ac40-4898-8bf5-09a4f37fde85",
"name": "Search Properties API",
"type": "n8n-nodes-base.httpRequest",
"position": [
320,
260
],
"parameters": {
"url": "https://api.batchdata.com/api/v1/properties/search",
"method": "POST",
"options": {},
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth"
},
"typeVersion": 4.1
},
{
"id": "0aa1fb95-66c8-4b61-81f5-04b37e5c1185",
"name": "Configure Search Parameters",
"type": "n8n-nodes-base.set",
"position": [
40,
240
],
"parameters": {
"values": {
"string": [
{
"name": "search_parameters",
"value": "={ \"location\": { \"city\": \"Austin\", \"state\": \"TX\" }, \"propertyType\": \"single_family\", \"value\": { \"min\": 200000, \"max\": 500000 }, \"status\": \"distressed\", \"equity\": { \"min\": 30 }, \"limit\": 50 }"
}
]
},
"options": {}
},
"typeVersion": 2
},
{
"id": "052b357b-a374-4e0c-ab98-67e79ed8cf2b",
"name": "Filter Property Results",
"type": "n8n-nodes-base.code",
"position": [
540,
260
],
"parameters": {
"jsCode": "// Process batch property results and filter according to criteria
const results = $input.all()[0].json.results || [];
// Filter to find matching properties
const filteredProperties = results.filter(property => {
// Example filtering criteria - customize as needed
// Only include properties where:
// 1. Owner doesn't live at the property (absentee)
// 2. Property has been owned for 5+ years
// 3. No sales in the last 3 years
const isAbsentee = property.owner_occupied === false;
// Calculate years of ownership if purchase date exists
let yearsOwned = 0;
if (property.last_sale_date) {
const purchaseDate = new Date(property.last_sale_date);
const currentDate = new Date();
yearsOwned = currentDate.getFullYear() - purchaseDate.getFullYear();
}
// Check if no recent sales (last 3 years)
let noRecentSales = true;
if (property.last_sale_date) {
const lastSale = new Date(property.last_sale_date);
const threeYearsAgo = new Date();
threeYearsAgo.setFullYear(threeYearsAgo.getFullYear() - 3);
noRecentSales = lastSale < threeYearsAgo;
}
return isAbsentee && yearsOwned >= 5 && noRecentSales;
});
// Add relevant score to each property
const scoredProperties = filteredProperties.map(property => {
// Create a simple scoring system from 0-100
// This helps prioritize the best leads
let score = 50; // Base score
// Increase score for properties with more equity
if (property.equity_percentage) {
score += Math.min(property.equity_percentage / 2, 25);
}
// Increase score for longer ownership
if (property.last_sale_date) {
const purchaseDate = new Date(property.last_sale_date);
const currentDate = new Date();
const yearsOwned = currentDate.getFullYear() - purchaseDate.getFullYear();
score += Math.min(yearsOwned, 15);
}
// Increase score for tax delinquency
if (property.tax_delinquent) {
score += 10;
}
return { ...property, lead_score: Math.round(score) };
});
// Sort by score descending
scoredProperties.sort((a, b) => b.lead_score - a.lead_score);
// Return the filtered and scored properties
return scoredProperties.map(property => {
return {
json: property
};
});"
},
"typeVersion": 2
},
{
"id": "2c183cc1-06a1-4528-82c3-df2585df58eb",
"name": "Get Owner Contact Info",
"type": "n8n-nodes-base.httpRequest",
"position": [
760,
260
],
"parameters": {
"url": "https://api.batchdata.com/api/v1/property/skip-trace",
"method": "POST",
"options": {},
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth"
},
"typeVersion": 4.1
},
{
"id": "2fe0aef9-30d2-4c30-9029-571f3b4c8ca9",
"name": "Format Lead Data",
"type": "n8n-nodes-base.code",
"position": [
960,
260
],
"parameters": {
"jsCode": "// Process and format the property data with owner contact info
return $input.all().map(item => {
const property = item.json;
const skipTraceData = property.skip_trace_data || {};
const ownerInfo = property.owner_info || {};
return {
json: {
// Property Information
property_id: property.property_id,
address: property.address,
city: property.city,
state: property.state,
zip: property.zip,
property_type: property.property_type,
beds: property.beds,
baths: property.baths,
sqft: property.building_sqft,
lot_size: property.lot_size,
year_built: property.year_built,
last_sale_date: property.last_sale_date,
last_sale_price: property.last_sale_price,
estimated_value: property.estimated_value,
estimated_equity: property.estimated_equity,
equity_percentage: property.equity_percentage,
lead_score: property.lead_score,
// Owner Information
owner_name: ownerInfo.full_name || `${ownerInfo.first_name || ''} ${ownerInfo.last_name || ''}`.trim(),
owner_mailing_address: ownerInfo.mailing_address,
owner_mailing_city: ownerInfo.mailing_city,
owner_mailing_state: ownerInfo.mailing_state,
owner_mailing_zip: ownerInfo.mailing_zip,
// Contact Info from Skip Trace
email: skipTraceData.email,
phone: skipTraceData.phone_number,
mobile: skipTraceData.mobile_number,
alternate_phone: skipTraceData.alternate_phone,
// Additional Details
absentee_owner: property.owner_occupied === false ? 'Yes' : 'No',
tax_delinquent: property.tax_delinquent ? 'Yes' : 'No',
years_owned: property.years_owned,
lead_source: 'BatchData Property Search',
date_added: new Date().toISOString().split('T')[0]
}
};
});"
},
"typeVersion": 2
},
{
"id": "013469c2-1e83-44e0-b078-c0b3d052a2c5",
"name": "Create Excel Spreadsheet",
"type": "n8n-nodes-base.spreadsheetFile",
"position": [
1280,
160
],
"parameters": {
"options": {
"fileName": "Property_Leads_{{ $now.format('YYYY-MM-DD') }}.xlsx",
"headerRow": true
},
"operation": "toFile",
"fileFormat": "xlsx"
},
"typeVersion": 2
},
{
"id": "954c492a-7da2-4902-99ab-318d4ea6e333",
"name": "Push to CRM",
"type": "n8n-nodes-base.hubspot",
"position": [
1280,
540
],
"parameters": {
"options": {},
"additionalFields": {}
},
"typeVersion": 2
},
{
"id": "61bfd72b-8971-4298-8d2a-09baea403956",
"name": "Email Notification",
"type": "n8n-nodes-base.emailSend",
"position": [
1520,
300
],
"webhookId": "e9459278-1cd9-47bb-bffd-88380d297217",
"parameters": {
"options": {},
"subject": "Property Lead Report - {{ $now.format('YYYY-MM-DD') }}",
"toEmail": "your-email@yourdomain.com",
"fromEmail": "no-reply@yourdomain.com"
},
"typeVersion": 2.1
},
{
"id": "a79a0618-ac63-4aaf-8337-b9ccc5940eef",
"name": "Summarize Results",
"type": "n8n-nodes-base.code",
"position": [
1280,
360
],
"parameters": {
"jsCode": "// Summarize the results of the property lead search
const leads = $input.all();
const totalLeads = leads.length;
// Calculate the highest lead score
let highestScore = 0;
if (totalLeads > 0) {
highestScore = Math.max(...leads.map(item => item.json.lead_score || 0));
}
// Return a summary object
return {
json: {
total_leads: totalLeads,
highest_score: highestScore,
execution_date: new Date().toISOString(),
success: true
}
};"
},
"typeVersion": 2
},
{
"id": "cf6bbc2b-4892-4612-aee9-7f255f627a67",
"name": "Sticky Note - Workflow Overview",
"type": "n8n-nodes-base.stickyNote",
"position": [
-420,
-520
],
"parameters": {
"width": 800,
"height": 280,
"content": "# Property Lead Automation Workflow
This workflow automatically searches for potential real estate leads based on configured criteria, obtains owner contact information through skip tracing, and pushes the leads to your CRM. It can be run manually or scheduled to run daily.
## Steps: Property Search → Filter Results → Skip Trace → Format Data → Export (Excel & CRM)"
},
"typeVersion": 1
},
{
"id": "ff155460-3f4e-44e8-aac7-4b84dff2dceb",
"name": "Sticky Note - Triggers",
"type": "n8n-nodes-base.stickyNote",
"position": [
-420,
-160
],
"parameters": {
"color": 2,
"width": 320,
"height": 620,
"content": "## Workflow Triggers
This workflow can be triggered in two ways:
1. **Scheduled Trigger** - Runs automatically every day at the specified time
2. **Manual Trigger** - Run the workflow on-demand by clicking Execute"
},
"typeVersion": 1
},
{
"id": "8c127497-0dc4-428d-a946-14c10b9572cb",
"name": "Sticky Note - Property Search",
"type": "n8n-nodes-base.stickyNote",
"position": [
-80,
-180
],
"parameters": {
"color": 4,
"width": 320,
"height": 650,
"content": "## Search Configuration
Configure your property search criteria including:
- Location (city, state, zip)
- Property type
- Value range
- Equity percentage
- Owner status
- And more
Edit the 'search_parameters' in the Set node to customize your search criteria."
},
"typeVersion": 1
},
{
"id": "20ad7c5e-5d73-4b43-b5b0-6c9eaae18400",
"name": "Sticky Note - Data Processing",
"type": "n8n-nodes-base.stickyNote",
"position": [
260,
-180
],
"parameters": {
"color": 5,
"width": 880,
"height": 660,
"content": "## Property Data Processing
1. **Search Properties API** - Connect to BatchData to search for properties
2. **Filter Property Results** - Apply additional filtering logic and calculate lead scores based on factors like:
- Equity percentage
- Years of ownership
- Owner occupancy status
- Tax delinquency
- Recent sales activity
3. **Get Owner Contact Info** - Skip trace each property to find owner contact details
4. **Format Lead Data** - Structure the data for CRM and reporting"
},
"typeVersion": 1
},
{
"id": "a0254233-a0af-43b2-8258-0820d8fdd49d",
"name": "Sticky Note - Output",
"type": "n8n-nodes-base.stickyNote",
"position": [
1180,
-180
],
"parameters": {
"color": 6,
"width": 560,
"height": 920,
"content": "## Lead Output Options
1. **Create Excel Spreadsheet** - Generates an Excel file with all property leads and details
2. **Push to CRM** - Adds leads to your CRM system (HubSpot in this example, but can be changed to Salesforce, Zoho, etc.)
3. **Email Notification** - Sends a summary email with the Excel file attached
4. **Summarize Results** - Provides a summary of the execution results"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "ff401fba-f56d-4d22-b259-d23a4e141a98",
"connections": {
"Daily Schedule": {
"main": [
[
{
"node": "Configure Search Parameters",
"type": "main",
"index": 0
}
]
]
},
"Format Lead Data": {
"main": [
[
{
"node": "Create Excel Spreadsheet",
"type": "main",
"index": 0
},
{
"node": "Push to CRM",
"type": "main",
"index": 0
},
{
"node": "Summarize Results",
"type": "main",
"index": 0
}
]
]
},
"Summarize Results": {
"main": [
[
{
"node": "Email Notification",
"type": "main",
"index": 0
}
]
]
},
"Search Properties API": {
"main": [
[
{
"node": "Filter Property Results",
"type": "main",
"index": 0
}
]
]
},
"Get Owner Contact Info": {
"main": [
[
{
"node": "Format Lead Data",
"type": "main",
"index": 0
}
]
]
},
"Filter Property Results": {
"main": [
[
{
"node": "Get Owner Contact Info",
"type": "main",
"index": 0
}
]
]
},
"Create Excel Spreadsheet": {
"main": [
[
{
"node": "Email Notification",
"type": "main",
"index": 0
}
]
]
},
"Configure Search Parameters": {
"main": [
[
{
"node": "Search Properties API",
"type": "main",
"index": 0
}
]
]
},
"When clicking \"Execute Workflow\"": {
"main": [
[
{
"node": "Configure Search Parameters",
"type": "main",
"index": 0
}
]
]
}
}
}
功能特点
- 自动检测新邮件
- AI智能内容分析
- 自定义分类规则
- 批量处理能力
- 详细的处理日志
技术分析
节点类型及作用
- Manualtrigger
- Scheduletrigger
- Httprequest
- Set
- Code
复杂度评估
配置难度:
维护难度:
扩展性:
实施指南
前置条件
- 有效的Gmail账户
- n8n平台访问权限
- Google API凭证
- AI分类服务订阅
配置步骤
- 在n8n中导入工作流JSON文件
- 配置Gmail节点的认证信息
- 设置AI分类器的API密钥
- 自定义分类规则和标签映射
- 测试工作流执行
- 配置定时触发器(可选)
关键参数
| 参数名称 | 默认值 | 说明 |
|---|---|---|
| maxEmails | 50 | 单次处理的最大邮件数量 |
| confidenceThreshold | 0.8 | 分类置信度阈值 |
| autoLabel | true | 是否自动添加标签 |
最佳实践
优化建议
- 定期更新AI分类模型以提高准确性
- 根据邮件量调整处理批次大小
- 设置合理的分类置信度阈值
- 定期清理过期的分类规则
安全注意事项
- 妥善保管API密钥和认证信息
- 限制工作流的访问权限
- 定期审查处理日志
- 启用双因素认证保护Gmail账户
性能优化
- 使用增量处理减少重复工作
- 缓存频繁访问的数据
- 并行处理多个邮件分类任务
- 监控系统资源使用情况
故障排除
常见问题
邮件未被正确分类
检查AI分类器的置信度阈值设置,适当降低阈值或更新训练数据。
Gmail认证失败
确认Google API凭证有效且具有正确的权限范围,重新进行OAuth授权。
调试技巧
- 启用详细日志记录查看每个步骤的执行情况
- 使用测试邮件验证分类逻辑
- 检查网络连接和API服务状态
- 逐步执行工作流定位问题节点
错误处理
工作流包含以下错误处理机制:
- 网络超时自动重试(最多3次)
- API错误记录和告警
- 处理失败邮件的隔离机制
- 异常情况下的回滚操作