8
n8n 中文网amn8n.com

基于Gemini 2.5、RAG和Cohere重排的Gmail客服代理

中级

这是一个自动化工作流,包含 12 个节点。主要使用 Gmail, GmailTrigger, Agent, RerankerCohere, EmbeddingsOpenAi 等节点。 基于Gemini 2.5、RAG和Cohere重排的Gmail客服代理

前置要求
  • Google 账号和 Gmail API 凭证
  • OpenAI API Key
  • Google Gemini API Key
  • PostgreSQL 数据库连接信息
  • Pinecone API Key

分类

-
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "3d7eb9567ae690bf8c9bba1cb43396e6e40c18e15eb5889cf9673ed1713da6db",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "113d6fd7-2850-4562-adad-d664ba8dc448",
      "name": "Gmail 触发器",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        3104,
        2080
      ],
      "parameters": {
        "simple": false,
        "filters": {},
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "JpuoplF0PostDvKB",
          "name": "Gmail account"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "d1d4a3be-70bc-436b-a7b9-2ee00e426a55",
      "name": "Gemini 2.5",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        3312,
        2288
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "id": "7v8o9EaQkl33woxm",
          "name": "v9"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "dd551d6b-adb2-473b-8982-8ac9b3be46b3",
      "name": "Gmail 回复",
      "type": "n8n-nodes-base.gmail",
      "position": [
        3664,
        2080
      ],
      "webhookId": "781b8efc-e90e-4f90-98f1-d92c2a42f088",
      "parameters": {
        "message": "={{ $json.output }}",
        "options": {
          "appendAttribution": false
        },
        "emailType": "text",
        "messageId": "={{ $('Gmail Trigger').item.json.id }}",
        "operation": "reply"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "JpuoplF0PostDvKB",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "32c51c6d-4ba8-45c4-b689-a7906d5a66b6",
      "name": "Cohere 重新排序器",
      "type": "@n8n/n8n-nodes-langchain.rerankerCohere",
      "position": [
        3744,
        2448
      ],
      "parameters": {},
      "credentials": {
        "cohereApi": {
          "id": "5UlwdPGx9tyNlbT4",
          "name": "CohereAI"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "5a55a56f-07f0-4da9-b333-be81d39c49c7",
      "name": "Pinecone 检索器",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        3568,
        2288
      ],
      "parameters": {
        "mode": "retrieve-as-tool",
        "topK": 10,
        "options": {},
        "useReranker": true,
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "agency-info",
          "cachedResultName": "agency-info"
        },
        "toolDescription": "Info About <agency> services, owner and general FAQ"
      },
      "credentials": {
        "pineconeApi": {
          "id": "2ZmkLkdFEmSRzqgm",
          "name": "PineconeApi"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "fd1413ab-433f-43f0-9dbf-6726c62fac44",
      "name": "OpenAI 嵌入",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        3568,
        2448
      ],
      "parameters": {
        "model": "text-embedding-3-large",
        "options": {
          "dimensions": 1024
        }
      },
      "credentials": {
        "openAiApi": {
          "id": "ymMvgDroJHalwvRf",
          "name": "OpenAI"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "b587ef62-ec9c-4727-ac16-6e5b2862fe78",
      "name": "电子邮件支持代理",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        3312,
        2080
      ],
      "parameters": {
        "text": "={{ $json.text }}",
        "options": {
          "systemMessage": "You are an email support agent for the agency. Use the pinecone tool to access its knowledge base."
        },
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "11ccc8a7-11fb-4bbc-8593-7d203de1614e",
      "name": "Postgres 内存",
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "position": [
        3408,
        2384
      ],
      "parameters": {
        "tableName": "email_support_agent_",
        "sessionKey": "={{ $json.id }}",
        "sessionIdType": "customKey"
      },
      "credentials": {
        "postgres": {
          "id": "TDX9l1042HXNo9nB",
          "name": "Neon - n8n chat"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "e2482901-3f58-4adb-817d-cbd48f777f7b",
      "name": "注意:Pinecone",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3856,
        2128
      ],
      "parameters": {
        "color": 2,
        "width": 350,
        "height": 240,
        "content": "## 🗄️ 节点:Pinecone 检索器"
      },
      "typeVersion": 1
    },
    {
      "id": "95398a05-9d35-4913-83ab-62bb9113594b",
      "name": "注意:Cohere",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3472,
        2592
      ],
      "parameters": {
        "color": 3,
        "width": 398,
        "height": 244,
        "content": "## 🔄 节点:Cohere 重新排序器"
      },
      "typeVersion": 1
    },
    {
      "id": "f578bcf8-4019-4c0e-abe3-78dc5b85c026",
      "name": "注意:代理",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3088,
        1792
      ],
      "parameters": {
        "color": 5,
        "width": 398,
        "height": 252,
        "content": "## 🤖 节点:电子邮件支持代理"
      },
      "typeVersion": 1
    },
    {
      "id": "ab002e7f-180b-439d-a544-a9daae2d68c5",
      "name": "概述注意1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2256,
        1712
      ],
      "parameters": {
        "color": 4,
        "width": 728,
        "height": 1480,
        "content": "# 带有 RAG 和 Cohere 重新排序的 AI 电子邮件支持代理"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Gemini 2.5": {
      "ai_languageModel": [
        [
          {
            "node": "Email Support Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "Email Support Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Cohere Reranker": {
      "ai_reranker": [
        [
          {
            "node": "Pinecone Retriever",
            "type": "ai_reranker",
            "index": 0
          }
        ]
      ]
    },
    "Postgres Memory": {
      "ai_memory": [
        [
          {
            "node": "Email Support Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Embeddings": {
      "ai_embedding": [
        [
          {
            "node": "Pinecone Retriever",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Pinecone Retriever": {
      "ai_tool": [
        [
          {
            "node": "Email Support Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Email Support Agent": {
      "main": [
        [
          {
            "node": "Gmail Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级

需要付费吗?

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

工作流信息
难度等级
中级
节点数量12
分类-
节点类型9
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
Daniel Nkencho

Daniel Nkencho

@daniel-automates

AI Automation Consultant | Helping Business Owners Implement AI Systems for growth and lead gen

外部链接
在 n8n.io 查看

分享此工作流