8
n8n 中文网amn8n.com

使用 Salesforce、Gemini AI 和 Brevo 为高消费客户发送个性化酒店奖励邮件

中级

这是一个Social Media, Multimodal AI领域的自动化工作流,包含 9 个节点。主要使用 If, Code, Salesforce, SendInBlue, SalesforceTrigger 等节点。 使用 Salesforce、Gemini AI 和 Brevo 为高消费客户发送个性化酒店奖励邮件

前置要求
  • Salesforce OAuth 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "b6731f6e46273cffeac6b5188a5b3bcb0840c00108e73b48ae2b799ac6e8e081",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "688b53dc-149a-41b6-8447-cde64f7a5c5c",
      "name": "Basic LLM Chain",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        -700,
        -120
      ],
      "parameters": {
        "text": "=You are an AI rewards assistant for a hotel CRM.  \n\nWhen given the guest’s spend summary in optional paid amenities:\n-  {{ $json.Total_Room_Service_Spend__c }}\n-  {{ $json.Total_Minibar_Spend__c }}\n- {{ $json.Total_Laundry_Spend__c }}\n- {{ $json.Total_Late_Checkout_Fees__c }}\n- {{ $json.Total_Extra_Bed_Fees__c }}\n- {{ $json.Total_Airport_Transfer_Spend__c }}\n\n**Task:**\n- STRICTLY CHOOSE THE OPTION BETWEEN THESE 5 REWARDS: ROOM SERVICE, MINI BAR, LAUNDARY, LATE CHECKOUT, EXTRA BED, AIRPORT TRANSFER\n- Look at which services the guest *already paid for* (any spend > $0)\n- Randomly pick **one** of the *other* services they haven’t used (spend = 0). If used everything then look for where the user spend the most on... and then give the offer on which he spent less on.\n- Offer a realistic, valuable, **one-time free perk** on that unused service\n- The offer should be concrete, short, and sound like a real hotel promotion (e.g., \"One free airport drop on your next stay\", \"Free late checkout on your next booking\")\n\n**Output:**\nAlways return JSON with this structure:\n{\n  \"suggested_offer\": \"...\"\n}\n\nDo not include anything else.\n",
        "batching": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.7
    },
    {
      "id": "01bd11e8-4a82-4906-91e6-8e26976f0bbf",
      "name": "结构化输出解析器",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -540,
        100
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"suggested_offer\": \"...\"\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "a741b4b3-0cec-4c40-aa3d-517d7d1ea315",
      "name": "检查最新退房记录",
      "type": "n8n-nodes-base.salesforceTrigger",
      "position": [
        -1620,
        -100
      ],
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyWeek"
            }
          ]
        },
        "triggerOn": "customObjectUpdated",
        "customObject": "Guest__c"
      },
      "credentials": {
        "salesforceOAuth2Api": {
          "id": "qUb78he7pQeZF8ZR",
          "name": "Salesforce account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ae15b8b0-3f66-434d-8730-5baf744984e7",
      "name": "提取退房信息",
      "type": "n8n-nodes-base.salesforce",
      "position": [
        -1400,
        -100
      ],
      "parameters": {
        "options": {
          "fields": [
            "Name",
            "guest_id__c",
            "phone__c",
            "Total_Room_Service_Spend__c",
            "Total_Minibar_Spend__c",
            "Total_Laundry_Spend__c",
            "Total_Late_Checkout_Fees__c",
            "Total_Extra_Bed_Fees__c",
            "Total_Airport_Transfer_Spend__c",
            "Email__c"
          ]
        },
        "resource": "customObject",
        "operation": "getAll",
        "returnAll": true,
        "customObject": "Guest__c"
      },
      "credentials": {
        "salesforceOAuth2Api": {
          "id": "qUb78he7pQeZF8ZR",
          "name": "Salesforce account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "75fc4e53-a12d-4dfe-85cf-f1ceb4a80c19",
      "name": "寻找VIP客户",
      "type": "n8n-nodes-base.code",
      "position": [
        -1180,
        -100
      ],
      "parameters": {
        "jsCode": "return $input.all().map(item => {\n  const data = item.json;\n\n  const total = \n    (data.Total_Room_Service_Spend__c || 0) +\n    (data.Total_Minibar_Spend__c || 0) +\n    (data.Total_Laundry_Spend__c || 0) +\n    (data.Total_Late_Checkout_Fees__c || 0) +\n    (data.Total_Airport_Transfer_Spend__c || 0);\n\n  return {\n    json: {\n      ...data,\n      total\n    }\n  };\n});\n"
      },
      "typeVersion": 2
    },
    {
      "id": "26bd7967-8885-474e-bac2-c1aabb7bcf2f",
      "name": "检查是否超过阈值",
      "type": "n8n-nodes-base.if",
      "position": [
        -960,
        -100
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "e8573d13-cdb4-48b7-a52d-f923cf4f9ebb",
              "operator": {
                "type": "number",
                "operation": "gte"
              },
              "leftValue": "={{ $json.total }}",
              "rightValue": 50
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "e04b8b27-474b-498d-ba44-04110d993217",
      "name": "发放个性化优惠",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleVertex",
      "position": [
        -700,
        100
      ],
      "parameters": {
        "options": {},
        "modelName": "gemini-2.5-flash",
        "projectId": {
          "__rl": true,
          "mode": "list",
          "value": "slidingpuzzlepro1",
          "cachedResultName": "Slidingpuzzlepro"
        }
      },
      "credentials": {
        "googleApi": {
          "id": "bK1tErzcCo9nt89s",
          "name": "Google Service Account account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "6e1c0c4b-a767-4420-bf30-1a91c4d539e6",
      "name": "通过电子邮件发送优惠",
      "type": "n8n-nodes-base.sendInBlue",
      "position": [
        -340,
        -120
      ],
      "parameters": {
        "sender": "emailplaceholder",
        "subject": "={{ $('Check the threshold exceedings').item.json.Name }}, We Have Something Special for Your Next Stay",
        "sendHTML": true,
        "htmlContent": "=<!DOCTYPE html> <html> <head>   <meta charset=\"UTF-8\" />   <title>Exclusive Offer Just for You</title>   <style>     body {       font-family: Arial, sans-serif;       background-color: #f7f7f7;       margin: 0;       padding: 0;     }     .container {       background-color: #ffffff;       width: 100%;       max-width: 600px;       margin: 40px auto;       border-radius: 8px;       box-shadow: 0 0 10px rgba(0,0,0,0.1);       overflow: hidden;     }     .header {       background-color: #003366;       color: #ffffff;       padding: 20px;       text-align: center;       font-size: 22px;     }     .content {       padding: 30px 20px;       text-align: center;     }     .offer {       font-size: 18px;       color: #333333;       margin: 20px 0;       font-weight: bold;     }     .footer {       font-size: 12px;       color: #999999;       text-align: center;       padding: 20px;     }   </style> </head> <body>   <div class=\"container\">     <div class=\"header\">       A Special Thank You     </div>     <div class=\"content\">       <p>We're delighted to share an exclusive offer with you:</p>       <p class=\"offer\">{{ $json.output.suggested_offer }}</p>       <p>We look forward to welcoming you again soon!</p>     </div>     <div class=\"footer\">       &copy; 2025 Hilton Garden Inn New York Times Square South. All rights reserved.     </div>   </div> </body> </html>",
        "receipients": "={{ $('Check the threshold exceedings').item.json.Email__c }}",
        "requestOptions": {},
        "additionalFields": {}
      },
      "credentials": {
        "sendInBlueApi": {
          "id": "ysEmyjdU0adBBOqN",
          "name": "Brevo account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "9135c69d-9372-4f77-8fd9-b50e915daa64",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2446.94942319236,
        -420
      ],
      "parameters": {
        "width": 760,
        "height": 1120,
        "content": "## 📩 **高消费客人奖励自动化**"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Basic LLM Chain": {
      "main": [
        [
          {
            "node": "Send offer via email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Look For VIP Clients": {
      "main": [
        [
          {
            "node": "Check the threshold exceedings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Extract Checkout information": {
      "main": [
        [
          {
            "node": "Look For VIP Clients",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Give Away Personalised Offers": {
      "ai_languageModel": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Check for any latest checkouts": {
      "main": [
        [
          {
            "node": "Extract Checkout information",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check the threshold exceedings": {
      "main": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

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

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流