8
n8n 中文网amn8n.com

GPT-4o Vision与Telegram图像分析与文本提取

高级

这是一个Document Extraction, Multimodal AI领域的自动化工作流,包含 16 个节点。主要使用 Code, Telegram, HttpRequest, ExtractFromFile, TelegramTrigger 等节点。 使用GPT-4o Vision和Telegram分析图像并提取文本

前置要求
  • Telegram Bot Token
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "355b2d103ad4834400263e78c73e64bbdb709c896780479c01a9ab9ccd7df6cf",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "fe8f2304-f2f6-45d5-8f26-3e07f59f2122",
      "name": "便签 — 概述",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1744,
        944
      ],
      "parameters": {
        "color": 5,
        "width": 560,
        "height": 496,
        "content": "# 📸 Telegram → AIMLAPI 视觉机器人"
      },
      "typeVersion": 1
    },
    {
      "id": "fc3443dd-7c1d-478f-846b-e20b2d480898",
      "name": "便签 — 设置指南",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2320,
        944
      ],
      "parameters": {
        "color": 5,
        "width": 560,
        "height": 496,
        "content": "# 🛠 设置指南"
      },
      "typeVersion": 1
    },
    {
      "id": "a00ee4eb-0c89-48a2-87c1-000197b71a55",
      "name": "便签 — 接收消息",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        944,
        1552
      ],
      "parameters": {
        "color": 3,
        "width": 384,
        "height": 448,
        "content": "# 📥 步骤 1 — 接收 Telegram 消息"
      },
      "typeVersion": 1
    },
    {
      "id": "375019d6-a2c0-438c-950c-376603599dc5",
      "name": "便签 — GPT‑5 处理",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1744,
        1552
      ],
      "parameters": {
        "width": 384,
        "height": 448,
        "content": "# 📷 步骤 2 — 获取照片"
      },
      "typeVersion": 1
    },
    {
      "id": "e58d2186-f12e-43a4-9b7c-a644d27e64fa",
      "name": "便签 — 发送回复",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2144,
        1552
      ],
      "parameters": {
        "color": 4,
        "width": 384,
        "height": 448,
        "content": "# 🧩 步骤 3 — 转换为 base64"
      },
      "typeVersion": 1
    },
    {
      "id": "06a31bfb-15af-40fe-b468-057cf985180f",
      "name": "便签 — 日志记录",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2944,
        1552
      ],
      "parameters": {
        "color": 5,
        "width": 384,
        "height": 448,
        "content": "# 🧠 步骤 4 — AIMLAPI Vision"
      },
      "typeVersion": 1
    },
    {
      "id": "7cc29371-2e04-440c-baea-4f7a716a5acf",
      "name": "便签 — 接收消息1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1344,
        1552
      ],
      "parameters": {
        "color": 3,
        "width": 384,
        "height": 448,
        "content": "# 💬 步骤 1.5 — 模拟输入"
      },
      "typeVersion": 1
    },
    {
      "id": "3eb41a97-ae1e-45df-8699-99c7db819cf0",
      "name": "便签 — 发送回复1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2544,
        1552
      ],
      "parameters": {
        "color": 4,
        "width": 384,
        "height": 448,
        "content": "# 🧑‍💻 步骤 3.5 — 标准化 MIME"
      },
      "typeVersion": 1
    },
    {
      "id": "d616db57-d547-42b7-8b75-d41d769ad814",
      "name": "便签 — 日志记录1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3344,
        1552
      ],
      "parameters": {
        "color": 5,
        "width": 384,
        "height": 448,
        "content": "# 📤 步骤 5 — 发送回复"
      },
      "typeVersion": 1
    },
    {
      "id": "d9b3cdf6-096d-426a-811b-9b35fa15f759",
      "name": "步骤 1 · 📩 Telegram 触发器(输入)",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        1072,
        1824
      ],
      "webhookId": "36951b18-32a3-4bd5-9fd5-be7ec180114f",
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "cFC7gGbzU7PQGk6J",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "969d9b61-fcab-4907-b670-ef12da530051",
      "name": "步骤 1.5 · 💬 正在输入…",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1472,
        1824
      ],
      "webhookId": "a048d256-da8b-4302-bc9c-ad03955ef7af",
      "parameters": {
        "chatId": "={{ $json.message.chat.id }}",
        "operation": "sendChatAction"
      },
      "credentials": {
        "telegramApi": {
          "id": "cFC7gGbzU7PQGk6J",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "e24fb8ae-5090-45b4-bc77-4d2ddb054245",
      "name": "步骤 2 · 📷 获取照片",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1888,
        1824
      ],
      "webhookId": "94d3ad2f-9d08-414e-a323-7e56904768cf",
      "parameters": {
        "fileId": "={{ $('Step 1 · 📩 Telegram Trigger (In)').item.json.message.photo[$('Step 1 · 📩 Telegram Trigger (In)').item.json.message.photo.length - 1].file_id }}",
        "resource": "file",
        "additionalFields": {
          "mimeType": "image/jpeg"
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "cFC7gGbzU7PQGk6J",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "34e8b41b-ccd9-431c-92a0-0b1471295c55",
      "name": "步骤 3 · 🧩 提取 → base64",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        2288,
        1824
      ],
      "parameters": {
        "options": {},
        "operation": "binaryToPropery"
      },
      "typeVersion": 1
    },
    {
      "id": "3cc458c3-ff28-4d34-9e40-769fa229f8ff",
      "name": "步骤 3.5 · 🧑‍💻 构建 Data URI",
      "type": "n8n-nodes-base.code",
      "position": [
        2672,
        1824
      ],
      "parameters": {
        "jsCode": "// Build a proper Data URI for Vision API\n// Base64 from previous node\nconst base64Data = $input.first().json.data;;\n\n// Telegram may report image/jpg; normalize to image/jpeg\nlet fixedMime = 'image/jpeg';\n\nreturn [{\n  dataUri: `data:${fixedMime};base64,${base64Data}`\n}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "dbc396b9-d19a-4f7a-a26a-77b60d3cc9bc",
      "name": "步骤 4 · 🧠 AIMLAPI Vision (HTTP)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3088,
        1824
      ],
      "parameters": {
        "url": "https://api.aimlapi.com/v1/chat/completions",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"model\": \"openai/gpt-4o\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": [\n        {\n          \"type\": \"text\",\n          \"text\": \"Describe this image. Then extract any visible text (OCR). Keep it concise.\"\n        },\n        {\n          \"type\": \"image_url\",\n          \"image_url\": {\n            \"url\": \"{{ $json.dataUri }}\"\n          }\n        }\n      ]\n    }\n  ],\n  \"max_tokens\": 300\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "aimlApi"
      },
      "credentials": {
        "aimlApi": {
          "id": "EXXHjMACiSMAhuC8",
          "name": "AI/ML account"
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.2
    },
    {
      "id": "ca71edf8-19e8-4f9f-acbb-506a1bcb0240",
      "name": "步骤 5 · 📤 回复到 Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3488,
        1824
      ],
      "webhookId": "78700f84-9668-4cf2-afb4-8e771a8c9d6a",
      "parameters": {
        "text": "={{ $json?.choices?.[0]?.message?.content || \"Sorry, the model returned an empty response.\" }}",
        "chatId": "={{ $('Step 1 · 📩 Telegram Trigger (In)').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false,
          "reply_to_message_id": "={{ $('Step 1 · 📩 Telegram Trigger (In)').item.json.message.message_id }}",
          "disable_web_page_preview": true
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "cFC7gGbzU7PQGk6J",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    }
  ],
  "pinData": {},
  "connections": {
    "Step 2 · 📷 Get Photo": {
      "main": [
        [
          {
            "node": "Step 3 · 🧩 Extract → base64",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Step 1.5 · 💬 Typing…": {
      "main": [
        [
          {
            "node": "Step 2 · 📷 Get Photo",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Step 3 · 🧩 Extract → base64": {
      "main": [
        [
          {
            "node": "Step 3.5 · 🧑‍💻 Build Data URI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Step 1 · 📩 Telegram Trigger (In)": {
      "main": [
        [
          {
            "node": "Step 1.5 · 💬 Typing…",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Step 4 · 🧠 AIMLAPI Vision (HTTP)": {
      "main": [
        [
          {
            "node": "Step 5 · 📤 Reply to Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Step 3.5 · 🧑‍💻 Build Data URI": {
      "main": [
        [
          {
            "node": "Step 4 · 🧠 AIMLAPI Vision (HTTP)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 文档提取, 多模态 AI

需要付费吗?

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

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

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

作者
外部链接
在 n8n.io 查看

分享此工作流