8
n8n 中文网amn8n.com

使用 GPT-4o 通过自然语言查询搜索 Outlook 邮件

高级

这是一个AI RAG, Multimodal AI领域的自动化工作流,包含 17 个节点。主要使用 Merge, Aggregate, Agent, MicrosoftOutlook, ChatTrigger 等节点。 使用 GPT-4o 通过自然语言查询搜索 Outlook 邮件

前置要求
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "ad0113c344ee237399e44e9f11798b05baeb83a6196d514a9ae9d2ad71c3b5c9",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "a5c3ebce-f05b-4985-96ef-b98b8db66a22",
      "name": "当收到聊天消息时",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -1440,
        5440
      ],
      "webhookId": "ccaca032-7964-4a83-9417-91a223bc1485",
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.3
    },
    {
      "id": "38e231b6-a4d3-4694-8527-7e6411ece665",
      "name": "便利贴21",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1952,
        5120
      ],
      "parameters": {
        "width": 400,
        "height": 928,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "451b2735-ce3a-4e10-98ea-a46b872f93be",
      "name": "便签22",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1520,
        5120
      ],
      "parameters": {
        "color": 7,
        "width": 1936,
        "height": 928,
        "content": "# 📧 Outlook 邮件搜索助手 (n8n + OpenAI)"
      },
      "typeVersion": 1
    },
    {
      "id": "5f29e431-f35e-43d1-a22c-b27f7630539b",
      "name": "OpenAI 聊天模型5",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -368,
        5888
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "4l6TDfLZVFS24g3X",
          "name": "OpenAi account 4"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "872318b9-07c0-4434-8258-8264c5ebcfff",
      "name": "便签23",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1456,
        5664
      ],
      "parameters": {
        "color": 3,
        "width": 288,
        "height": 304,
        "content": "### 1️⃣ 设置 OpenAI 连接"
      },
      "typeVersion": 1
    },
    {
      "id": "bc36ba09-b088-45c3-9ab6-4c19e8dd4aa4",
      "name": "OpenAI 聊天模型 6",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -1344,
        5856
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "4l6TDfLZVFS24g3X",
          "name": "OpenAi account 4"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "b7e5a86b-9534-4a1c-8134-f0cdc92a40c5",
      "name": "简单记忆1",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -1040,
        5696
      ],
      "parameters": {},
      "typeVersion": 1.3
    },
    {
      "id": "b765f576-4cce-4264-8cd0-eb42bcfe0b3b",
      "name": "结构化输出解析器 3",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -880,
        5728
      ],
      "parameters": {
        "jsonSchemaExample": "{\n\t\"search\": \"search term\"\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "9dd5c86f-8d6d-4b94-a7b7-08d81aac3749",
      "name": "合并",
      "type": "n8n-nodes-base.merge",
      "position": [
        -640,
        5648
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineAll"
      },
      "typeVersion": 3.2
    },
    {
      "id": "ac3539fb-842d-4922-9ca7-42397cfb7143",
      "name": "结构化输出解析器 5",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -144,
        5904
      ],
      "parameters": {
        "jsonSchemaExample": "{\n\t\"score\": \"score\",\n\t\"url\": \"url\"\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "4bf1962a-009e-457d-95a9-243b64bd9a79",
      "name": "OpenAI 聊天模型7",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        144,
        5664
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "4l6TDfLZVFS24g3X",
          "name": "OpenAi account 4"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "68610127-4f8e-4c97-819f-7c47c0d4c93f",
      "name": "生成搜索词",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1136,
        5408
      ],
      "parameters": {
        "options": {
          "systemMessage": "Take in a search that someone wants to search their outlook for a specific mail. Once they tell you what they wnat, output a search term. \n\nOutput like this. \n\n{\n\t\"search\": \"search term\"\n}"
        },
        "hasOutputParser": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "6045e6b4-1f1a-4a94-bdc5-b4cca9dbb167",
      "name": "搜索 Outlook",
      "type": "n8n-nodes-base.microsoftOutlook",
      "position": [
        -384,
        5456
      ],
      "webhookId": "ae07c8b7-e0be-4a87-93a8-cfcb00303d0c",
      "parameters": {
        "limit": 5,
        "output": "raw",
        "options": {},
        "filtersUI": {
          "values": {
            "search": "={{ $json.output.search }} -from:rbreen@ynteractive.com\n",
            "filterBy": "search"
          }
        },
        "operation": "getAll"
      },
      "credentials": {
        "microsoftOutlookOAuth2Api": {
          "id": "9z1nG9ReKLXU309r",
          "name": "Microsoft Outlook account 4"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "90182205-aef1-465d-a271-16c63b9a4942",
      "name": "评分邮件是否与搜索相关",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -304,
        5664
      ],
      "parameters": {
        "text": "=User question: {{ $json.chatInput }} Email content: {{ $json.body.content }}  sender: {{ $json.sender.emailAddress.address }}  url: {{ $json.webLink }}",
        "options": {
          "systemMessage": "take in the user question and give a number 1-100 on how likely this is the email they are looking for. output like this: "
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "7b73107e-a3e7-4c4d-95c3-7f53c858c5e0",
      "name": "以表格形式为用户输出",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        96,
        5408
      ],
      "parameters": {
        "text": "={{ $json.data }}",
        "options": {
          "systemMessage": "write this data into a table output with two columns. score, then url. "
        },
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "eb49ccbb-5951-4774-b42d-22822317fc3f",
      "name": "转换为单一输出",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        -64,
        5408
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "010f5610-caad-493f-afc6-55a9f0aaf7c2",
      "name": "便利贴24",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -480,
        5232
      ],
      "parameters": {
        "color": 3,
        "width": 288,
        "height": 336,
        "content": "### 2️⃣ 设置 Outlook 连接"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Merge": {
      "main": [
        [
          {
            "node": "Score if email is relevent to search",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search Outlook": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory1": {
      "ai_memory": [
        [
          {
            "node": "Generate Search Term",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model5": {
      "ai_languageModel": [
        [
          {
            "node": "Score if email is relevent to search",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model6": {
      "ai_languageModel": [
        [
          {
            "node": "Generate Search Term",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model7": {
      "ai_languageModel": [
        [
          {
            "node": "Output as table for user",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Generate Search Term": {
      "main": [
        [
          {
            "node": "Search Outlook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to one Output": {
      "main": [
        [
          {
            "node": "Output as table for user",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser3": {
      "ai_outputParser": [
        [
          {
            "node": "Generate Search Term",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser5": {
      "ai_outputParser": [
        [
          {
            "node": "Score if email is relevent to search",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "Generate Search Term",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Score if email is relevent to search": {
      "main": [
        [
          {
            "node": "Convert to one Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - AI RAG 检索增强, 多模态 AI

需要付费吗?

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

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

适合高级用户,包含 16+ 个节点的复杂工作流

作者
Robert Breen

Robert Breen

@rbreen

Professional services consultant with over 10 years of experience solving complex business problems across industries. I specialize in n8n and process automation—designing custom workflows that integrate tools like Google Calendar, Airtable, GPT, and internal systems. Whether you need to automate scheduling, sync data, or streamline operations, I build solutions that save time and drive results.

外部链接
在 n8n.io 查看

分享此工作流