8
n8n 中文网amn8n.com

集成MySQL数据库的AI聊天机器人工作流

中级

这是一个Engineering, DevOps, Product, AI, IT Ops领域的自动化工作流,包含 11 个节点。主要使用 MySqlTool, Agent, LmChatGroq, ChatTrigger, MemoryBufferWindow 等节点,结合人工智能技术实现智能自动化。 集成MySQL数据库的AI驱动聊天机器人工作流

前置要求
  • MySQL 数据库连接信息
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "f0daacbbece4d36ce73ed214e506ba3899410c0e00a1b6cd1d93e012465d1082"
  },
  "nodes": [
    {
      "id": "e1055031-f1f1-44dd-8e3b-18b9f543aac2",
      "name": "当接收到聊天消息时",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -60,
        -80
      ],
      "webhookId": "cf1de04f-3e38-426c-89f0-3bdb110a5dcf",
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "88eaaf60-aed6-4e9d-9667-d2838a8e7f78",
      "name": "聊天历史",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        280,
        120
      ],
      "parameters": {},
      "typeVersion": 1.3
    },
    {
      "id": "a5b49dee-d5e4-4324-a7f8-1638e4e41abd",
      "name": "MySQL",
      "type": "n8n-nodes-base.mySqlTool",
      "position": [
        460,
        120
      ],
      "parameters": {},
      "typeVersion": 2.4
    },
    {
      "id": "7abfcdc7-dfc5-4627-a479-82dd38404c88",
      "name": "MySQL 架构",
      "type": "n8n-nodes-base.mySqlTool",
      "position": [
        640,
        120
      ],
      "parameters": {},
      "typeVersion": 2.4
    },
    {
      "id": "bc9dfb90-0696-4801-a5c2-741c2fd27855",
      "name": "MySQL 定义",
      "type": "n8n-nodes-base.mySqlTool",
      "position": [
        820,
        120
      ],
      "parameters": {},
      "typeVersion": 2.4
    },
    {
      "id": "fd8344a4-ee89-4365-ae36-cc39f26c47df",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        360,
        -80
      ],
      "parameters": {},
      "typeVersion": 1.7
    },
    {
      "id": "4849ec08-2ab9-46f2-bc8c-f9dad3196246",
      "name": "Groq 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatGroq",
      "position": [
        100,
        120
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "400a5f98-60af-4acb-950a-085402f3502d",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        60,
        300
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "5859cd82-9d6c-4783-8ef9-44cd4d800148",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        240,
        300
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "599c02ac-7246-4cab-8bdd-1f6565ece04d",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        420,
        300
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "33cbfb73-10e5-428b-ba71-539be16e7bc7",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -60,
        -300
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "MySQL": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Chat History": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "MySQL Schema": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Groq Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "MySQL Definition": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 工程, 开发运维, 产品, 人工智能, IT 运维

需要付费吗?

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

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

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

作者
Gegenfeld

Gegenfeld

@gegenfeld

We at Gegenfeld are an EdTech platform dedicated to delivering high-quality on-demand courses and interactive training sessions for professional development at all skill levels. With our commitment to "Accelerate your future," we empower professionals to enhance their expertise through engaging, industry-focused learning experiences. On n8n, we share some of the workflows used in our interactive training to provide deeper insights and practical applications.

外部链接
在 n8n.io 查看

分享此工作流