多渠道营销活动消息系统 - GPT-4与Salesforce
这是一个Lead Nurturing、Multimodal AI领域的自动化工作流,包含 14 个节点。主要使用 Switch、Twilio、EmailSend、Salesforce、HttpRequest 等节点。 集成GPT-4和Salesforce的多渠道营销活动消息系统
- •Salesforce OAuth 凭证
- •可能需要目标 API 的认证凭证
- •OpenAI API Key
{
"meta": {
"instanceId": "9a562c06a632241f66aadd52a495ad98e76b760ef5cfce9c319a4759c47cd94e",
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "2d468c09-fe3a-4c8a-b4af-817a762a8d7a",
"name": "发送短信",
"type": "n8n-nodes-base.twilio",
"notes": "Send SMS using Twilio",
"position": [
-60,
420
],
"parameters": {
"to": "={{ $json.message.content.to }}",
"from": "+1xxxxxxxxxx",
"message": "={{ $json.message.content.message }}",
"options": {}
},
"credentials": {
"twilioApi": {
"id": "vM2JERicK76paC8V",
"name": "Twilio account"
}
},
"typeVersion": 1
},
{
"id": "ad400bf5-b77d-4f76-be46-fe6cc76e5a0c",
"name": "OpenAI",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
-660,
720
],
"parameters": {
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1",
"cachedResultName": "GPT-4.1"
},
"options": {},
"messages": {
"values": [
{
"role": "system",
"content": "You are “MarCom AI” – a specialist that writes outbound messages for Salesforce Campaigns.\n{\n \"contactMethod\": \"SMS | Email | Telegram | WhatsApp | (null)\",\n \"phone\": \"(###) ###-#### or empty\",\n \"email\": \"user@example.com or empty\",\n \"campaignDescription\": \"Full campaign description text\"\n}\n\nYour job\n\nPick the channel in contactMethod.\n• If it is null, default to Email if an email exists; otherwise default to SMS.\n\nCraft one concise, personalized outbound message that:\n• References the key value proposition(s) and date/location found in campaignDescription.\n• Includes an explicit next-step call-to-action (book demo, visit booth, etc.).\n\nObey channel rules:\n• SMS / WhatsApp / Telegram → ≤ 160 characters, no subject.\n• Email → Provide a subject ≤ 60 chars and a body ≤ 120 words.\n\nReturn a SINGLE JSON object only – no extra commentary – with exactly these keys:\n{\n \"method\": \"SMS | Email | Telegram | WhatsApp\",\n \"from\": \"PowerSwitch Marketing <marketing@example.com>\",\n \"to\": \"<email or phone based on method>\",\n \"subject\": \"<for Email only, otherwise omit>\",\n \"message\": \"<text body or SMS content>\"\n}\n"
},
{
"role": "assistant",
"content": "=Here is the record data for this recipient:\n\n{\n \"contactMethod\": \"{{ $json.Contact.ContactMethod__c }}\",\n \"phone\": \"{{ $json.Phone }}\",\n \"email\": \"{{ $json.Email }}\",\n \"campaignDescription\": \"{{ $('Fetch Campaign').item.json.Description }}\"\n}\n\nGenerate the outbound communication in the required JSON format."
}
]
},
"jsonOutput": true
},
"credentials": {
"openAiApi": {
"id": "ciKVFfcmd36noEnL",
"name": "OpenAi account"
}
},
"typeVersion": 1.8
},
{
"id": "b9e3bee1-83c7-4a60-94fe-110236d0c8a9",
"name": "发送邮件",
"type": "n8n-nodes-base.emailSend",
"position": [
-64,
620
],
"webhookId": "653bd18e-774f-45aa-b28f-858e1a2bba32",
"parameters": {
"html": "={{ $json.message.content.message }}",
"options": {},
"subject": "={{ $json.message.content.subject }}",
"toEmail": "={{ $json.message.content.to }}",
"fromEmail": "youremail@yourdomain.com"
},
"credentials": {
"smtp": {
"id": "JNtQ5FosqXaLKi5O",
"name": "SMTP account"
}
},
"typeVersion": 2.1
},
{
"id": "d89a36de-0978-430e-a248-a7cd7e73ee37",
"name": "HTTP 请求",
"type": "n8n-nodes-base.httpRequest",
"position": [
156,
720
],
"parameters": {
"url": "=https:/xxxxx.my.salesforce.com/services/data/v60.0/sobjects/CampaignMember/{{ $('Fetch Campaign Members').item.json.Id }}",
"method": "PATCH",
"options": {},
"jsonBody": "={\n \"Processed__c\" : true\n} ",
"sendBody": true,
"specifyBody": "json",
"authentication": "predefinedCredentialType",
"nodeCredentialType": "salesforceOAuth2Api"
},
"credentials": {
"salesforceOAuth2Api": {
"id": "XhjgRQcYQYRIgOfD",
"name": "Salesforce account"
}
},
"typeVersion": 4.2
},
{
"id": "649c91de-560e-47e4-b498-217246ced614",
"name": "获取营销活动",
"type": "n8n-nodes-base.salesforce",
"position": [
-1100,
720
],
"parameters": {
"query": "=SELECT Id, Description,Name FROM Campaign",
"resource": "search"
},
"credentials": {
"salesforceOAuth2Api": {
"id": "XhjgRQcYQYRIgOfD",
"name": "Salesforce account"
}
},
"typeVersion": 1
},
{
"id": "f5a813de-06b0-40a8-baff-1a51a9857647",
"name": "便签说明",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1180,
520
],
"parameters": {
"content": "## 获取营销活动"
},
"typeVersion": 1
},
{
"id": "d208f08e-6fc8-47fa-a1e1-e2bcae764d5e",
"name": "便签说明1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-920,
460
],
"parameters": {
"height": 220,
"content": "## 获取营销活动成员"
},
"typeVersion": 1
},
{
"id": "ca76386b-6908-4541-9ff2-8fb69b3237a2",
"name": "获取营销活动成员",
"type": "n8n-nodes-base.salesforce",
"position": [
-880,
720
],
"parameters": {
"query": "=SELECT Id, CampaignId, Contact.ContactMethod__c, Email, Phone FROM CampaignMember where CampaignId = '{{ $json.Id }}'",
"resource": "search"
},
"credentials": {
"salesforceOAuth2Api": {
"id": "XhjgRQcYQYRIgOfD",
"name": "Salesforce account"
}
},
"typeVersion": 1
},
{
"id": "e72ebcee-0d97-4e57-b0f8-167ea0fe9d27",
"name": "便签说明2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-660,
440
],
"parameters": {
"height": 240,
"content": "## 生成个性化消息"
},
"typeVersion": 1
},
{
"id": "553f9b9b-20f2-4ead-a2d1-1111c21bf176",
"name": "便签说明3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-400,
520
],
"parameters": {
"content": "## 通信方法映射"
},
"typeVersion": 1
},
{
"id": "44581a57-558b-4aa6-a27d-e03e62fc9393",
"name": "通信方法切换器",
"type": "n8n-nodes-base.switch",
"notes": "Route to Email flow",
"position": [
-284,
699
],
"parameters": {
"rules": {
"rules": [
{
"value2": "SMS"
},
{
"output": 1,
"value2": "Email"
},
{
"output": 2,
"value2": "Whatsapp"
},
{
"output": 3,
"value2": "Telegram"
}
]
},
"value1": "={{ $json.message.content.method }}",
"dataType": "string"
},
"typeVersion": 1
},
{
"id": "4ac45980-237a-41ba-adcd-f3cd6945699d",
"name": "发送 Whatsapp",
"type": "n8n-nodes-base.twilio",
"notes": "Send SMS using Twilio",
"position": [
-64,
820
],
"parameters": {
"to": "={{ $json.message.content.to }}",
"from": "+1xxxxxxxxxx",
"message": "={{ $json.message.content.message }}",
"options": {},
"toWhatsapp": true
},
"credentials": {
"twilioApi": {
"id": "vM2JERicK76paC8V",
"name": "Twilio account"
}
},
"typeVersion": 1
},
{
"id": "44bf7301-b466-48aa-b1c8-490fd8cb6e01",
"name": "便签说明4",
"type": "n8n-nodes-base.stickyNote",
"position": [
160,
480
],
"parameters": {
"height": 220,
"content": "## 标记营销活动成员为已处理"
},
"typeVersion": 1
},
{
"id": "0e592700-06db-4cc9-ad37-924360f113a6",
"name": "定时触发器",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
-1320,
720
],
"parameters": {
"rule": {
"interval": [
{}
]
}
},
"typeVersion": 1.2
}
],
"pinData": {},
"connections": {
"OpenAI": {
"main": [
[
{
"node": "Communication Method Switch",
"type": "main",
"index": 0
}
]
]
},
"Send SMS": {
"main": [
[
{
"node": "HTTP Request",
"type": "main",
"index": 0
}
]
]
},
"Send Email": {
"main": [
[
{
"node": "HTTP Request",
"type": "main",
"index": 0
}
]
]
},
"Send Whatsapp": {
"main": [
[
{
"node": "HTTP Request",
"type": "main",
"index": 0
}
]
]
},
"Fetch Campaign": {
"main": [
[
{
"node": "Fetch Campaign Members",
"type": "main",
"index": 0
}
]
]
},
"Schedule Trigger": {
"main": [
[
{
"node": "Fetch Campaign",
"type": "main",
"index": 0
}
]
]
},
"Fetch Campaign Members": {
"main": [
[
{
"node": "OpenAI",
"type": "main",
"index": 0
}
]
]
},
"Communication Method Switch": {
"main": [
[
{
"node": "Send SMS",
"type": "main",
"index": 0
}
],
[
{
"node": "Send Email",
"type": "main",
"index": 0
}
],
[
{
"node": "Send Whatsapp",
"type": "main",
"index": 0
}
],
[
{
"node": "HTTP Request",
"type": "main",
"index": 0
}
]
]
}
}
}如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
这是一个中级难度的工作流,适用于Lead Nurturing、Multimodal AI等场景。适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
Le Nguyen
@leeseiferSalesforce Architect with 10+ years of experience in CRM, integrations, and automation. Skilled in Apex, LWC, REST APIs, and full-stack dev (JavaScript, .NET). I build secure, scalable workflows in n8n—connecting Salesforce, Stripe, and more. Passionate about lead scoring, data sync, and secure field masking. Certified Application Architect with deep expertise in platform, integration, and data architecture.
分享此工作流