AI智能体信使
高级
这是一个Content Creation、Multimodal AI领域的自动化工作流,包含 34 个节点。主要使用 Set、Code、Switch、Webhook、Function 等节点。 使用GPT-4的Facebook Messenger机器人,支持文本、图像和语音处理
前置要求
- •HTTP Webhook 端点(n8n 会自动生成)
- •可能需要目标 API 的认证凭证
- •OpenAI API Key
使用的节点 (34 个)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "bBJOoh6tRVSg50K5",
"meta": {
"instanceId": "4373d1c98d837a02928f24e76c24879728ab83407616320d7d7808e429ea0a4e",
"templateCredsSetupCompleted": true
},
"name": "AI Agent 信使",
"tags": [],
"nodes": [
{
"id": "2ccd1577-6b09-4dba-a008-382833689fab",
"name": "OpenAI 聊天模型",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
2016,
704
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"id": "jl5FyiQarFxAvt8F",
"name": "OpenAi account"
}
},
"typeVersion": 1.2
},
{
"id": "d588ba3b-d9db-481a-bfdb-dea8a0d0f275",
"name": "简单记忆",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"position": [
2192,
704
],
"parameters": {
"sessionKey": "={{ $('Webhook1').item.json.body.entry[0].messaging[0].sender.id }}",
"sessionIdType": "customKey"
},
"typeVersion": 1.3
},
{
"id": "e97f4fe7-b9fd-465b-8229-9a117ce46b81",
"name": "计算器",
"type": "@n8n/n8n-nodes-langchain.toolCalculator",
"position": [
2352,
704
],
"parameters": {},
"typeVersion": 1
},
{
"id": "6a045e89-c2c1-4bef-b8bd-35eb6d524ee1",
"name": "维基百科",
"type": "@n8n/n8n-nodes-langchain.toolWikipedia",
"position": [
2512,
704
],
"parameters": {},
"typeVersion": 1
},
{
"id": "d7cb9060-af1b-4006-814f-d13d00406bd6",
"name": "下载音频",
"type": "n8n-nodes-base.httpRequest",
"position": [
880,
448
],
"parameters": {
"url": "={{ $json.url }}",
"options": {},
"authentication": "predefinedCredentialType",
"nodeCredentialType": "facebookGraphApi"
},
"credentials": {
"facebookGraphApi": {
"id": "WIGwSMnkKuDXE3cY",
"name": "Facebook Graph account"
}
},
"typeVersion": 4.2
},
{
"id": "43dc357f-2e94-4ca4-87dd-bc26c5ca516c",
"name": "音频转录器",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
1248,
448
],
"parameters": {
"options": {},
"resource": "audio",
"operation": "transcribe"
},
"credentials": {
"openAiApi": {
"id": "jl5FyiQarFxAvt8F",
"name": "OpenAi account"
}
},
"typeVersion": 1.8
},
{
"id": "e891d603-5258-47b5-a4de-834a21145aef",
"name": "识别并重定向消息类型",
"type": "n8n-nodes-base.switch",
"position": [
368,
432
],
"parameters": {
"rules": {
"values": [
{
"outputKey": "=Image Message",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "b12ff3af-0aae-4874-9c16-37f0337bf214",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{ $json.type === \"image\" }}",
"rightValue": ""
}
]
},
"renameOutput": true
},
{
"outputKey": "Audio Message",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "584171c6-5842-41a4-ae70-b901457d1b43",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{ $json.type === \"audio\" }}",
"rightValue": ""
}
]
},
"renameOutput": true
},
{
"outputKey": "Text Message",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "c1d29099-8a6f-4944-ad5c-a60926aabbd1",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{ $json.type === \"text\" }}",
"rightValue": ""
}
]
},
"renameOutput": true
}
]
},
"options": {}
},
"typeVersion": 3.2
},
{
"id": "18493f65-52e0-4438-afba-daaac6f8fabe",
"name": "下载图片",
"type": "n8n-nodes-base.httpRequest",
"position": [
880,
112
],
"parameters": {
"url": "={{ $json.url }}",
"options": {},
"authentication": "predefinedCredentialType",
"nodeCredentialType": "facebookGraphApi"
},
"credentials": {
"facebookGraphApi": {
"id": "WIGwSMnkKuDXE3cY",
"name": "Facebook Graph account"
}
},
"typeVersion": 4.2
},
{
"id": "908a01ea-04ba-4711-8aeb-0326abb7b512",
"name": "识别消息类型",
"type": "n8n-nodes-base.function",
"position": [
0,
448
],
"parameters": {
"functionCode": "// ─── 0. Récupère la racine utile (body si présent) ─────────────────────\nconst root = $json.body ?? $json; // ← marche avec ou sans \"body\"\n\n// ─── 1. Cherche l'objet \"message\", quel que soit le chemin ─────────────\nlet msg;\n\nif (root.message) {\n // cas où un Set/Split l’a déjà extrait\n msg = root.message;\n} else if (root.entry?.[0]?.messaging?.[0]?.message) {\n // structure brute Facebook\n msg = root.entry[0].messaging[0].message;\n} else {\n throw new Error('Impossible de localiser le champ \"message\"');\n}\n\n// ─── 2. Prépare la sortie standardisée ─────────────────────────────────\nlet result;\n\nif (msg.attachments?.[0]) {\n const att = msg.attachments[0];\n if (att.type === 'image') {\n result = { type: 'image', url: att.payload?.url };\n } else if (att.type === 'audio') {\n result = { type: 'audio', url: att.payload?.url };\n } else {\n result = { type: att.type || 'attachment', url: att.payload?.url };\n }\n} else if (msg.text) {\n result = { type: 'text', text: msg.text };\n} else {\n result = { type: 'unknown' };\n}\n\n// ─── 3. Retourne l'objet pour les nœuds suivants ───────────────────────\nreturn [ result ];"
},
"typeVersion": 1
},
{
"id": "4c783fcc-48ab-4381-ba12-d730d7837c30",
"name": "编辑字段1",
"type": "n8n-nodes-base.set",
"position": [
1248,
784
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "5a5d4ec5-61d5-471c-bab7-135528008e6c",
"name": "user_prompt",
"type": "string",
"value": "={{ $json.text }}"
}
]
},
"includeOtherFields": true
},
"typeVersion": 3.4
},
{
"id": "752e4920-7677-4e78-bef9-1ee55478b33a",
"name": "编辑字段2",
"type": "n8n-nodes-base.set",
"position": [
1632,
448
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "5a5d4ec5-61d5-471c-bab7-135528008e6c",
"name": "user_prompt",
"type": "string",
"value": "={{ $json.text }}"
}
]
},
"includeOtherFields": true
},
"typeVersion": 3.4
},
{
"id": "391e29fb-4b60-407e-a1f1-db0740fddf14",
"name": "编辑字段3",
"type": "n8n-nodes-base.set",
"position": [
1632,
112
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "5a5d4ec5-61d5-471c-bab7-135528008e6c",
"name": "user_prompt",
"type": "string",
"value": "={{ $json.content }}"
}
]
},
"includeOtherFields": true
},
"typeVersion": 3.4
},
{
"id": "66394ce4-5a3d-45a8-8929-a5fe5d8399be",
"name": "代码1",
"type": "n8n-nodes-base.code",
"position": [
3152,
448
],
"parameters": {
"jsCode": "// -------- Build Messenger Payload ----------\n// 1) Récupère le PSID directement depuis ton webhook “Webhook1”\nconst psid = ($node[\"Webhook1\"].json.body?.entry ?? $node[\"Webhook1\"].json.entry)[0]\n .messaging[0].sender.id; // ID du client\n\nconst reply = $json.output || 'Réponse vide'; // texte déjà nettoyé par le 1er Code\n\nreturn [{\n json: {\n messaging_type: 'RESPONSE',\n recipient: { id: String(psid) }, // ← chaîne obligatoire\n message: { text: reply }\n }\n}];"
},
"typeVersion": 2
},
{
"id": "5536e5a6-5b84-4a37-bdd4-a4fa01dc4e2c",
"name": "代码",
"type": "n8n-nodes-base.code",
"position": [
2784,
448
],
"parameters": {
"jsCode": "/**\n * n8n – Code node\n * Mode : Run Once for All Items\n * Objectif :\n * 1. Repère **gras** ou *gras*\n * 2. Convertit le contenu en lettres \"Unicode Bold\"\n * 3. Supprime tous les astérisques\n */\n\nconst FIELD = 'output'; // ← mets ici le nom exact du champ texte\n\n// --- petite fonction de conversion ASCII → Unicode gras\nfunction toUnicodeBold(str) {\n const upperOffset = 0x1D400 - 0x41; // A → 𝐀\n const lowerOffset = 0x1D41A - 0x61; // a → 𝐚\n const digitOffset = 0x1D7CE - 0x30; // 0 → 𝟎\n\n return str.split('').map(ch => {\n const code = ch.charCodeAt(0);\n if (code >= 0x41 && code <= 0x5A) return String.fromCodePoint(code + upperOffset); // A-Z\n if (code >= 0x61 && code <= 0x7A) return String.fromCodePoint(code + lowerOffset); // a-z\n if (code >= 0x30 && code <= 0x39) return String.fromCodePoint(code + digitOffset); // 0-9\n return ch; // ponctuation, espaces…\n }).join('');\n}\n\nfor (const item of $input.all()) {\n if (item.json[FIELD]) {\n item.json[FIELD] = item.json[FIELD]\n // ► 1. **…** ou *…* → conversion + suppression d’astérisques\n .replace(/\\*{1,2}([^*]+?)\\*{1,2}/gs, (_, txt) => toUnicodeBold(txt))\n\n // ► 2. S’il reste des astérisques isolés → on les retire\n .replace(/\\*/g, '');\n }\n}\n\nreturn $input.all();"
},
"typeVersion": 2
},
{
"id": "8e37259a-0d7f-40e6-87a5-d7eafe6c4913",
"name": "发送响应",
"type": "n8n-nodes-base.httpRequest",
"position": [
3520,
448
],
"parameters": {
"url": "https://graph.facebook.com/v17.0/me/messages?access_token=",
"body": "={{ JSON.stringify($json, null, 0) }}",
"method": "POST",
"options": {},
"sendBody": true,
"contentType": "raw",
"sendHeaders": true,
"rawContentType": "application/json",
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
}
},
"typeVersion": 4.2
},
{
"id": "85bc2e7b-83d3-4481-948b-4e0444d52246",
"name": "AI Agent 信使",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
2160,
448
],
"parameters": {
"text": "={{ $json.user_prompt }}",
"options": {
"systemMessage": "Tu es un assistant spécialisé.\n- Si la demande nécessite uniquement des calculs mathématiques, financiers ou statistiques : utilise toujours l’outil Calculatrice.\n- Si la demande nécessite une recherche d’information externe (histoire, biographie, faits généraux) : utilise l’outil Wikipédia.\n- Ne mélange pas les deux outils sauf si c’est absolument nécessaire.\n- Lorsque la question contient un montant, un pourcentage, un taux ou une durée : c’est un calcul → utilise uniquement l’outil Calculatrice."
},
"promptType": "define"
},
"typeVersion": 2.2
},
{
"id": "a09429dd-8e6c-4c85-94c3-c73c8385a6c0",
"name": "分析图像",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
1248,
112
],
"parameters": {
"text": "Describe this image.",
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4o",
"cachedResultName": "GPT-4O"
},
"options": {},
"resource": "image",
"inputType": "base64",
"operation": "analyze"
},
"credentials": {
"openAiApi": {
"id": "jl5FyiQarFxAvt8F",
"name": "OpenAi account"
}
},
"typeVersion": 1.8
},
{
"id": "b838533f-1f70-45a1-9785-ea28aacc0822",
"name": "Webhook1",
"type": "n8n-nodes-base.webhook",
"position": [
-368,
448
],
"webhookId": "50f8576e-a334-40ae-af63-0cc4fecff1d0",
"parameters": {
"path": "Messenger",
"options": {},
"httpMethod": "POST"
},
"typeVersion": 2.1
},
{
"id": "bd67326b-ef8e-48fc-a9da-4c917ad88594",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-480,
256
],
"parameters": {
"width": 336,
"height": 384,
"content": "## Webhook1(信使入口)"
},
"typeVersion": 1
},
{
"id": "5fd271ca-be10-4830-bc24-7994b9cb74a8",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-112,
256
],
"parameters": {
"width": 336,
"height": 384,
"content": "## 识别消息类型(代码)"
},
"typeVersion": 1
},
{
"id": "a44151ae-4d95-47bb-8f9d-2ba746cfd1dd",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
256,
256
],
"parameters": {
"width": 368,
"height": 384,
"content": "## 识别并重定向消息类型(路由器/规则)"
},
"typeVersion": 1
},
{
"id": "0b132eb3-09ff-4fcf-a11b-4655128298a9",
"name": "便签4",
"type": "n8n-nodes-base.stickyNote",
"position": [
768,
-48
],
"parameters": {
"color": 5,
"width": 336,
"height": 320,
"content": "## 下载图片"
},
"typeVersion": 1
},
{
"id": "3ed9947b-4940-4d4e-a51e-826d4cdb3041",
"name": "便签5",
"type": "n8n-nodes-base.stickyNote",
"position": [
1136,
-48
],
"parameters": {
"color": 5,
"width": 336,
"height": 320,
"content": "## 分析图片(视觉)"
},
"typeVersion": 1
},
{
"id": "8521e4c9-92ac-4e9f-beb0-150a84301a72",
"name": "便签6",
"type": "n8n-nodes-base.stickyNote",
"position": [
1504,
-48
],
"parameters": {
"color": 5,
"width": 368,
"height": 320,
"content": "## 编辑字段3(图片→提示)"
},
"typeVersion": 1
},
{
"id": "ef459985-d05b-41ed-b540-166ddfd8320c",
"name": "便签7",
"type": "n8n-nodes-base.stickyNote",
"position": [
768,
304
],
"parameters": {
"color": 5,
"width": 336,
"height": 304,
"content": "## 下载音频"
},
"typeVersion": 1
},
{
"id": "b9482f90-0981-46b9-b07f-a95569ee6399",
"name": "便签8",
"type": "n8n-nodes-base.stickyNote",
"position": [
1136,
304
],
"parameters": {
"color": 5,
"width": 336,
"height": 304,
"content": "## 音频转录器"
},
"typeVersion": 1
},
{
"id": "59be867f-e5f4-4252-a251-7f20c0654003",
"name": "便签9",
"type": "n8n-nodes-base.stickyNote",
"position": [
1504,
304
],
"parameters": {
"color": 5,
"width": 368,
"height": 304,
"content": "## 编辑字段2(音频→提示)"
},
"typeVersion": 1
},
{
"id": "26565c46-d336-4a12-a83d-fd06461edacb",
"name": "便签10",
"type": "n8n-nodes-base.stickyNote",
"position": [
1136,
640
],
"parameters": {
"color": 5,
"width": 336,
"height": 304,
"content": "## 编辑字段1(文本→提示)"
},
"typeVersion": 1
},
{
"id": "338acd3a-73e1-479f-85a6-809daa4bca01",
"name": "便签11",
"type": "n8n-nodes-base.stickyNote",
"position": [
2672,
240
],
"parameters": {
"width": 336,
"height": 368,
"content": "## 代码(后处理加粗)"
},
"typeVersion": 1
},
{
"id": "4aa7b210-b885-407a-93cc-3c8ec9c1a150",
"name": "便签12",
"type": "n8n-nodes-base.stickyNote",
"position": [
3040,
240
],
"parameters": {
"width": 336,
"height": 368,
"content": "## 代码1(构建 Messenger 有效载荷)"
},
"typeVersion": 1
},
{
"id": "4d639833-bb9d-447a-9331-f44d20446864",
"name": "便签13",
"type": "n8n-nodes-base.stickyNote",
"position": [
3408,
240
],
"parameters": {
"color": 4,
"width": 352,
"height": 368,
"content": "## 发送响应(HTTP → Graph API)"
},
"typeVersion": 1
},
{
"id": "5a7944b5-13d4-4fc5-9c68-2430516912dd",
"name": "便签14",
"type": "n8n-nodes-base.stickyNote",
"position": [
1952,
240
],
"parameters": {
"color": 3,
"width": 688,
"height": 624,
"content": "## AI Agent + 聊天模型 + 记忆 + 工具"
},
"typeVersion": 1
},
{
"id": "38a8016e-1df7-4337-a8a0-5db52b8e144d",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-976,
-96
],
"parameters": {
"width": 416,
"height": 1008,
"content": "# 6步实现 Messenger 自动化 ✨"
},
"typeVersion": 1
},
{
"id": "778d262f-5dfe-4986-9eb0-a94a46a3f771",
"name": "便签15",
"type": "n8n-nodes-base.stickyNote",
"position": [
3136,
-192
],
"parameters": {
"width": 608,
"height": 384,
"content": "## [视频教程](https://youtu.be/yHNPBDNgk88)"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "5b201e08-f698-418e-ad26-df60f327cd8a",
"connections": {
"Code": {
"main": [
[
{
"node": "Code1",
"type": "main",
"index": 0
}
]
]
},
"Code1": {
"main": [
[
{
"node": "Send Response",
"type": "main",
"index": 0
}
]
]
},
"Webhook1": {
"main": [
[
{
"node": "Identify Message Type",
"type": "main",
"index": 0
}
]
]
},
"Wikipedia": {
"ai_tool": [
[
{
"node": "AI Agent Messenger",
"type": "ai_tool",
"index": 0
}
]
]
},
"Calculator": {
"ai_tool": [
[
{
"node": "AI Agent Messenger",
"type": "ai_tool",
"index": 0
}
]
]
},
"Edit Fields1": {
"main": [
[
{
"node": "AI Agent Messenger",
"type": "main",
"index": 0
}
]
]
},
"Edit Fields2": {
"main": [
[
{
"node": "AI Agent Messenger",
"type": "main",
"index": 0
}
]
]
},
"Edit Fields3": {
"main": [
[
{
"node": "AI Agent Messenger",
"type": "main",
"index": 0
}
]
]
},
"Analyze image": {
"main": [
[
{
"node": "Edit Fields3",
"type": "main",
"index": 0
}
]
]
},
"Simple Memory": {
"ai_memory": [
[
{
"node": "AI Agent Messenger",
"type": "ai_memory",
"index": 0
}
]
]
},
"Download Audio": {
"main": [
[
{
"node": "Audio Transcriber",
"type": "main",
"index": 0
}
]
]
},
"Download Image": {
"main": [
[
{
"node": "Analyze image",
"type": "main",
"index": 0
}
]
]
},
"Audio Transcriber": {
"main": [
[
{
"node": "Edit Fields2",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent Messenger",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"AI Agent Messenger": {
"main": [
[
{
"node": "Code",
"type": "main",
"index": 0
}
]
]
},
"Identify Message Type": {
"main": [
[
{
"node": "Identify and ReRoute Message Types",
"type": "main",
"index": 0
}
]
]
},
"Identify and ReRoute Message Types": {
"main": [
[
{
"node": "Download Image",
"type": "main",
"index": 0
}
],
[
{
"node": "Download Audio",
"type": "main",
"index": 0
}
],
[
{
"node": "Edit Fields1",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
这是一个高级难度的工作流,适用于Content Creation、Multimodal AI等场景。适合高级用户,包含 16+ 个节点的复杂工作流
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
批量SEO内容生成与带AI图片的Webflow草稿创建(模板)
使用GPT、Gemini图片和Webflow草稿创建进行批量SEO内容生成
If
Set
Code
+18
54 节点Dahiana
Content Creation
AI个人助理 - 任务与邮件管理
在Telegram上使用GPT-4o个人助理管理任务、邮件和日历
Set
Code
Switch
+13
40 节点Ronnie Craig
Content Creation
Nano Banana-Gemini 2.5多模态Telegram机器人
基于Nano Banana/Gemini 2.5的多模态Telegram机器人
If
Set
Code
+11
36 节点Denis
Content Creation
导出 n8n
使用LINE和OpenAI Vision从图片记录食物卡路里到Google Sheets
If
Set
Code
+9
17 节点kote2
Personal Productivity
✨🩷自动化社交媒体内容发布工厂 + 系统提示组合
基于动态系统提示和GPT-4o的AI驱动多平台社交媒体内容工厂
If
Set
Code
+20
100 节点Amit Mehta
Content Creation
从趋势电子表格生成SEO内容到存储(SharePoint/Drive/Dropbox)
使用GPT-4o、FAL AI和多存储支持从趋势自动生成SEO内容
If
Set
Code
+13
47 节点plemeo
Content Creation