8
n8n 中文网amn8n.com

Telegram 上的个人 AI 助手

高级

这是一个Personal Productivity, AI Chatbot领域的自动化工作流,包含 18 个节点。主要使用 Set, Switch, Telegram, Agent, TelegramTrigger 等节点。 语音与文本Telegram助手,集成GPT-4.1-mini和对话记忆

前置要求
  • Telegram Bot Token
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "AVzZ0VuRrjztizVp",
  "meta": {
    "instanceId": "0262c5f4d433c921784d8cec7f9673161a659640dd7d351c2e09acc65228f34b",
    "templateCredsSetupCompleted": true
  },
  "name": "Telegram 上的个人 AI 助手",
  "tags": [
    {
      "id": "1yZiArijt4TA2xCQ",
      "name": "assistant",
      "createdAt": "2025-10-13T20:19:10.089Z",
      "updatedAt": "2025-10-13T20:19:10.089Z"
    },
    {
      "id": "dq2RsbUNZZAcjqKZ",
      "name": "telegram",
      "createdAt": "2025-10-13T20:19:10.091Z",
      "updatedAt": "2025-10-13T20:19:10.091Z"
    }
  ],
  "nodes": [
    {
      "id": "a3b8de01-dfe2-4973-affa-f602c07a0b65",
      "name": "Telegram 触发器",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -64,
        80
      ],
      "webhookId": "408df290-be7c-4911-8af5-6bfbc09414ec",
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "L29XF6rMuKkBrwqD",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "4be5becc-3487-498d-b796-b40a91b9329c",
      "name": "AI 代理",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1392,
        48
      ],
      "parameters": {
        "text": "={{ $json.message.text }}",
        "options": {
          "systemMessage": "=You are a personal assistant that helps user fulfill their requests.\n\nWhen you are asked to perform a task on the current date, please use the current time and date :  {{ $now }}\n\n## OUtput\n\nYou should output the result and don't include any thing unnecessary. Just  make sure that you politely answer user question and ask if any other information is required."
        },
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "67b709b2-68ce-49c1-ad70-d13e67bcecce",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1360,
        352
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini",
          "cachedResultName": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "2TIKLr6R47YRZp7X",
          "name": "OpenAi account 2"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "1815073f-3372-4021-84bf-9c117f01a111",
      "name": "编辑字段",
      "type": "n8n-nodes-base.set",
      "position": [
        1024,
        -80
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "ed66987c-b2d8-4e33-bad2-e6476c594990",
              "name": "message.text",
              "type": "string",
              "value": "={{ $json.message.text }}"
            },
            {
              "id": "93500e9e-a398-49f4-b4d3-151bcf68d44c",
              "name": "sessionId",
              "type": "number",
              "value": "={{ $json.message.chat.id }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "0cfb4cc4-5b87-4b1e-bf09-50e875605640",
      "name": "发送短信",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1888,
        48
      ],
      "webhookId": "4701162a-d6c8-4416-aa08-21da49cb3b5f",
      "parameters": {
        "text": "={{ $json.output }}",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "L29XF6rMuKkBrwqD",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "cd8ef26f-5f45-46ec-a152-dc14fcbdf398",
      "name": "简单记忆",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1552,
        352
      ],
      "parameters": {
        "sessionKey": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 7
      },
      "typeVersion": 1.3
    },
    {
      "id": "7d32da5c-90c7-4c7f-942a-cfdb44d471f6",
      "name": "切换",
      "type": "n8n-nodes-base.switch",
      "position": [
        256,
        80
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "text",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "feabf872-0ae2-4749-a240-4997aa07c59f",
                    "operator": {
                      "type": "boolean",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.message.text }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "voice",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "aca5831b-bc5d-4b59-aae2-0e450eb2221f",
                    "operator": {
                      "type": "boolean",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.message.voice.file_id }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {},
        "looseTypeValidation": true
      },
      "typeVersion": 3.2
    },
    {
      "id": "951546cb-0d17-44f0-80c8-cedcb64269c3",
      "name": "获取文件",
      "type": "n8n-nodes-base.telegram",
      "position": [
        512,
        320
      ],
      "webhookId": "f7442c68-5fed-40b4-b94c-0c280bf16b52",
      "parameters": {
        "fileId": "={{ $json.message.voice.file_id }}",
        "resource": "file",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "L29XF6rMuKkBrwqD",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "42f0d043-b796-425e-a4ff-5c3a2136d02c",
      "name": "转录录音",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        752,
        320
      ],
      "parameters": {
        "options": {},
        "resource": "audio",
        "operation": "transcribe"
      },
      "credentials": {
        "openAiApi": {
          "id": "2TIKLr6R47YRZp7X",
          "name": "OpenAi account 2"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "f02a02f5-917a-424e-a24a-ae3b1b40fa09",
      "name": "编辑字段 1",
      "type": "n8n-nodes-base.set",
      "position": [
        1024,
        320
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "7f5016ec-e3f5-491e-8684-cf240b0fc116",
              "name": "message.text",
              "type": "string",
              "value": "={{ $json.text }}"
            },
            {
              "id": "b763d61b-3378-4bec-bc45-3578071e54e3",
              "name": "sessionId",
              "type": "string",
              "value": "={{ $('Telegram Trigger').item.json.message.chat.id }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "1103380a-2e93-492f-81ab-0f90851605ae",
      "name": "便签12",
      "type": "n8n-nodes-base.stickyNote",
      "notes": "2025 Balakrishnan",
      "creator": "Balakrishnan",
      "position": [
        -128,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 236,
        "height": 252,
        "content": "💡 它激活此工作流并触发/启动 Telegram 消息!"
      },
      "typeVersion": 1
    },
    {
      "id": "d34e0902-7667-44c8-a59b-8b97a2830b23",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "notes": "2025 Balakrishnan",
      "creator": "Balakrishnan",
      "position": [
        176,
        -48
      ],
      "parameters": {
        "color": 7,
        "width": 252,
        "height": 300,
        "content": "💡 它分割来自用户的输入。如果用户输入是文本,则直接进入测试字段。否则将被转换为文本格式。"
      },
      "typeVersion": 1
    },
    {
      "id": "f39d3b38-725e-4621-9fa1-c3b9051e7aea",
      "name": "便签15",
      "type": "n8n-nodes-base.stickyNote",
      "notes": "2025 Balakrishnan",
      "creator": "Balakrishnan",
      "position": [
        368,
        288
      ],
      "parameters": {
        "color": 7,
        "width": 276,
        "height": 244,
        "content": "💡 此节点帮助您的代理获取语音笔记文件"
      },
      "typeVersion": 1
    },
    {
      "id": "01cf3628-2ef2-4307-b46f-0b9412120992",
      "name": "便签 16",
      "type": "n8n-nodes-base.stickyNote",
      "notes": "2025 Balakrishnan",
      "creator": "Balakrishnan",
      "position": [
        672,
        288
      ],
      "parameters": {
        "color": 7,
        "width": 292,
        "height": 276,
        "content": "💡 转录器帮助将语音转换为文字/文本格式,以分析用户的词语。"
      },
      "typeVersion": 1
    },
    {
      "id": "8b9899c0-f007-4a2b-b0f8-4ebd7e866e46",
      "name": "便签17",
      "type": "n8n-nodes-base.stickyNote",
      "notes": "2025 Balakrishnan",
      "creator": "Balakrishnan",
      "position": [
        992,
        -160
      ],
      "parameters": {
        "color": 7,
        "width": 276,
        "height": 724,
        "content": "💡 这些节点从 Telegram 获取输入文本消息。然后将其抛给 AI 代理,借助 OpenAI 聊天模型提供回复!"
      },
      "typeVersion": 1
    },
    {
      "id": "5726d2ac-c4cb-4e74-b8db-23ec20f16979",
      "name": "便签13",
      "type": "n8n-nodes-base.stickyNote",
      "notes": "2025 Balakrishnan",
      "creator": "Balakrishnan",
      "position": [
        1296,
        -96
      ],
      "parameters": {
        "color": 7,
        "width": 396,
        "height": 300,
        "content": "💡 您的 AI 代理可以:"
      },
      "typeVersion": 1
    },
    {
      "id": "99437331-d7d5-4d42-94bd-75105baa5562",
      "name": "便签18",
      "type": "n8n-nodes-base.stickyNote",
      "notes": "2025 Balakrishnan",
      "creator": "Balakrishnan",
      "position": [
        1296,
        304
      ],
      "parameters": {
        "color": 7,
        "width": 436,
        "height": 324,
        "content": "💡 这是 **GPT 4.1 mini** 聊天模型。这里我们需要连接我们的 **API 密钥** 来利用此 AI 模型。"
      },
      "typeVersion": 1
    },
    {
      "id": "bed59b48-c359-4200-b4a6-eadab0e28c7b",
      "name": "便签14",
      "type": "n8n-nodes-base.stickyNote",
      "notes": "2025 Balakrishnan",
      "creator": "Balakrishnan",
      "position": [
        1776,
        -96
      ],
      "parameters": {
        "color": 7,
        "width": 316,
        "height": 316,
        "content": "💡 这将把响应发送回 Telegram 用户。"
      },
      "typeVersion": 1
    }
  ],
  "active": true,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "dd57966f-ee98-4844-8b12-f72a782dc0a3",
  "connections": {
    "Switch": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get a file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Send a text message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get a file": {
      "main": [
        [
          {
            "node": "Transcribe a recording",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields1": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Transcribe a recording": {
      "main": [
        [
          {
            "node": "Edit Fields1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 个人效率, AI 聊天机器人

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流