8
n8n 中文网amn8n.com

自动化推荐工作流

高级

这是一个Social Media, Multimodal AI领域的自动化工作流,包含 34 个节点。主要使用 If, Set, Code, Slack, Webhook 等节点。 使用GPT-4处理推荐信,并通过Google表格自动生成社交媒体卡片

前置要求
  • Slack Bot Token 或 Webhook URL
  • HTTP Webhook 端点(n8n 会自动生成)
  • Google Drive API 凭证
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "",
  "meta": {
    "instanceId": "",
    "templateCredsSetupCompleted": false
  },
  "name": "自动化推荐工作流",
  "tags": [],
  "nodes": [
    {
      "id": "4665148e-044d-44bc-982e-e253eb60f173",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -496,
        -64
      ],
      "parameters": {
        "color": 7,
        "width": 389,
        "height": 392,
        "content": "## 🚀 工作流开始:推荐收集"
      },
      "typeVersion": 1
    },
    {
      "id": "0edf9e7e-bd71-42da-b028-2ea8b7c8439b",
      "name": "Webhook触发器",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -304,
        192
      ],
      "webhookId": "",
      "parameters": {
        "path": "testimonial-webhook",
        "options": {},
        "httpMethod": "POST",
        "responseMode": "lastNode"
      },
      "typeVersion": 1.1
    },
    {
      "id": "3d5b7bac-6955-4c7b-bfbf-525b4b01416e",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        -96
      ],
      "parameters": {
        "color": 7,
        "width": 357,
        "height": 411,
        "content": "## ✅ 数据验证和清理"
      },
      "typeVersion": 1
    },
    {
      "id": "e2b98cfd-f458-491f-adf9-951daae6c164",
      "name": "数据验证",
      "type": "n8n-nodes-base.code",
      "position": [
        64,
        192
      ],
      "parameters": {
        "jsCode": "// Data Validation Code for n8n\n// This code cleans and validates testimonial data from the webhook\n\nconst items = $input.all();\nconst cleanedItems = [];\n\nfor (const item of items) {\n  // Access the body data from webhook\n  const data = item.json.body || item.json;\n  \n  // Extract and clean fields\n  let name = (data.name || data.Name || '').trim();\n  let designation = (data.designation || data.Designation || data.role || '').trim();\n  let testimonial = (data.testimonial_text || data.testimonial || data.Testimonial || '').trim();\n  let photoUrl = (data.photo_url || data.Photo || data.photo || '').trim();\n  let email = (data.email || data.Email || '').trim();\n  \n  // Validation: Check required fields\n  if (!name || name.length < 2) {\n    name = 'Anonymous User';\n  }\n  \n  if (!testimonial || testimonial.length < 10) {\n    // Skip invalid testimonials\n    console.log('Skipping invalid testimonial - too short or empty');\n    continue;\n  }\n  \n  // Set defaults for optional fields\n  if (!designation) {\n    designation = 'Valued Customer';\n  }\n  \n  // Generate fallback avatar if no photo provided\n  if (!photoUrl || !photoUrl.startsWith('http')) {\n    photoUrl = 'https://ui-avatars.com/api/?name=' + encodeURIComponent(name) + '&size=400&background=4F46E5&color=fff&bold=true';\n  }\n  \n  // Clean testimonial text - remove extra spaces and HTML tags\n  testimonial = testimonial\n    .replace(/\\s+/g, ' ')    // Replace multiple spaces with single space\n    .replace(/[<>]/g, '')     // Remove < and > to prevent XSS\n    .trim();\n  \n  // Create clean object with all data\n  cleanedItems.push({\n    json: {\n      name: name,\n      designation: designation,\n      testimonial: testimonial,\n      photoUrl: photoUrl,\n      email: email,\n      timestamp: new Date().toISOString(),\n      originalLength: testimonial.length,\n      source: 'webhook'\n    }\n  });\n}\n\n// If no valid testimonials found, throw error\nif (cleanedItems.length === 0) {\n  throw new Error('No valid testimonials found after validation');\n}\n\nreturn cleanedItems;"
      },
      "typeVersion": 2
    },
    {
      "id": "825f049a-a2d5-47e2-83e7-57b319193a2e",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        288,
        -48
      ],
      "parameters": {
        "color": 7,
        "width": 295,
        "height": 379,
        "content": "## 🤖 AI增强设置"
      },
      "typeVersion": 1
    },
    {
      "id": "6f77780d-a9e7-44a3-834b-89f41fa40219",
      "name": "设置AI提示",
      "type": "n8n-nodes-base.set",
      "position": [
        368,
        192
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "prompt-assignment",
              "name": "prompt",
              "type": "string",
              "value": "=You are a professional editor. Polish the following testimonial to be grammatically perfect while maintaining the original tone, enthusiasm, and authenticity. Keep it natural and conversational. Do not add fake details or change the meaning. Keep the length similar to the original.\n\nOriginal testimonial:\n{{ $json.testimonial }}\n\nReturn ONLY the improved testimonial text, nothing else. No quotes, no preamble."
            }
          ]
        }
      },
      "typeVersion": 3.3
    },
    {
      "id": "b9b9ee52-9122-4c55-90f3-cdfbda8bfcfc",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        608,
        -32
      ],
      "parameters": {
        "color": 7,
        "width": 327,
        "height": 347,
        "content": "## 🧠 OpenAI处理"
      },
      "typeVersion": 1
    },
    {
      "id": "5fdf887b-e1aa-4122-8ede-1ef586072a06",
      "name": "OpenAI增强",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        640,
        192
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4-turbo-preview",
          "cachedResultName": "GPT-4-TURBO-PREVIEW"
        },
        "options": {
          "maxTokens": 300,
          "temperature": 0.3
        },
        "messages": {
          "values": [
            {
              "content": "={{ $json.prompt }}"
            }
          ]
        }
      },
      "credentials": {
        "openAiApi": {
          "id": "YOUR_OPENAI_API_KEY",
          "name": "OpenAI API"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "d3b64d7c-c54e-4eeb-bec6-9b56ac3dba07",
      "name": "便签说明4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        944,
        -16
      ],
      "parameters": {
        "color": 7,
        "width": 343,
        "height": 331,
        "content": "## 📦 提取AI响应"
      },
      "typeVersion": 1
    },
    {
      "id": "2f0c7201-a5e4-4b3a-be91-0f200f8f249f",
      "name": "提取AI响应",
      "type": "n8n-nodes-base.code",
      "position": [
        1040,
        192
      ],
      "parameters": {
        "jsCode": "// Extract AI Response Code (Updated for OpenAI format)\n// This extracts the enhanced testimonial from OpenAI and merges with previous data\n\nconst items = $input.all();\n\nreturn items.map((item) => {\n  // Get the original data from Data Validation node\n  const previousData = $('Data Validation').item.json;\n  \n  // Extract AI response from OpenAI's response format\n  // OpenAI returns: [{ message: { content: \"text\" } }]\n  let aiResponse;\n  \n  if (Array.isArray(item.json) && item.json[0]?.message?.content) {\n    // Handle array format from OpenAI\n    aiResponse = item.json[0].message.content;\n  } else if (item.json.message?.content) {\n    // Handle object format\n    aiResponse = item.json.message.content;\n  } else if (item.json.choices?.[0]?.message?.content) {\n    // Handle choices format\n    aiResponse = item.json.choices[0].message.content;\n  } else if (item.json.text) {\n    // Handle simple text format\n    aiResponse = item.json.text;\n  } else {\n    // Fallback to original testimonial if extraction fails\n    aiResponse = previousData.testimonial;\n  }\n  \n  // Return merged data with both original and enhanced testimonial\n  return {\n    json: {\n      ...previousData,                              // Keep all original data\n      originalTestimonial: previousData.testimonial,  // Save original\n      testimonial: aiResponse.trim(),                 // Use enhanced version\n      enhanced: true,                                 // Mark as enhanced\n      aiModel: 'gpt-4-turbo'                         // Track which model used\n    }\n  };\n});"
      },
      "typeVersion": 2
    },
    {
      "id": "7ec4da11-b438-4877-be02-f967719aef64",
      "name": "便签说明5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1296,
        -96
      ],
      "parameters": {
        "color": 7,
        "width": 272,
        "height": 427,
        "content": "## 🎨 HTML模板生成"
      },
      "typeVersion": 1
    },
    {
      "id": "b57bee88-1bc0-4bd2-b6cc-73ff96b56797",
      "name": "生成HTML模板",
      "type": "n8n-nodes-base.code",
      "position": [
        1344,
        192
      ],
      "parameters": {
        "jsCode": "// Generate HTML Template Code - FIXED VERSION\n// Creates a beautiful branded testimonial card with proper image handling\n\nconst items = $input.all();\n\nreturn items.map(item => {\n  const data = item.json;\n  \n  // Function to escape HTML special characters (prevent XSS)\n  const escapeHtml = (text) => {\n    return text\n      .replace(/&/g, '&amp;')\n      .replace(/</g, '&lt;')\n      .replace(/>/g, '&gt;')\n      .replace(/\"/g, '&quot;')\n      .replace(/'/g, '&#039;');\n  };\n  \n  // Get initials for fallback\n  const getInitials = (name) => {\n    return name\n      .split(' ')\n      .map(n => n[0])\n      .join('')\n      .toUpperCase()\n      .substring(0, 2);\n  };\n  \n  const initials = getInitials(data.name);\n  \n  // Generate the HTML testimonial card\n  const html = `<!DOCTYPE html>\n<html>\n<head>\n  <meta charset=\"UTF-8\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n  <link href=\"https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap\" rel=\"stylesheet\">\n  <style>\n    * {\n      margin: 0;\n      padding: 0;\n      box-sizing: border-box;\n    }\n    \n    body {\n      width: 800px;\n      height: 600px;\n      display: flex;\n      align-items: center;\n      justify-content: center;\n      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n      font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;\n      padding: 40px;\n    }\n    \n    .testimonial-card {\n      background: white;\n      border-radius: 24px;\n      padding: 48px;\n      max-width: 700px;\n      box-shadow: 0 20px 60px rgba(0,0,0,0.3);\n      position: relative;\n      overflow: hidden;\n    }\n    \n    .quote-icon {\n      position: absolute;\n      top: 30px;\n      left: 40px;\n      font-size: 80px;\n      color: #667eea;\n      opacity: 0.15;\n      font-family: Georgia, serif;\n      line-height: 1;\n    }\n    \n    .star-rating {\n      color: #fbbf24;\n      font-size: 24px;\n      margin-bottom: 20px;\n      position: relative;\n      z-index: 1;\n      letter-spacing: 4px;\n    }\n    \n    .testimonial-text {\n      font-size: 20px;\n      line-height: 1.7;\n      color: #2d3748;\n      margin-bottom: 32px;\n      position: relative;\n      z-index: 1;\n      font-style: italic;\n    }\n    \n    .author-section {\n      display: flex;\n      align-items: center;\n      gap: 20px;\n      position: relative;\n      z-index: 1;\n    }\n    \n    .author-photo-wrapper {\n      width: 72px;\n      height: 72px;\n      border-radius: 50%;\n      border: 4px solid #667eea;\n      box-shadow: 0 4px 12px rgba(0,0,0,0.1);\n      overflow: hidden;\n      display: flex;\n      align-items: center;\n      justify-content: center;\n      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n      flex-shrink: 0;\n    }\n    \n    .author-photo {\n      width: 100%;\n      height: 100%;\n      object-fit: cover;\n      display: block;\n    }\n    \n    .author-initials {\n      display: none;\n      font-size: 28px;\n      font-weight: 700;\n      color: white;\n      user-select: none;\n    }\n    \n    .author-photo-wrapper.fallback .author-photo {\n      display: none;\n    }\n    \n    .author-photo-wrapper.fallback .author-initials {\n      display: flex;\n    }\n    \n    .author-info h3 {\n      font-size: 22px;\n      color: #1a202c;\n      margin-bottom: 4px;\n      font-weight: 700;\n    }\n    \n    .author-info p {\n      font-size: 16px;\n      color: #718096;\n      font-weight: 500;\n    }\n    \n    .brand-logo {\n      position: absolute;\n      bottom: 30px;\n      right: 40px;\n      font-size: 14px;\n      color: #a0aec0;\n      font-weight: 600;\n      letter-spacing: 1px;\n      text-transform: uppercase;\n    }\n    \n    .decorative-circle {\n      position: absolute;\n      width: 200px;\n      height: 200px;\n      border-radius: 50%;\n      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n      opacity: 0.05;\n      bottom: -100px;\n      right: -100px;\n    }\n  </style>\n  <script>\n    function handleImageError(img) {\n      var wrapper = img.parentElement;\n      wrapper.classList.add('fallback');\n    }\n  </script>\n</head>\n<body>\n  <div class=\"testimonial-card\">\n    <div class=\"quote-icon\">\"</div>\n    <div class=\"decorative-circle\"></div>\n    \n    <div class=\"star-rating\">\n      ★★★★★\n    </div>\n    \n    <div class=\"testimonial-text\">\n      \"${escapeHtml(data.testimonial)}\"\n    </div>\n    \n    <div class=\"author-section\">\n      <div class=\"author-photo-wrapper\">\n        <img \n          src=\"${data.photoUrl}\" \n          alt=\"${escapeHtml(data.name)}\" \n          class=\"author-photo\" \n          onerror=\"handleImageError(this)\"\n        />\n        <div class=\"author-initials\">${initials}</div>\n      </div>\n      <div class=\"author-info\">\n        <h3>${escapeHtml(data.name)}</h3>\n        <p>${escapeHtml(data.designation)}</p>\n      </div>\n    </div>\n    \n    <div class=\"brand-logo\">\n      YOUR BRAND\n    </div>\n  </div>\n</body>\n</html>`;\n  \n  // Generate a unique filename\n  const fileName = `${data.name.replace(/\\s+/g, '_')}_Testimonial_${new Date().getTime()}.png`;\n  \n  // Return the HTML and filename\n  return {\n    json: {\n      ...data,           // Keep all previous data\n      html: html,        // Add HTML template\n      fileName: fileName // Add filename for later use\n    }\n  };\n});"
      },
      "typeVersion": 2
    },
    {
      "id": "50e726ce-705a-4bc4-a98e-f0653a26ad47",
      "name": "便签 6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1584,
        -80
      ],
      "parameters": {
        "color": 7,
        "width": 256,
        "height": 427,
        "content": "## 📸 HTML转图像转换"
      },
      "typeVersion": 1
    },
    {
      "id": "abad8276-3b3e-4414-ad1d-7c4105e86d03",
      "name": "HTML/CSS转图像",
      "type": "n8n-nodes-htmlcsstoimage.htmlCssToImage",
      "position": [
        1632,
        192
      ],
      "parameters": {
        "html_content": "={{ $json.html }}"
      },
      "credentials": {
        "htmlcsstoimgApi": {
          "id": "YOUR_HTMLCSSTOIMG_API_KEY",
          "name": "Htmlcsstoimg API"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "1c06771d-8cb7-4870-b3a1-a6960ffd0029",
      "name": "便签 7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1856,
        -80
      ],
      "parameters": {
        "color": 7,
        "width": 288,
        "height": 411,
        "content": "## ⬇️ 下载图像"
      },
      "typeVersion": 1
    },
    {
      "id": "94929251-c783-4ede-9710-6aff9fc59ea1",
      "name": "下载图片",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1920,
        192
      ],
      "parameters": {
        "url": "={{ $json.image_url }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "b79caf76-ec04-4a57-90d7-7ae3ff802e2e",
      "name": "## 为什么选择 4o 模型?👆",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2160,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 288,
        "height": 443,
        "content": "## ☁️ Google Drive上传"
      },
      "typeVersion": 1
    },
    {
      "id": "e028a171-81b8-4120-b443-414fbd77dc46",
      "name": "上传到Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        2208,
        192
      ],
      "parameters": {
        "name": "={{ $('Generate HTML Template').item.json.fileName }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive",
          "cachedResultUrl": "https://drive.google.com/drive/my-drive",
          "cachedResultName": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_GOOGLE_DRIVE_FOLDER_ID",
          "cachedResultUrl": "https://drive.google.com/drive/folders/YOUR_GOOGLE_DRIVE_FOLDER_ID",
          "cachedResultName": "testimonial data"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "YOUR_GOOGLE_DRIVE_OAUTH2_API_KEY",
          "name": "Google Drive OAuth2"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "7990f760-83ad-483c-adea-2f9eac6020d7",
      "name": "更新 Google 表格",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2544,
        192
      ],
      "parameters": {
        "columns": {
          "value": {
            "Name": "={{ $('Generate HTML Template').item.json.name }}",
            "Email": "={{ $('Generate HTML Template').item.json.email }}",
            "Source": "={{ $('Generate HTML Template').item.json.source }}",
            "Status": "Pending Approval",
            "Drive ID": "={{ $json.id }}",
            "Enhanced": "={{ $('Generate HTML Template').item.json.enhanced ? 'Yes' : 'No' }}",
            "Timestamp": "={{ $('Generate HTML Template').item.json.timestamp }}",
            "Image Link": "={{ $json.webViewLink }}",
            "Designation": "={{ $('Generate HTML Template').item.json.designation }}",
            "Testimonial": "={{ $('Generate HTML Template').item.json.testimonial }}",
            "Original Length": "={{ $('Generate HTML Template').item.json.originalLength }}",
            "Original Testimonial": "={{ $('Generate HTML Template').item.json.originalTestimonial }}"
          },
          "schema": [
            {
              "id": "Timestamp",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Timestamp",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Designation",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Designation",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Testimonial",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Testimonial",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Original Testimonial",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Original Testimonial",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Image Link",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Image Link",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Drive ID",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Drive ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Original Length",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Original Length",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Enhanced",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Enhanced",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Source",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Source",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Posted to Social",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Posted to Social",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Posted At",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Posted At",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Drive ID"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1358321955,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_GOOGLE_SHEETS_ID_HERE/edit#gid=1358321955",
          "cachedResultName": "Testimonial Database"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_GOOGLE_SHEETS_ID_HERE",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_GOOGLE_SHEETS_ID_HERE/edit?usp=drivesdk",
          "cachedResultName": "Feedback Log"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "YOUR_GOOGLE_SHEETS_OAUTH2_API_KEY",
          "name": "Google Sheets OAuth2"
        }
      },
      "typeVersion": 4.4
    },
    {
      "id": "496bcc78-6f79-4719-aaf6-14f83c27e13b",
      "name": "便签10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2768,
        -48
      ],
      "parameters": {
        "color": 7,
        "width": 272,
        "height": 395,
        "content": "## 📢 Slack通知"
      },
      "typeVersion": 1
    },
    {
      "id": "1baf7d5d-478f-4d8c-9fe1-4b0a1947109e",
      "name": "发送Slack通知",
      "type": "n8n-nodes-base.slack",
      "position": [
        2832,
        192
      ],
      "webhookId": "",
      "parameters": {
        "text": "=🎉 *New Testimonial Received!*\n\n*Customer Details:*\n- Name: {{ $('Generate HTML Template').item.json.name }}\n- Role: {{ $('Generate HTML Template').item.json.designation }}\n- Email: {{ $('Generate HTML Template').item.json.email }}\n\n*Testimonial:*\n_\"{{ $('Generate HTML Template').item.json.testimonial }}\"_\n\n*Original:*\n_\"{{ $('Generate HTML Template').item.json.originalTestimonial }}\"_\n\n*Image Preview:*\n{{ $('Upload to Google Drive').item.json.webViewLink }}\n\n*Database:*\nStatus: {{ $json.Status }}\nSheet: [View Testimonial Database](https://docs.google.com/spreadsheets/d/YOUR_SHEET_ID/edit)\n\n*Actions Required:*\n1. Review the testimonial and image\n2. Update status in Google Sheet to \"Approved\" or \"Rejected\"\n3. Approved testimonials will auto-post to social media\n\n---\n_Submitted via webhook at {{ $('Generate HTML Template').item.json.timestamp }}_",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "SLACK_CHANNEL_ID",
          "cachedResultName": "SLACK_CHANNEL_NAME"
        },
        "otherOptions": {}
      },
      "credentials": {
        "slackApi": {
          "id": "YOUR_SLACK_API_KEY",
          "name": "Slack API"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "f95c7659-6e59-468b-9a53-4047a8e2f337",
      "name": "便签11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1184,
        512
      ],
      "parameters": {
        "color": 7,
        "width": 368,
        "height": 411,
        "content": "## ⏰ 计划触发器 - 批准检查器"
      },
      "typeVersion": 1
    },
    {
      "id": "93107afd-1e32-4f86-928a-baf2e9c5a24c",
      "name": "每 5 分钟",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        1280,
        784
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "75ff904f-6a28-459a-999c-f959985088ee",
      "name": "便签12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1568,
        576
      ],
      "parameters": {
        "color": 7,
        "width": 320,
        "height": 347,
        "content": "## 📖 读取数据库"
      },
      "typeVersion": 1
    },
    {
      "id": "f5180c82-5bc1-4676-9e57-08e65ff741ae",
      "name": "读取Google Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1616,
        784
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1358321955,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_GOOGLE_SHEET_ID/edit#gid=1358321955",
          "cachedResultName": "Testimonial Database"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_GOOGLE_SHEET_ID",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_GOOGLE_SHEET_ID/edit?usp=drivesdk",
          "cachedResultName": "Feedback Log"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "YOUR_GOOGLE_SHEETS_OAUTH2_API_KEY",
          "name": "Google Sheets OAuth2"
        }
      },
      "typeVersion": 4.4
    },
    {
      "id": "2a5196a0-de9c-48cc-8e48-805c2228ddf7",
      "name": "便签13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1904,
        528
      ],
      "parameters": {
        "color": 7,
        "width": 320,
        "height": 395,
        "content": "## ✔️ 条件过滤器"
      },
      "typeVersion": 1
    },
    {
      "id": "f516c987-5dac-4580-abf1-a29c111e5b5e",
      "name": "如果已批准且未发布",
      "type": "n8n-nodes-base.if",
      "position": [
        1984,
        784
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 1,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "status-check",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.Status }}",
              "rightValue": "Approved"
            },
            {
              "id": "not-posted",
              "operator": {
                "type": "string",
                "operation": "empty",
                "singleValue": true
              },
              "leftValue": "={{ $json['Posted to Social'] }}",
              "rightValue": "Yes"
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "96ecfaa0-9c6d-4711-941c-4cdeb8397026",
      "name": "便签 14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2240,
        432
      ],
      "parameters": {
        "color": 7,
        "width": 320,
        "height": 395,
        "content": "## 📱 社交媒体就绪通知"
      },
      "typeVersion": 1
    },
    {
      "id": "9284d544-2cf9-4d67-830e-ef3de1990efb",
      "name": "通知准备发布",
      "type": "n8n-nodes-base.slack",
      "position": [
        2304,
        672
      ],
      "webhookId": "",
      "parameters": {
        "text": "=✅ *Testimonial Ready for Social Media!*\n\n*Customer Details:*\n- Name: {{ $json.Name }}\n- Role: {{ $json.Designation }}\n- Email: {{ $json.Email }}\n\n*Testimonial:*\n_\"{{ $json.Testimonial }}\"_\n\n*Original:*\n_\"{{ $json['Original Testimonial'] }}\"_\n\n*View Image:*\n{{ $json['Image Link'] }}\n\n---\n\n*📱 Ready-to-Post Social Media Text:*\n\n🌟 Hear what our clients say!\n\n\"{{ $json.Testimonial }}\"\n\n— {{ $json.Name }}, {{ $json.Designation }}\n\n#ClientSuccess #Testimonial #CustomerReview\n\n---\n\n*Actions Required:*\n1. Copy the text above\n2. Post to Twitter & LinkedIn manually\n3. This testimonial will be marked as processed\n\n_Automated by n8n • {{ $now.format('MMM DD, YYYY @ HH:mm') }}_",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "SLACK_CHANNEL_ID",
          "cachedResultName": "SLACK_CHANNEL_NAME"
        },
        "otherOptions": {}
      },
      "credentials": {
        "slackApi": {
          "id": "YOUR_SLACK_API_KEY",
          "name": "Slack API"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "e63a79cc-2313-4d65-a349-b261dd17fecd",
      "name": "便签 15",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2592,
        512
      ],
      "parameters": {
        "color": 7,
        "width": 336,
        "height": 315,
        "content": "## 🔄 标记为已处理"
      },
      "typeVersion": 1
    },
    {
      "id": "6b7e87eb-7958-4bab-bde9-db1df08c3148",
      "name": "标记为已发布",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2656,
        672
      ],
      "parameters": {
        "columns": {
          "value": {
            "Drive ID": "={{ $('IF Approved & Not Posted').item.json[\"Drive ID\"] }}",
            "Posted At": "={{ $now.toISO() }}",
            "Posted to Social": "Ready - Manual Post Required"
          },
          "schema": [
            {
              "id": "Timestamp",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Timestamp",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Designation",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Designation",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Testimonial",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Testimonial",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Original Testimonial",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Original Testimonial",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Image Link",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Image Link",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Drive ID",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Drive ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Original Length",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Original Length",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Enhanced",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Enhanced",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Source",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Source",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Posted to Social",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Posted to Social",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Posted At",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Posted At",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Drive ID"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1358321955,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_GOOGLE_SHEETS_ID_HERE/edit#gid=1358321955",
          "cachedResultName": "Testimonial Database"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_GOOGLE_SHEETS_ID_HERE",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_GOOGLE_SHEETS_ID_HERE/edit?usp=drivesdk",
          "cachedResultName": "Feedback Log"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "YOUR_GOOGLE_SHEETS_OAUTH2_API_KEY",
          "name": "Google Sheets OAuth2"
        }
      },
      "typeVersion": 4.4
    },
    {
      "id": "bf68641b-18b6-4fe7-ba2e-bf418f44aef8",
      "name": "便签 9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2464,
        -32
      ],
      "parameters": {
        "color": 7,
        "width": 288,
        "height": 363,
        "content": "## 📊 数据库更新"
      },
      "typeVersion": 1
    },
    {
      "id": "564a5664-46e7-417c-b01c-ffc7f761184b",
      "name": "便签16",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -896,
        -128
      ],
      "parameters": {
        "color": 7,
        "width": 368,
        "height": 560,
        "content": "## 📋 **首先设置凭据**"
      },
      "typeVersion": 1
    },
    {
      "id": "4be49892-0a67-4eb2-8cc9-c18b92559a76",
      "name": "便签17",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1312,
        -48
      ],
      "parameters": {
        "color": 7,
        "width": 384,
        "height": 480,
        "content": "## 🧪 **测试工作流**"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "",
  "connections": {
    "Set AI Prompt": {
      "main": [
        [
          {
            "node": "OpenAI Enhancement",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Image": {
      "main": [
        [
          {
            "node": "Upload to Google Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Data Validation": {
      "main": [
        [
          {
            "node": "Set AI Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Every 5 Minutes": {
      "main": [
        [
          {
            "node": "Read Google Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook Trigger": {
      "main": [
        [
          {
            "node": "Data Validation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTML/CSS to Image": {
      "main": [
        [
          {
            "node": "Download Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Google Sheet": {
      "main": [
        [
          {
            "node": "IF Approved & Not Posted",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Enhancement": {
      "main": [
        [
          {
            "node": "Extract AI Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract AI Response": {
      "main": [
        [
          {
            "node": "Generate HTML Template",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Google Sheet": {
      "main": [
        [
          {
            "node": "Send Slack Notification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notify Ready to Post": {
      "main": [
        [
          {
            "node": "Mark as Posted",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate HTML Template": {
      "main": [
        [
          {
            "node": "HTML/CSS to Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload to Google Drive": {
      "main": [
        [
          {
            "node": "Update Google Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF Approved & Not Posted": {
      "main": [
        [
          {
            "node": "Notify Ready to Post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

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

需要付费吗?

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

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

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

作者
Jitesh Dugar

Jitesh Dugar

@jiteshdugar

AI Automation Specialist - OpenAI, CRM & Automation Expert with a solid understanding of various tools that include Zapier, Make, Zoho CRM, Hubspot, Google Sheets, Airtable, Pipedrive, Google Analytics, and more.

外部链接
在 n8n.io 查看

分享此工作流