8
n8n 中文网amn8n.com

我的工作流3

中级

这是一个Social Media, Multimodal AI领域的自动化工作流,包含 14 个节点。主要使用 Code, HttpRequest, ScheduleTrigger 等节点。 使用AI细分和个性化邮件营销的自动竞争对手交易监控

前置要求
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "WvrxIu1q3XWWkbdc",
  "meta": {
    "instanceId": "f4b0efaa33080e7774e0d9285c40c7abcd2c6f7cf1a8b901fa7106170dd4cda3",
    "templateCredsSetupCompleted": true
  },
  "name": "我的工作流 3",
  "tags": [
    {
      "id": "IZ3TCbPLnlWJhHZq",
      "name": "Amazon Intelligence",
      "createdAt": "2025-08-04T14:47:06.250Z",
      "updatedAt": "2025-08-04T14:47:06.250Z"
    }
  ],
  "nodes": [
    {
      "id": "132eecf6-60ed-4ed8-b03f-bbbe6953d7ab",
      "name": "工作流概览",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        384,
        -512
      ],
      "parameters": {
        "width": 400,
        "height": 336,
        "content": "🎯 **交易情报与营销自动化**"
      },
      "typeVersion": 1
    },
    {
      "id": "a2c2a600-ce18-4e32-be65-712efd6ad9e5",
      "name": "每日触发器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        432,
        -96
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 8 * * *"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "993aac58-cd3e-4721-80d1-b6fa96df976f",
      "name": "数据收集设置",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        784,
        -512
      ],
      "parameters": {
        "width": 280,
        "height": 344,
        "content": "🔍 **数据收集**"
      },
      "typeVersion": 1
    },
    {
      "id": "6463dcab-4fd9-474d-a245-2e62a5c957e7",
      "name": "获取交易数据",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        640,
        -96
      ],
      "parameters": {
        "url": "https://www.retailmenot.com/coupons/electronics",
        "options": {
          "timeout": 30000
        }
      },
      "typeVersion": 4.1
    },
    {
      "id": "df3fdb3f-9749-4ea2-90e0-6d4c4ab88288",
      "name": "分析交易",
      "type": "n8n-nodes-base.code",
      "position": [
        832,
        -96
      ],
      "parameters": {
        "jsCode": "// Deal Analysis Engine\nconst dealData = $input.first().json;\n\nfunction analyzeDealData() {\n  // Simulated deal analysis since scraping might fail\n  const mockDeals = [\n    { store: 'Amazon', discount: 30, category: 'electronics', title: 'Echo Dot Sale' },\n    { store: 'Best Buy', discount: 25, category: 'electronics', title: 'Laptop Deals' },\n    { store: 'Target', discount: 40, category: 'home', title: 'Home Decor Sale' },\n    { store: 'Walmart', discount: 20, category: 'general', title: 'Weekly Specials' }\n  ];\n\n  const analysis = {\n    summary: {\n      total_deals: mockDeals.length,\n      average_discount: Math.round(mockDeals.reduce((sum, deal) => sum + deal.discount, 0) / mockDeals.length),\n      top_categories: ['electronics', 'home', 'general'],\n      analyzed_at: new Date().toISOString()\n    },\n    competitive_intelligence: {\n      threat_level: mockDeals.some(d => d.discount > 35) ? 'High' : 'Medium',\n      top_discounts: mockDeals.sort((a, b) => b.discount - a.discount).slice(0, 3),\n      market_activity: 'Active'\n    },\n    urgent_deals: mockDeals.filter(d => d.discount >= 30)\n  };\n\n  return analysis;\n}\n\nconst result = analyzeDealData();\nreturn [{ json: result }];"
      },
      "typeVersion": 2
    },
    {
      "id": "7f254e0e-3156-467a-900f-79a5731cc2ce",
      "name": "细分客户",
      "type": "n8n-nodes-base.code",
      "position": [
        1040,
        -96
      ],
      "parameters": {
        "jsCode": "// Customer Segmentation\nconst dealAnalysis = $input.first().json;\n\nfunction segmentCustomers() {\n  // Simulated customer database\n  const customers = [\n    { id: 'C001', name: 'John Smith', email: 'john@example.com', value: 2500, segment: 'vip' },\n    { id: 'C002', name: 'Sarah Johnson', email: 'sarah@example.com', value: 450, segment: 'bargain_hunter' },\n    { id: 'C003', name: 'Mike Wilson', email: 'mike@example.com', value: 1200, segment: 'at_risk' },\n    { id: 'C004', name: 'Emma Davis', email: 'emma@example.com', value: 180, segment: 'new_prospect' }\n  ];\n\n  const segments = {\n    vip_customers: customers.filter(c => c.segment === 'vip'),\n    bargain_hunters: customers.filter(c => c.segment === 'bargain_hunter'),\n    at_risk: customers.filter(c => c.segment === 'at_risk'),\n    new_prospects: customers.filter(c => c.segment === 'new_prospect')\n  };\n\n  return {\n    segments,\n    total_customers: customers.length,\n    segmentation_date: new Date().toISOString()\n  };\n}\n\nconst segmentation = segmentCustomers();\nreturn [{ json: segmentation }];"
      },
      "typeVersion": 2
    },
    {
      "id": "72b9f5bf-701b-4cee-84c4-368a1564d266",
      "name": "情报处理",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1056,
        -512
      ],
      "parameters": {
        "width": 300,
        "height": 332,
        "content": "🧠 **情报处理**"
      },
      "typeVersion": 1
    },
    {
      "id": "832b51e7-1d72-463a-b41c-e8f4a0b1605e",
      "name": "生成个性化优惠",
      "type": "n8n-nodes-base.code",
      "position": [
        1232,
        -96
      ],
      "parameters": {
        "jsCode": "// Generate Personalized Offers\nconst dealAnalysis = $input.item(0).json;\nconst customerSegments = $input.item(1).json;\n\nfunction generateOffers(deals, segments) {\n  const avgDiscount = deals.summary.average_discount;\n  const threatLevel = deals.competitive_intelligence.threat_level;\n  \n  const offers = {\n    campaign_batches: [],\n    offer_summary: {\n      total_campaigns: 0,\n      projected_revenue: 0,\n      generated_at: new Date().toISOString()\n    }\n  };\n\n  // Generate offers for each segment\n  Object.keys(segments.segments).forEach(segmentName => {\n    const segmentCustomers = segments.segments[segmentName];\n    if (segmentCustomers.length === 0) return;\n\n    let discountLevel;\n    let priority;\n    \n    switch(segmentName) {\n      case 'vip_customers':\n        discountLevel = Math.max(15, avgDiscount - 5);\n        priority = 'Medium';\n        break;\n      case 'bargain_hunters':\n        discountLevel = Math.max(avgDiscount + 5, 35);\n        priority = threatLevel === 'High' ? 'Critical' : 'High';\n        break;\n      case 'at_risk':\n        discountLevel = Math.max(avgDiscount + 10, 40);\n        priority = 'Critical';\n        break;\n      case 'new_prospects':\n        discountLevel = Math.max(20, avgDiscount);\n        priority = 'Low';\n        break;\n      default:\n        discountLevel = avgDiscount;\n        priority = 'Medium';\n    }\n\n    const batch = {\n      segment: segmentName,\n      customer_count: segmentCustomers.length,\n      discount_percentage: discountLevel,\n      priority: priority,\n      estimated_revenue: segmentCustomers.length * 75, // $75 average per customer\n      customers: segmentCustomers.map(customer => ({\n        id: customer.id,\n        email: customer.email,\n        name: customer.name,\n        discount_code: `DEAL${Math.random().toString(36).substr(2, 6).toUpperCase()}`,\n        personalized_discount: discountLevel\n      }))\n    };\n\n    offers.campaign_batches.push(batch);\n  });\n\n  offers.offer_summary.total_campaigns = offers.campaign_batches.length;\n  offers.offer_summary.projected_revenue = offers.campaign_batches.reduce(\n    (sum, batch) => sum + batch.estimated_revenue, 0\n  );\n\n  return offers;\n}\n\nconst personalizedOffers = generateOffers(dealAnalysis, customerSegments);\nreturn [{ json: personalizedOffers }];"
      },
      "typeVersion": 2
    },
    {
      "id": "e4406cd2-d562-4763-8d00-d144c19a0224",
      "name": "创建电子邮件营销活动",
      "type": "n8n-nodes-base.code",
      "position": [
        1440,
        -96
      ],
      "parameters": {
        "jsCode": "// Email Campaign Generator\nconst offers = $input.first().json;\n\nfunction createEmailCampaigns(offerData) {\n  const campaigns = [];\n  \n  offerData.campaign_batches.forEach(batch => {\n    batch.customers.forEach(customer => {\n      const emailContent = {\n        to: customer.email,\n        subject: getSubjectLine(batch.segment, customer.personalized_discount),\n        campaign_id: `CAMP_${batch.segment.toUpperCase()}_${Date.now()}`,\n        customer_name: customer.name,\n        discount_code: customer.discount_code,\n        discount_percentage: customer.personalized_discount,\n        priority: batch.priority,\n        template: getEmailTemplate(batch.segment)\n      };\n      \n      campaigns.push(emailContent);\n    });\n  });\n\n  return {\n    email_campaigns: campaigns,\n    summary: {\n      total_emails: campaigns.length,\n      high_priority: campaigns.filter(c => c.priority === 'Critical').length,\n      projected_revenue: offerData.offer_summary.projected_revenue,\n      created_at: new Date().toISOString()\n    }\n  };\n}\n\nfunction getSubjectLine(segment, discount) {\n  const subjects = {\n    'vip_customers': `Exclusive ${discount}% Off - VIP Access Only`,\n    'bargain_hunters': `Flash Sale: ${discount}% Off Everything!`,\n    'at_risk': `We Miss You! ${discount}% Off to Come Back`,\n    'new_prospects': `Welcome! ${discount}% Off Your First Order`\n  };\n  return subjects[segment] || `Special ${discount}% Discount Just for You`;\n}\n\nfunction getEmailTemplate(segment) {\n  const templates = {\n    'vip_customers': 'elegant_gold_template',\n    'bargain_hunters': 'urgent_red_template',\n    'at_risk': 'warm_comeback_template',\n    'new_prospects': 'welcome_blue_template'\n  };\n  return templates[segment] || 'default_template';\n}\n\nconst emailCampaigns = createEmailCampaigns(offers);\nreturn [{ json: emailCampaigns }];"
      },
      "typeVersion": 2
    },
    {
      "id": "c2b6338b-4cbd-4d7c-b9e3-dcca918e0640",
      "name": "营销活动生成",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1360,
        -512
      ],
      "parameters": {
        "width": 300,
        "height": 332,
        "content": "📧 **营销活动生成**"
      },
      "typeVersion": 1
    },
    {
      "id": "786942ab-42c2-4ed5-b101-81209bdb0525",
      "name": "生成分析报告",
      "type": "n8n-nodes-base.code",
      "position": [
        1632,
        -96
      ],
      "parameters": {
        "jsCode": "// Analytics Dashboard\nconst dealAnalysis = $input.item(0).json;\nconst customerSegments = $input.item(1).json;\nconst offers = $input.item(2).json;\nconst emailCampaigns = $input.item(3).json;\n\nfunction generateReport(deals, segments, offerData, campaigns) {\n  const report = {\n    executive_summary: {\n      date: new Date().toISOString().split('T')[0],\n      total_deals_analyzed: deals.summary.total_deals,\n      average_market_discount: deals.summary.average_discount,\n      threat_level: deals.competitive_intelligence.threat_level,\n      customers_targeted: segments.total_customers,\n      campaigns_created: campaigns.summary.total_emails,\n      projected_revenue: campaigns.summary.projected_revenue\n    },\n    key_insights: [\n      `Market average discount: ${deals.summary.average_discount}%`,\n      `Competitive threat level: ${deals.competitive_intelligence.threat_level}`,\n      `${segments.total_customers} customers across ${Object.keys(segments.segments).length} segments`,\n      `${campaigns.summary.high_priority} high-priority campaigns scheduled`\n    ],\n    immediate_actions: [],\n    segment_performance: {},\n    next_execution: new Date(Date.now() + 24*60*60*1000).toISOString()\n  };\n\n  // Generate immediate actions based on threat level\n  if (deals.competitive_intelligence.threat_level === 'High') {\n    report.immediate_actions.push('Deploy aggressive counter-pricing strategy');\n    report.immediate_actions.push('Increase email send frequency');\n  }\n\n  // Segment performance breakdown\n  offerData.campaign_batches.forEach(batch => {\n    report.segment_performance[batch.segment] = {\n      customers: batch.customer_count,\n      discount_offered: batch.discount_percentage + '%',\n      priority: batch.priority,\n      estimated_revenue: batch.estimated_revenue\n    };\n  });\n\n  return report;\n}\n\nconst analyticsReport = generateReport(dealAnalysis, customerSegments, offers, emailCampaigns);\nreturn [{ json: analyticsReport }];"
      },
      "typeVersion": 2
    },
    {
      "id": "4927d96d-2da5-4ead-aaf9-c3e334e5097f",
      "name": "发送每日报告",
      "type": "n8n-nodes-base.httpRequest",
      "disabled": true,
      "position": [
        1840,
        -96
      ],
      "parameters": {
        "url": "https://api.sendgrid.com/v3/mail/send",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "personalizations",
              "value": "=[{ \"to\": [{ \"email\": \"manager@company.com\" }], \"subject\": \"Daily Deal Intelligence Report\" }]"
            },
            {
              "name": "from",
              "value": "={ \"email\": \"noreply@yourcompany.com\", \"name\": \"Deal Intelligence System\" }"
            },
            {
              "name": "content",
              "value": "=[{ \"type\": \"text/html\", \"value\": `<h2>Daily Deal Intelligence Report</h2><p>Market Threat Level: <strong>${$json.executive_summary.threat_level}</strong></p><p>Campaigns Created: <strong>${$json.executive_summary.campaigns_created}</strong></p><p>Projected Revenue: <strong>$${$json.executive_summary.projected_revenue}</strong></p>` }]"
            }
          ]
        },
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.1
    },
    {
      "id": "08755947-82c6-4031-a316-aa702fa1ce2d",
      "name": "分析与报告",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1664,
        -512
      ],
      "parameters": {
        "width": 280,
        "height": 328,
        "content": "📊 **分析与报告**"
      },
      "typeVersion": 1
    },
    {
      "id": "f5b2262b-a391-4e6b-9ec3-1278087db280",
      "name": "电子邮件配置",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1936,
        -512
      ],
      "parameters": {
        "width": 280,
        "height": 328,
        "content": "⚙️ **需要电子邮件设置**"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "636eafc1-e538-49df-bad6-0f5ba335d428",
  "connections": {
    "Analyze Deals": {
      "main": [
        [
          {
            "node": "Segment Customers",
            "type": "main",
            "index": 0
          },
          {
            "node": "Generate Analytics Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Daily Trigger": {
      "main": [
        [
          {
            "node": "Fetch Deal Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Deal Data": {
      "main": [
        [
          {
            "node": "Analyze Deals",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Analytics Report": {
      "main": [
        [
          {
            "node": "Send Daily Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Personalized Offers": {
      "main": [
        [
          {
            "node": "Create Email Campaigns",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 社交媒体, 多模态 AI

需要付费吗?

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

工作流信息
难度等级
中级
节点数量14
分类2
节点类型4
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

外部链接
在 n8n.io 查看

分享此工作流