8
n8n 中文网amn8n.com

创建注重隐私的AI助手(Telegram + Ollama + Whisper)

高级

这是一个AI Chatbot, Multimodal AI领域的自动化工作流,包含 17 个节点。主要使用 If, Switch, Telegram, RenameKeys, HttpRequest 等节点。 使用Telegram、Ollama和Whisper创建注重隐私的AI助手

前置要求
  • Telegram Bot Token
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "Rkx3j2cBXiT3NLtq",
  "meta": {
    "instanceId": "68c78b5f5127dab9c9c85759cf1cc527cbfc0b062ed9029302333429c7a80fff",
    "templateCredsSetupCompleted": true
  },
  "name": "创建注重隐私的 AI 助手(Telegram + Ollama + Whisper)",
  "tags": [],
  "nodes": [
    {
      "id": "60ac6d31-82e4-4895-95fd-8c62a635b81b",
      "name": "Telegram 触发器",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        0,
        -20
      ],
      "webhookId": "5ecca1a2-488b-4ecb-9227-7283aa601b8d",
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {
          "download": true
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "jF0NoI1ZviINMHer",
          "name": "PersonalAssistant"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "9a8e1386-d472-4c2c-9f44-f0d8df6d02e0",
      "name": "获取语音文件",
      "type": "n8n-nodes-base.telegram",
      "position": [
        660,
        -45
      ],
      "webhookId": "f53d1f07-adb9-4ee8-a5ff-26bd17038cf0",
      "parameters": {
        "fileId": "={{ $json.message.voice.file_id }}",
        "resource": "file"
      },
      "credentials": {
        "telegramApi": {
          "id": "jF0NoI1ZviINMHer",
          "name": "PersonalAssistant"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "f258d1ef-fcab-420a-a7a9-61b7f80cec5d",
      "name": "消息类型判断",
      "type": "n8n-nodes-base.switch",
      "position": [
        440,
        -120
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "text",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "a2d6691c-beed-44d8-a67f-be43b28155df",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.message.text }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "voice",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "6ce5f222-d555-470b-862d-e132b9a5fb72",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.message.voice.file_id }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "2507b938-0a44-44f6-838a-6ccc33e27d24",
      "name": "授权检查条件判断",
      "type": "n8n-nodes-base.if",
      "position": [
        220,
        -20
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "d2e36e10-3ffc-47ab-bf1a-3c9639b0106a",
              "operator": {
                "type": "number",
                "operation": "equals"
              },
              "leftValue": "={{ $json.message.from.id }}",
              "rightValue": null
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "4355f058-2648-408f-ac1b-1b350b6aed10",
      "name": "发送文本消息",
      "type": "n8n-nodes-base.telegram",
      "position": [
        440,
        80
      ],
      "webhookId": "d669815c-1907-472c-a6aa-a2783853642c",
      "parameters": {
        "text": "I am sorry, you have no access to my services.",
        "chatId": "={{ json.message.from.id }}",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "jF0NoI1ZviINMHer",
          "name": "PersonalAssistant"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "6035caa1-9b21-4401-a92f-5499b536b95d",
      "name": "Whisper ASR HTTP 请求",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        880,
        -45
      ],
      "parameters": {
        "url": "http://localhost:9000/asr",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "name": "audio_file",
              "parameterType": "formBinaryData",
              "inputDataFieldName": "data"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "6bce3f08-cebf-4b45-9b5c-0cf098afbd96",
      "name": "发送文本消息1",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1696,
        -120
      ],
      "webhookId": "3711915e-e974-4fb7-ad40-4403538c1ba1",
      "parameters": {
        "text": "={{ $json.output }}",
        "chatId": "",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "jF0NoI1ZviINMHer",
          "name": "PersonalAssistant"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "8dce296d-4991-42a0-a87f-bb00a1f6e2d1",
      "name": "AI 代理",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1320,
        -120
      ],
      "parameters": {
        "text": "=You are my personal chatbot assistant.\nMy input: '{{ $json.message.text }}'.\nYour Answer: ",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "f476f17a-2be8-4573-a862-ae32162d3060",
      "name": "Ollama 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOllama",
      "position": [
        1348,
        100
      ],
      "parameters": {
        "model": "llama3.2:1b",
        "options": {}
      },
      "credentials": {
        "ollamaApi": {
          "id": "1gnjAn8BMXTjWvEX",
          "name": "Ollama account 2"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "80e6b57c-bd5b-40f3-b6e8-f8014d68e04d",
      "name": "简单记忆",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1468,
        100
      ],
      "parameters": {
        "sessionKey": "={{ $json.message.text }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 2
      },
      "typeVersion": 1.3
    },
    {
      "id": "bafa884d-00e4-4882-8a45-551ebaafeb57",
      "name": "重命名转录键",
      "type": "n8n-nodes-base.renameKeys",
      "position": [
        1100,
        -45
      ],
      "parameters": {
        "keys": {
          "key": [
            {
              "newKey": "message.text",
              "currentKey": "data"
            }
          ]
        },
        "additionalOptions": {}
      },
      "typeVersion": 1
    },
    {
      "id": "f2f41dd0-b1f7-4abc-8db4-6539dd1a2288",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -60,
        -200
      ],
      "parameters": {
        "content": "## Telegram 触发器"
      },
      "typeVersion": 1
    },
    {
      "id": "a02a2a95-6141-4e30-87eb-547c7a8228a3",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        260,
        -300
      ],
      "parameters": {
        "content": "## 条件判断"
      },
      "typeVersion": 1
    },
    {
      "id": "269b02bc-fb27-42a9-9d82-3708f359b812",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        600,
        -260
      ],
      "parameters": {
        "content": "## 分支判断"
      },
      "typeVersion": 1
    },
    {
      "id": "a2fcd43b-828b-472e-9a88-2c0f7b66b927",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        840,
        140
      ],
      "parameters": {
        "content": "## 语音转录"
      },
      "typeVersion": 1
    },
    {
      "id": "6da6c91c-9be4-4385-b93b-df5f12b4c305",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1320,
        -300
      ],
      "parameters": {
        "content": "## AI Agent"
      },
      "typeVersion": 1
    },
    {
      "id": "d9cb4fbc-cb85-4381-aa41-b6e548760e07",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1620,
        -300
      ],
      "parameters": {
        "content": "## Telegram"
      },
      "typeVersion": 1
    }
  ],
  "active": true,
  "pinData": {},
  "settings": {
    "callerPolicy": "workflowsFromSameOwner",
    "executionOrder": "v1"
  },
  "versionId": "160c1b3b-9a50-44c7-93e3-dd29d0d547c8",
  "connections": {
    "8dce296d-4991-42a0-a87f-bb00a1f6e2d1": {
      "main": [
        [
          {
            "node": "6bce3f08-cebf-4b45-9b5c-0cf098afbd96",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "80e6b57c-bd5b-40f3-b6e8-f8014d68e04d": {
      "ai_memory": [
        [
          {
            "node": "8dce296d-4991-42a0-a87f-bb00a1f6e2d1",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "9a8e1386-d472-4c2c-9f44-f0d8df6d02e0": {
      "main": [
        [
          {
            "node": "6035caa1-9b21-4401-a92f-5499b536b95d",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "60ac6d31-82e4-4895-95fd-8c62a635b81b": {
      "main": [
        [
          {
            "node": "2507b938-0a44-44f6-838a-6ccc33e27d24",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "f476f17a-2be8-4573-a862-ae32162d3060": {
      "ai_languageModel": [
        [
          {
            "node": "8dce296d-4991-42a0-a87f-bb00a1f6e2d1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "f258d1ef-fcab-420a-a7a9-61b7f80cec5d": {
      "main": [
        [
          {
            "node": "8dce296d-4991-42a0-a87f-bb00a1f6e2d1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "9a8e1386-d472-4c2c-9f44-f0d8df6d02e0",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2507b938-0a44-44f6-838a-6ccc33e27d24": {
      "main": [
        [
          {
            "node": "f258d1ef-fcab-420a-a7a9-61b7f80cec5d",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "4355f058-2648-408f-ac1b-1b350b6aed10",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "bafa884d-00e4-4882-8a45-551ebaafeb57": {
      "main": [
        [
          {
            "node": "8dce296d-4991-42a0-a87f-bb00a1f6e2d1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "6035caa1-9b21-4401-a92f-5499b536b95d": {
      "main": [
        [
          {
            "node": "bafa884d-00e4-4882-8a45-551ebaafeb57",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - AI 聊天机器人, 多模态 AI

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流

分类

分类: 34