MongoDB 智能代理
中级
这是一个Other、AI领域的自动化工作流,包含 8 个节点。主要使用 MongoDbTool、Agent、ChatTrigger、LmChatOpenAi、ToolWorkflow 等节点,结合人工智能技术实现智能自动化。 MongoDB AI 代理 - 智能电影推荐
前置要求
- •MongoDB 连接字符串
- •OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "22PddLUgcjSJbT1w",
"meta": {
"instanceId": "fa7d5e2425ec76075df7100dbafffed91cc6f71f12fe92614bf78af63c54a61d",
"templateCredsSetupCompleted": true
},
"name": "MongoDB Agent",
"tags": [],
"nodes": [
{
"id": "d8c07efe-eca0-48cb-80e6-ea8117073c5f",
"name": "OpenAI 聊天模型",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
1300,
560
],
"parameters": {
"options": {}
},
"credentials": {
"openAiApi": {
"id": "TreGPMKr9hrtCvVp",
"name": "OpenAi account"
}
},
"typeVersion": 1
},
{
"id": "636de178-7b68-429a-9371-41cf2a950076",
"name": "MongoDB聚合",
"type": "n8n-nodes-base.mongoDbTool",
"position": [
1640,
540
],
"parameters": {
"query": "={{ $fromAI(\"pipeline\", \"The MongoDB pipeline to execute\" , \"string\" , [{\"$match\" : { \"rating\" : 5 } }])}}",
"operation": "aggregate",
"collection": "movies",
"descriptionType": "manual",
"toolDescription": "Get from AI the MongoDB Aggregation pipeline to get context based on the provided pipeline, the document structure of the documents is : {\n \"plot\": \"A group of bandits stage a brazen train hold-up, only to find a determined posse hot on their heels.\",\n \"genres\": [\n \"Short\",\n \"Western\"\n ],\n \"runtime\": 11,\n \"cast\": [\n \"A.C. Abadie\",\n \"Gilbert M. 'Broncho Billy' Anderson\",\n ...\n ],\n \"poster\": \"...jpg\",\n \"title\": \"The Great Train Robbery\",\n \"fullplot\": \"Among the earliest existing films in American cinema - notable as the ...\",\n \"languages\": [\n \"English\"\n ],\n \"released\": \"date\"\n },\n \"directors\": [\n \"Edwin S. Porter\"\n ],\n \"rated\": \"TV-G\",\n \"awards\": {\n \"wins\": 1,\n \"nominations\": 0,\n \"text\": \"1 win.\"\n },\n \"lastupdated\": \"2015-08-13 00:27:59.177000000\",\n \"year\": 1903,\n \"imdb\": {\n \"rating\": 7.4,"
},
"credentials": {
"mongoDb": {
"id": "8xGgiXzf2o0L4a0y",
"name": "MongoDB account"
}
},
"typeVersion": 1.1
},
{
"id": "e0f248dc-22b7-40a2-a00e-6298b51e4470",
"name": "窗口缓冲内存",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"position": [
1500,
540
],
"parameters": {
"contextWindowLength": 10
},
"typeVersion": 1.2
},
{
"id": "da27ee52-43db-4818-9844-3c0a064bf958",
"name": "当收到聊天消息时",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"position": [
1160,
400
],
"webhookId": "0730df2d-2f90-45e0-83dc-609668260fda",
"parameters": {
"mode": "webhook",
"public": true,
"options": {
"allowedOrigins": "*"
}
},
"typeVersion": 1.1
},
{
"id": "9ad79da9-3145-44be-9026-e37b0e856f5d",
"name": "插入收藏",
"type": "@n8n/n8n-nodes-langchain.toolWorkflow",
"position": [
1860,
520
],
"parameters": {
"name": "insertFavorites",
"workflowId": {
"__rl": true,
"mode": "list",
"value": "6QuKnOrpusQVu66Q",
"cachedResultName": "insertMongoDB"
},
"description": "=仅使用此工具添加收藏,结构为 {\"title\" : \"接收到的标题\" }"
},
"typeVersion": 1.2
},
{
"id": "4d7713d1-d2ad-48bf-971b-b86195e161ca",
"name": "AI Agent - 电影推荐",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
1380,
300
],
"parameters": {
"text": "=Assistant for best movies context, you have tools to search using \"MongoDBAggregate\" and you need to provide a MongoDB aggregation pipeline code array as a \"query\" input param. User input and request: {{ $json.chatInput }}. Only when a user confirms a favorite movie use the insert favorite using the \"insertFavorite\" workflow tool of to insertFavorite as { \"title\" : \"<TITLE>\" }.",
"options": {},
"promptType": "define"
},
"typeVersion": 1.7
},
{
"id": "2eac8aed-9677-4d89-bd76-456637f5b979",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
880,
300
],
"parameters": {
"width": 216.0875923062025,
"height": 499.89779507612025,
"content": "## 由 OpenAI 和 MongoDB 驱动的 AI Agent"
},
"typeVersion": 1
},
{
"id": "4d8130fe-4aed-4e09-9c1d-60fb9ac1a500",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
1300,
720
],
"parameters": {
"content": "## 处理流程"
},
"typeVersion": 1
}
],
"active": true,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "879aab24-6346-435f-8fd4-3fca856ba64c",
"connections": {
"insertFavorite": {
"ai_tool": [
[
{
"node": "AI Agent - Movie Recommendation",
"type": "ai_tool",
"index": 0
}
]
]
},
"MongoDBAggregate": {
"ai_tool": [
[
{
"node": "AI Agent - Movie Recommendation",
"type": "ai_tool",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent - Movie Recommendation",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Window Buffer Memory": {
"ai_memory": [
[
{
"node": "AI Agent - Movie Recommendation",
"type": "ai_memory",
"index": 0
}
]
]
},
"When chat message received": {
"main": [
[
{
"node": "AI Agent - Movie Recommendation",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
这是一个中级难度的工作流,适用于Other、AI等场景。适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
构建自定义n8n工作流MCP服务器
构建自定义n8n工作流MCP服务器
If
N8n
Set
+15
46 节点Jimleuk
Other
🔥📈🤖 适用于n8n创作者排行榜的AI代理 - 查找热门工作流
🔥📈🤖 n8n创作者排行榜AI代理 - 查找热门工作流
Set
Sort
Limit
+15
43 节点Joseph LePage
Other
旅行助手Agent
使用MongoDB Atlas、Gemini LLM和向量搜索的旅行规划助手
Webhook
Agent
Chat Trigger
+7
14 节点Pavel Duchovny
Other
我的工作流
使用Bright Data网络爬取和GPT-4.1生成个人新闻源
Set
Email Send
Mcp Client Tool
+6
15 节点Daniel Shashko
Other
使用AI SQL代理查询n8n凭据
使用AI SQL代理查询n8n凭据
N8n
Set
Code
+7
13 节点Jimleuk
Other
AI智能助手与Airtable对话及数据分析
AI智能助手与Airtable对话及数据分析
If
Set
Merge
+12
41 节点Mark Shcherbakov
Engineering
工作流信息
难度等级
中级
节点数量8
分类2
节点类型7
作者
Pavel Duchovny
@pashDeveloper imagination == Innovation ✓ Experienced DBA & DevOps engineer & Web Developer. Develop and deploy automation of servers, infrastructure and security to the cloud. Scaling, upgrading and designing Big scaled systems and databases . Specializing in designing and building big data solutions in both RDBMS and NoSql echosystems. Hardworking and innovative personality.
外部链接
在 n8n.io 上查看 →
分享此工作流