8
n8n 中文网amn8n.com

赞助交易邮件自动化

高级

这是一个AI Summarization, Multimodal AI领域的自动化工作流,包含 16 个节点。主要使用 If, Set, Gmail, GmailTrigger, Agent 等节点。 使用Gmail和GPT-4自动化赞助交易邮件回复

前置要求
  • Google 账号和 Gmail API 凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "Kb8GjaSSiC75Pcdk",
  "meta": {
    "instanceId": "87616dfce72ffd690a51f4d408ac3b27a946f12a1119e0e281f5ed271497219e",
    "templateCredsSetupCompleted": true
  },
  "name": "Email Automation for Sponsored Deals",
  "tags": [],
  "nodes": [
    {
      "id": "26059112-67e7-4a81-b187-70dcbf8ff44f",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -440,
        -100
      ],
      "parameters": {
        "simple": false,
        "filters": {},
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "qRfscNFGDLVMQs6g",
          "name": "Gmail account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "fbcb4645-50d3-4e2c-9c27-8c89333f39db",
      "name": "Edit Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        -220,
        -100
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "d78ea8f1-65f1-4cb6-bb27-c652a5a63d94",
              "name": "From",
              "type": "string",
              "value": "={{ $json.headers.from }}"
            },
            {
              "id": "1b4a5b47-5057-4ac2-9e03-f3bb0d98134b",
              "name": "Subject",
              "type": "string",
              "value": "={{ $json.subject }}"
            },
            {
              "id": "f9968f70-b3a0-4000-9a64-c6504317eeff",
              "name": "Email_Body",
              "type": "string",
              "value": "={{ $json.text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "1ecfa39b-9749-4364-96af-f4d5db5486c6",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -20,
        -100
      ],
      "parameters": {
        "text": "=# System Prompt for Sponsored Email Detection Agent\n\n## Role\nYou are an **Email Sentiment & Sponsorship Detection Agent**.  \nYour primary task is to analyze incoming emails, determine if they are **sponsored emails**, identify the sender’s **intention**, and return results in a structured JSON format.  \n\n---\n\n## Behavior\n- Always be **objective and concise**.  \n- Never provide extra explanations outside the defined output format.  \n- Focus strictly on analyzing **email content, tone, and intent**.  \n\n---\n\n## Output Format\nAlways respond in **Markdown** using the following JSON structure:  \n\n```json\n{\n  \"isSponsoredEmail\": true/false,\n  \"reason\": \"Concise explanation of why you classified it this way\"\n}\n\n\n {{ $json.Email_Body }}",
        "options": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2
    },
    {
      "id": "7d9b4d22-b83a-43c6-b2d1-081c12771d56",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -100,
        120
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "qlhg6EzexBZ9bwXO",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "b251365d-8bff-441e-8ab3-250ba216bac3",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        160,
        200
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"isSponsoredEmail\": {\n\t\t\t\"type\": \"boolean\"\n\t\t},\n\t\t\"reason\": {\n\t\t\t\"type\": \"string\"\t\t\t\n\t\t}\n\t}\n}"
      },
      "typeVersion": 1.2
    },
    {
      "id": "dc80f4ae-c9dd-4847-8142-b34598ee7f2c",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        360,
        -100
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "a4ad6006-2906-4101-b106-d232132206fd",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.output.isSponsoredEmail }}",
              "rightValue": "true"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "e089a21d-712d-4c85-991a-6a751ab6361f",
      "name": "No Operation, do nothing",
      "type": "n8n-nodes-base.noOp",
      "position": [
        680,
        100
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "e27b672a-3cc6-45d7-a7b8-80f56e1c1c87",
      "name": "AI Agent1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        680,
        -380
      ],
      "parameters": {
        "text": "=#Role\nYou are a professional and courteous email assistant responding on behalf of [Your Company Name]. You've just received a sponsored email offer. Please read the email content and draft a polite, professional reply informing the sender that while you appreciate their interest, your company is not currently accepting sponsored content.\n\nKindly explain that you have specific criteria that must be met before considering sponsorships, such as alignment with your brand values, audience relevance, and internal planning cycles. Offer to keep their information on file and encourage them to reach out in the future when sponsorship opportunities reopen.\n\nMaintain a friendly tone, express gratitude for their outreach, and do not close the door completely. End with a courteous sign-off.\n\n# Prepare Email body as below. \nHello,\n\nThank you for your interest in collaborating with [Your Company Name]. We truly appreciate the time and effort you’ve taken to reach out to us.\n\nWe do occasionally accept sponsored content, provided it meets a few important criteria that ensure value and relevance for our audience. Specifically, we look for partnerships that:  \n\n1. **Align with Our Brand Values** – The content should reflect the professionalism, integrity, and focus areas of our company.  \n2. **Serve Our Audience** – Sponsored material should provide clear benefits, insights, or solutions that are relevant and meaningful to our community.  \n3. **Complement Our Planning Cycles** – We accept sponsored opportunities at select times during the year to align with our editorial calendar and campaign schedule.  \n\nIf your offer meets these guidelines, we’d be glad to explore the possibility further. Please feel free to share details about your proposal, including the nature of the content, target audience, and how it aligns with the values above.  \n\nWe carefully review all opportunities and will respond with next steps if there’s a good fit. Even if the timing isn’t right, we’re happy to keep your information on file for future consideration.  \n\nThank you again for thinking of [Your Company Name]. We look forward to staying connected.  \n\nWarm regards,  \n[Your Name]  \n[Your Company Name]  \n\n\n\nEmail Details are as below:\n{{ $('Gmail Trigger').item.json.headers.from }}\n{{ $('Gmail Trigger').item.json.headers.subject }}\n{{ $('Gmail Trigger').item.json.text }}\n\nNote: just prepare the email body and do not include message headers. ",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "e74356b8-3f5f-440c-81d8-9f62ec468711",
      "name": "OpenAI Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        680,
        -120
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "qlhg6EzexBZ9bwXO",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "a0edd387-37ee-4ad6-b12f-9c1b5005f6ba",
      "name": "Gmail",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1180,
        -380
      ],
      "webhookId": "0167c16b-b9fd-41e1-850e-8274c27dd4bb",
      "parameters": {
        "message": "={{ $json.output }}",
        "options": {},
        "emailType": "text",
        "messageId": "={{ $('Gmail Trigger').item.json.id }}",
        "operation": "reply"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "qRfscNFGDLVMQs6g",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "8579055e-fca8-4b96-a02f-b41251841d16",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -620,
        -300
      ],
      "parameters": {
        "width": 300,
        "height": 360,
        "content": "## Email Trigger\nRead inbox every minute and then send to next node for Analysis"
      },
      "typeVersion": 1
    },
    {
      "id": "b5f4a066-8ee7-4fbc-a627-59b1f199647c",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -300,
        -260
      ],
      "parameters": {
        "width": 260,
        "height": 320,
        "content": "## Extract\n- Header\n- Subject\n- EmailBody"
      },
      "typeVersion": 1
    },
    {
      "id": "36ff7139-a3fe-40d5-ae61-30ee62910207",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        -340
      ],
      "parameters": {
        "color": 4,
        "width": 360,
        "height": 220,
        "content": "## Process and validate Confirm If Sponsored \n\n- The AI agent will read through the email and confirm if the email is an sponsored email or not.\n- It then pass this boolean to If Else node."
      },
      "typeVersion": 1
    },
    {
      "id": "ce10097e-b873-4bfe-8171-3b86c7d2c0d5",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        500,
        -560
      ],
      "parameters": {
        "color": 6,
        "width": 440,
        "content": "## Prepare Email Body \n- This node will prepare email body with company policies on accepting any sponsored deals."
      },
      "typeVersion": 1
    },
    {
      "id": "7da70e7a-8805-4426-a639-afffc41bd1b6",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1140,
        -220
      ],
      "parameters": {
        "content": "## Reply\n- This node will send an email to the Sender\n"
      },
      "typeVersion": 1
    },
    {
      "id": "2f793a0b-343e-4ab6-975a-0efafe48304c",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        740,
        240
      ],
      "parameters": {
        "content": "## If not a Sponsored Email. Do Nothing. \n\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "624043af-906a-4f2a-99d0-46399fdf2e2b",
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "AI Agent1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent1": {
      "main": [
        [
          {
            "node": "Gmail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - AI 摘要总结, 多模态 AI

需要付费吗?

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

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

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

作者
Pramod Kumar Rathoure

Pramod Kumar Rathoure

@prathoure

Design and build custom n8n workflows that: ⚡ Eliminate repetitive work 📊 Integrate tools like Google Workspace, CRMs, and APIs ✅ Deliver faster, error-free results I create solutions that save time, boost accuracy, and let teams focus on high-value work. For me, automation isn’t just about technology—it’s about freeing people from busywork so they can do what matters most. let’s talk—I can help you turn them into smooth, automated workflows.

外部链接
在 n8n.io 查看

分享此工作流