8
n8n 中文网amn8n.com

法律助理代理

中级

这是一个AI领域的自动化工作流,包含 11 个节点。主要使用 Telegram, Agent, TelegramTrigger, LmChatOpenAi, EmbeddingsOpenAi 等节点,结合人工智能技术实现智能自动化。 🧑‍⚖️ AI法律助理代理 — 基于AI的法律问答与文档检索

前置要求
  • Telegram Bot Token
  • OpenAI API Key
  • Pinecone API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "rPicfavvntizpQkM",
  "meta": {
    "instanceId": "1c7b08fed4406d546caf4a44e8b942ca317e7e207bb9a5701955a1a6e1ce1843",
    "templateCredsSetupCompleted": true
  },
  "name": "法律助理代理",
  "tags": [],
  "nodes": [
    {
      "id": "81b14e7a-0dde-4dd3-aa1b-943c1857903d",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        220,
        0
      ],
      "parameters": {
        "text": "={{ $json.message.text }}",
        "options": {
          "systemMessage": "You are a helpful legal assistant. Your task is to answer legal questions of the users by referring to the Pinecone Vector Database \"Legal Contract Library\" to get an accurate answer. \n#Rule\nDo not make up facts, if you do not have the right information, you may say so."
        },
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "53d344e5-773b-432a-8940-00a9b6814ee8",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        80,
        240
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "38b9de84-bfee-4d66-b22a-f95bcd78b9a6",
      "name": "OpenAI 嵌入",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        520,
        360
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openAiApi": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "be801891-2ac9-4871-b54b-72491eb9b962",
      "name": "法律合同库",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        360,
        240
      ],
      "parameters": {
        "mode": "retrieve-as-tool",
        "options": {},
        "toolName": "Redacted",
        "pineconeIndex": {
          "__rl": true,
          "mode": "id",
          "value": "Redacted"
        },
        "toolDescription": "Extract, contracts, legal policies and relevant regulatory documents here."
      },
      "credentials": {
        "pineconeApi": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "8cbbb27e-5c31-4c8e-93a1-7515b28649b6",
      "name": "Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        820,
        0
      ],
      "webhookId": "",
      "parameters": {
        "text": "={{ $json.output }}",
        "chatId": "",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "c664b9b0-cf1b-454c-b943-adcc3f0a8de5",
      "name": "Telegram 触发器",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -200,
        0
      ],
      "webhookId": "",
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "f4fa00fd-5e18-4a81-8263-b3bf2d52cb9e",
      "name": "简单记忆1",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        240,
        240
      ],
      "parameters": {
        "sessionKey": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 10
      },
      "typeVersion": 1.3
    },
    {
      "id": "f2aff94c-ad46-4759-90f0-368d420219e2",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -340,
        -160
      ],
      "parameters": {
        "width": 340,
        "height": 700,
        "content": "Telegram 消息触发器"
      },
      "typeVersion": 1
    },
    {
      "id": "4eb385e9-5caf-46f3-97a3-bac95c210c78",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        20,
        -160
      ],
      "parameters": {
        "color": 3,
        "width": 720,
        "height": 700,
        "content": "法律助理 AI 代理"
      },
      "typeVersion": 1
    },
    {
      "id": "252a59c6-90aa-4ca4-9a4e-2905b69cc984",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        760,
        -160
      ],
      "parameters": {
        "color": 4,
        "width": 280,
        "height": 700,
        "content": "Telegram 输出"
      },
      "typeVersion": 1
    },
    {
      "id": "beaef1c7-48cb-4f35-a0d7-b5819a0e99fe",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1180,
        -160
      ],
      "parameters": {
        "color": 6,
        "width": 820,
        "height": 1180,
        "content": "🧑‍⚖️ 法律助理代理 — 基于 AI 的法律问答与文档检索"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "0cec767c-2903-4bfb-999a-5668fcadd39d",
  "connections": {
    "AI Agent": {
      "main": [
        [
          {
            "node": "Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory1": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI": {
      "ai_embedding": [
        [
          {
            "node": "Legal Contract Library",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Legal Contract Library": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 人工智能

需要付费吗?

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

工作流信息
难度等级
中级
节点数量11
分类1
节点类型8
难度说明

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

作者
Automate With Marc

Automate With Marc

@marconi

Automating Start-Up and Business processes. Helping non-techies understand and leverage Agentic AI with easy to understand step-by-step tutorials. Check out my educational content: https://www.youtube.com/@Automatewithmarc

外部链接
在 n8n.io 查看

分享此工作流