多模态AI助手代理(GPT-4o & MongoDB)与Gmail工具使用
高级
这是一个Personal Productivity, AI RAG领域的自动化工作流,包含 26 个节点。主要使用 If, Set, Switch, Telegram, GmailTool 等节点。 使用GPT-4o、MongoDB和Gmail工具处理语音、图像和文档
前置要求
- •Telegram Bot Token
- •Google 账号和 Gmail API 凭证
- •可能需要目标 API 的认证凭证
- •OpenAI API Key
- •MongoDB 连接字符串
使用的节点 (26)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "u1UDiWECb1RUnZNN",
"meta": {
"instanceId": "13d96e1ebd7901d1ed300d36db3a4447107e9ad60df51fe711e45683875362aa",
"templateCredsSetupCompleted": true
},
"name": "多模态 AI 助手代理(GPT-4o & MongoDB)与 Gmail 工具使用",
"tags": [
{
"id": "88Rkm7VaAFefsT34",
"name": "AI Agents",
"createdAt": "2025-05-06T22:52:26.053Z",
"updatedAt": "2025-07-21T00:33:33.971Z"
},
{
"id": "IEpRLlnMFuw6uI0n",
"name": "MongoDB",
"createdAt": "2025-07-21T00:34:02.234Z",
"updatedAt": "2025-07-21T00:34:02.234Z"
},
{
"id": "YKfqWKbhkj0tMP9a",
"name": "Assistant",
"createdAt": "2025-05-11T00:54:42.509Z",
"updatedAt": "2025-05-11T00:54:42.509Z"
},
{
"id": "s1UA6FThbKhQYbLu",
"name": "MultiModal",
"createdAt": "2025-05-06T22:52:35.914Z",
"updatedAt": "2025-05-06T22:52:35.914Z"
},
{
"id": "u0sDc9TmwaTimDuy",
"name": "Gmail",
"createdAt": "2025-05-11T00:53:52.260Z",
"updatedAt": "2025-05-11T00:53:52.260Z"
}
],
"nodes": [
{
"id": "007accc7-cc28-4904-a66e-e78e73b13b3b",
"name": "Telegram 触发器",
"type": "n8n-nodes-base.telegramTrigger",
"position": [
-220,
-880
],
"webhookId": "a10253d2-0645-46d0-95e7-f7bb41193431",
"parameters": {
"updates": [
"message"
],
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"id": "LvJD4EnUtBT8OCXQ",
"name": "Telegram account 2"
}
},
"typeVersion": 1.2
},
{
"id": "8d5e865b-7a6b-4c1d-a850-68b9a25de56f",
"name": "切换",
"type": "n8n-nodes-base.switch",
"position": [
-20,
-880
],
"parameters": {
"rules": {
"values": [
{
"outputKey": "photo",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "loose"
},
"combinator": "and",
"conditions": [
{
"id": "05a85c74-cb5e-4fa4-83be-bd258efc1464",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.message.photo[3]}}",
"rightValue": ""
}
]
},
"renameOutput": true
},
{
"outputKey": "voice",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "loose"
},
"combinator": "and",
"conditions": [
{
"id": "4135a526-68a7-428d-82f3-d5882d9bc4e6",
"operator": {
"type": "object",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.message.voice }}",
"rightValue": ""
}
]
},
"renameOutput": true
},
{
"outputKey": "document",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "loose"
},
"combinator": "and",
"conditions": [
{
"id": "26c733da-6782-487d-9b37-61e7544e2e84",
"operator": {
"type": "object",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.message.document }}",
"rightValue": ""
}
]
},
"renameOutput": true
},
{
"outputKey": "text",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "loose"
},
"combinator": "and",
"conditions": [
{
"id": "b8457c94-8f58-4b84-866a-4b04f3df7779",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.message.text }}",
"rightValue": ""
}
]
},
"renameOutput": true
}
]
},
"options": {},
"looseTypeValidation": true
},
"typeVersion": 3.2
},
{
"id": "1dc71295-3f8b-4d7a-9469-707db0828a16",
"name": "转录录音",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
680,
-400
],
"parameters": {
"options": {},
"resource": "audio",
"operation": "transcribe"
},
"credentials": {
"openAiApi": {
"id": "RYBVUGi38HFcqZqp",
"name": "OpenAi account 2"
}
},
"typeVersion": 1.8
},
{
"id": "31ab270f-3820-4113-b534-70fda48fc108",
"name": "AI 代理",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
1220,
600
],
"parameters": {
"text": "={{ $json.text }}",
"options": {
"systemMessage": "You are a helpful assistant.\n\nIf you don't have enough context to answer a question, use the MongoDB Atlas Vector Store Tool to check the vector store for more context before you formulate a response. "
},
"promptType": "define"
},
"typeVersion": 2
},
{
"id": "25361e7d-6be5-4025-a1d7-b546bb248090",
"name": "OpenAI 聊天模型",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
1040,
880
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"id": "RYBVUGi38HFcqZqp",
"name": "OpenAi account 2"
}
},
"typeVersion": 1.2
},
{
"id": "aa026292-2ddb-41cb-b650-46b336a6607d",
"name": "响应",
"type": "n8n-nodes-base.telegram",
"position": [
1600,
600
],
"webhookId": "b8c042cd-b186-42e4-97c6-cb11ca708ab4",
"parameters": {
"text": "={{ $json.output }}",
"chatId": "={{ $('Switch').item.json.message.from.id }}",
"additionalFields": {
"appendAttribution": false
}
},
"credentials": {
"telegramApi": {
"id": "LvJD4EnUtBT8OCXQ",
"name": "Telegram account 2"
}
},
"typeVersion": 1.2
},
{
"id": "b5e4eeec-b901-4121-9f97-6dc8bbdb92db",
"name": "MongoDB 聊天记忆",
"type": "@n8n/n8n-nodes-langchain.memoryMongoDbChat",
"position": [
1240,
880
],
"parameters": {
"sessionKey": "={{ $('Telegram Trigger').item.json.message.from.id }}",
"databaseName": "chat_messages",
"sessionIdType": "customKey",
"contextWindowLength": 100
},
"credentials": {
"mongoDb": {
"id": "ZW5dFVMhek3Ia8Nb",
"name": "MongoDB account"
}
},
"typeVersion": 1
},
{
"id": "638201f8-1e90-46e6-af59-a4ddc8bf5bf9",
"name": "ConvertAPI HTTP 请求",
"type": "n8n-nodes-base.httpRequest",
"position": [
460,
-880
],
"parameters": {
"": "",
"url": "https://v2.convertapi.com/convert/ai/to/png",
"method": "POST",
"options": {},
"sendBody": true,
"sendQuery": false,
"curlImport": "",
"contentType": "multipart-form-data",
"infoMessage": "",
"sendHeaders": true,
"authentication": "none",
"bodyParameters": {
"parameters": [
{
"name": "StoreFile",
"value": "true",
"parameterType": "formData"
},
{
"name": "File",
"parameterType": "formBinaryData",
"inputDataFieldName": "data"
}
]
},
"specifyHeaders": "keypair",
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "Bearer ..."
}
]
},
"httpVariantWarning": "",
"provideSslCertificates": false
},
"credentials": {
"convertApi": {
"id": "HGlTSw87jzs9hTfi",
"name": "ConvertAPI account"
}
},
"typeVersion": 4.2,
"extendsCredential": "convertApi"
},
{
"id": "10176355-04e5-49b5-a128-7aecb538e72a",
"name": "获取音频文件",
"type": "n8n-nodes-base.telegram",
"position": [
240,
-400
],
"webhookId": "a26ace34-37e6-473e-8a57-5d1c908b7642",
"parameters": {
"fileId": "={{ $json.message.voice.file_id }}",
"resource": "file"
},
"credentials": {
"telegramApi": {
"id": "LvJD4EnUtBT8OCXQ",
"name": "Telegram account 2"
}
},
"typeVersion": 1.2
},
{
"id": "53e02e99-b01a-4115-8663-d4241bfbc8e5",
"name": "获取照片文件",
"type": "n8n-nodes-base.telegram",
"position": [
240,
-880
],
"webhookId": "a26ace34-37e6-473e-8a57-5d1c908b7642",
"parameters": {
"fileId": "={{ $json.message.photo[3].file_id }}",
"resource": "file"
},
"credentials": {
"telegramApi": {
"id": "LvJD4EnUtBT8OCXQ",
"name": "Telegram account 2"
}
},
"typeVersion": 1.2
},
{
"id": "f3341c7e-c303-49c7-be9c-37b6b03b76f7",
"name": "分析图片",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
680,
-880
],
"parameters": {
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4o",
"cachedResultName": "GPT-4O"
},
"options": {},
"resource": "image",
"imageUrls": "={{ $json.Files[0].Url }}",
"operation": "analyze"
},
"credentials": {
"openAiApi": {
"id": "RYBVUGi38HFcqZqp",
"name": "OpenAi account 2"
}
},
"typeVersion": 1.8
},
{
"id": "7aea5368-650e-440a-b986-31010ab82fdc",
"name": "从图像获取文本",
"type": "n8n-nodes-base.set",
"position": [
900,
-880
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "da1e0cdd-5633-4bb7-97bd-2caf2e3b45c1",
"name": "text",
"type": "string",
"value": "=I just submitted an images with this description: {{ $json.content }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "676ca8f7-bb55-4c66-ae26-1fab3bb36c77",
"name": "从音频获取文本",
"type": "n8n-nodes-base.set",
"position": [
880,
-400
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "5b1b84f3-b95b-4142-8891-397815757620",
"name": "text",
"type": "string",
"value": "={{ $json.text }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "f3ec9d7f-1e0e-42cb-bf8b-1bead0558289",
"name": "获取文件",
"type": "n8n-nodes-base.telegram",
"position": [
240,
20
],
"webhookId": "f7a8fa17-3d06-4913-a979-20f6048f5e23",
"parameters": {
"fileId": "={{ $('Telegram Trigger').item.json.message.document.file_id }}",
"resource": "file"
},
"credentials": {
"telegramApi": {
"id": "LvJD4EnUtBT8OCXQ",
"name": "Telegram account 2"
}
},
"typeVersion": 1.2
},
{
"id": "25fc5879-8fa1-47a8-9888-d4129227beca",
"name": "如果",
"type": "n8n-nodes-base.if",
"position": [
440,
20
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "c56dbc4c-08c6-49a1-8a3b-fa7b13304c23",
"operator": {
"type": "string",
"operation": "contains"
},
"leftValue": "={{ $json.result.file_path }}",
"rightValue": "pdf"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "d48612ec-28e1-4685-a5f6-efb7cb53ba3b",
"name": "从文件中提取",
"type": "n8n-nodes-base.extractFromFile",
"position": [
680,
20
],
"parameters": {
"options": {},
"operation": "pdf"
},
"typeVersion": 1
},
{
"id": "36ec8656-502e-45dd-8309-4486bab3c0c8",
"name": "从 PDF 获取文本",
"type": "n8n-nodes-base.set",
"position": [
880,
20
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "da1e0cdd-5633-4bb7-97bd-2caf2e3b45c1",
"name": "text",
"type": "string",
"value": "=I just uploaded a file with details: \nName: {{ $json.info.Title }},\nContent :{{ $json.text }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "a06fe0fe-0c55-40fa-9711-0f8c39d44780",
"name": "不支持的输入",
"type": "n8n-nodes-base.set",
"position": [
680,
220
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "da1e0cdd-5633-4bb7-97bd-2caf2e3b45c1",
"name": "text",
"type": "string",
"value": "=User just uploaded the Word file but your system doesnt support such files just yet."
}
]
}
},
"typeVersion": 3.4
},
{
"id": "a32d4c7d-dd06-49e5-b302-09bb9926341c",
"name": "从消息获取文本",
"type": "n8n-nodes-base.set",
"position": [
220,
600
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "33f1c9df-bdb2-481d-8cf6-6633d23da23a",
"name": "text",
"type": "string",
"value": "={{$json.message.text}}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "d1d4e397-d495-4584-b8c4-bf9c87174f48",
"name": "在 Gmail 中发送消息",
"type": "n8n-nodes-base.gmailTool",
"position": [
1460,
880
],
"webhookId": "b5e761ce-83d5-4636-b54b-45a26150a650",
"parameters": {
"sendTo": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('To', ``, 'string') }}",
"message": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Message', ``, 'string') }}",
"options": {},
"subject": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Subject', ``, 'string') }}"
},
"credentials": {
"gmailOAuth2": {
"id": "7xeNUMGkl9ZTBgQc",
"name": "Gmail account 2"
}
},
"typeVersion": 2.1
},
{
"id": "e4c44de2-e751-4baf-afcd-d329c4891d43",
"name": "在 Gmail 中搜索消息",
"type": "n8n-nodes-base.gmailTool",
"position": [
1660,
880
],
"webhookId": "74970d71-72e1-4b20-9430-fdbdc971f6f6",
"parameters": {
"limit": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Limit', ``, 'number') }}",
"filters": {
"q": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Search', ``, 'string') }}"
},
"operation": "getAll"
},
"credentials": {
"gmailOAuth2": {
"id": "7xeNUMGkl9ZTBgQc",
"name": "Gmail account 2"
}
},
"typeVersion": 2.1
},
{
"id": "30e70a97-136e-4dd7-bad2-48c4f0f63773",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-220,
-1160
],
"parameters": {
"width": 2820,
"height": 240,
"content": "## 📝 总体概述"
},
"typeVersion": 1
},
{
"id": "b67876a6-803d-46ba-ae08-f27b718efe2b",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
1200,
-880
],
"parameters": {
"width": 1400,
"height": 340,
"content": "## 📸 处理照片"
},
"typeVersion": 1
},
{
"id": "1369051f-00c7-4564-bed9-c07b35f92fc8",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
1200,
20
],
"parameters": {
"width": 1400,
"height": 420,
"content": "## 📄 处理文档和应对不支持的文件"
},
"typeVersion": 1
},
{
"id": "4884964b-3a71-4459-9a0b-b4e2de51c90c",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
1200,
-400
],
"parameters": {
"width": 1400,
"height": 300,
"content": "## 🎙️ 处理音频"
},
"typeVersion": 1
},
{
"id": "791a2aa1-e747-4ac4-be8c-13375349a235",
"name": "便签4",
"type": "n8n-nodes-base.stickyNote",
"position": [
1880,
600
],
"parameters": {
"width": 720,
"height": 700,
"content": "## 🧠 AI 代理处理、MongoDB 向量存储和 Gmail 访问"
},
"typeVersion": 1
}
],
"active": true,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "15a8fd13-ef3a-4df1-bb73-3971d9d3eab9",
"connections": {
"If": {
"main": [
[
{
"node": "Extract from File",
"type": "main",
"index": 0
}
],
[
{
"node": "Unsupported Input",
"type": "main",
"index": 0
}
]
]
},
"Switch": {
"main": [
[
{
"node": "Get photo file",
"type": "main",
"index": 0
}
],
[
{
"node": "Get audio file",
"type": "main",
"index": 0
}
],
[
{
"node": "Get a file",
"type": "main",
"index": 0
}
],
[
{
"node": "Get text from Message",
"type": "main",
"index": 0
}
]
]
},
"AI Agent": {
"main": [
[
{
"node": "Respond",
"type": "main",
"index": 0
}
]
]
},
"Get a file": {
"main": [
[
{
"node": "If",
"type": "main",
"index": 0
}
]
]
},
"Analyze image": {
"main": [
[
{
"node": "Get text from Image",
"type": "main",
"index": 0
}
]
]
},
"Get audio file": {
"main": [
[
{
"node": "Transcribe a recording",
"type": "main",
"index": 0
}
]
]
},
"Get photo file": {
"main": [
[
{
"node": "ConvertAPI HTTP Request",
"type": "main",
"index": 0
}
]
]
},
"Telegram Trigger": {
"main": [
[
{
"node": "Switch",
"type": "main",
"index": 0
}
]
]
},
"Extract from File": {
"main": [
[
{
"node": "Get text from PDF",
"type": "main",
"index": 0
}
]
]
},
"Get text from PDF": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Unsupported Input": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"Get text from Audio": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"Get text from Image": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"MongoDB Chat Memory": {
"ai_memory": [
[
{
"node": "AI Agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"Get text from Message": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"Transcribe a recording": {
"main": [
[
{
"node": "Get text from Audio",
"type": "main",
"index": 0
}
]
]
},
"ConvertAPI HTTP Request": {
"main": [
[
{
"node": "Analyze image",
"type": "main",
"index": 0
}
]
]
},
"Send a message in Gmail": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Search for a messages in Gmail": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 个人效率, AI RAG 检索增强
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
Telegram AI支持聊天机器人(多模态输入)
使用GPT-4和Supabase RAG创建多模态Telegram支持机器人
If
Set
Code
+17
51 节点Ezema Kingsley Chibuzo
客服机器人
AIAutomationPro终极RAG聊天机器人v1 n8n市场模板
多语言Telegram RAG聊天机器人,集成监督AI和自动化Google Drive流程
If
Set
Wait
+29
128 节点Daniel Ng
客服机器人
使用 GPT-4o、ElevenLabs 和 WaveSpeed 口型同步创建真实 UGC 视频广告
使用 GPT-4o、ElevenLabs 和 WaveSpeed 口型同步创建真实 UGC 视频广告
If
Set
Wait
+12
38 节点Muhammad Farooq Iqbal
内容创作
美甲沙龙:主代理V2 Telegram版
集成Telegram、Claude和GPT5-mini的多智能体沙龙预约管理系统
If
Set
Code
+19
67 节点Denis
内容创作
Nano Banana-Gemini 2.5多模态Telegram机器人
基于Nano Banana/Gemini 2.5的多模态Telegram机器人
If
Set
Code
+11
36 节点Denis
内容创作
AI知识库助手与OpenAI、Supabase及Google Drive文档同步
AI知识库助手与OpenAI、Supabase及Google Drive文档同步
Set
Limit
Switch
+16
49 节点Abdul Mir
内部知识库
工作流信息
难度等级
高级
节点数量26
分类2
节点类型13
作者
NanaB
@nanabrownAutomation Developer with 3+ years building innovative solutions on UiPath, Power Platform, and n8n, also with a strong background in both API development and integration. Now specializing in the creation and implementation of AI Agents.
外部链接
在 n8n.io 查看 →
分享此工作流