Analyse d'images Telegram avec la vision GPT-4o et extraction de texte

Avancé

Ceci est unDocument Extraction, Multimodal AIworkflow d'automatisation du domainecontenant 16 nœuds.Utilise principalement des nœuds comme Code, Telegram, HttpRequest, ExtractFromFile, TelegramTrigger. Analyser des images et extraire du texte avec GPT-4o Vision et Telegram

Prérequis
  • Token Bot Telegram
  • Peut nécessiter les informations d'identification d'authentification de l'API cible
Aperçu du workflow
Visualisation des connexions entre les nœuds, avec support du zoom et du déplacement
Exporter le workflow
Copiez la configuration JSON suivante dans n8n pour importer et utiliser ce workflow
{
  "meta": {
    "instanceId": "355b2d103ad4834400263e78c73e64bbdb709c896780479c01a9ab9ccd7df6cf",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "fe8f2304-f2f6-45d5-8f26-3e07f59f2122",
      "name": "Note adhésive — Aperçu",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1744,
        944
      ],
      "parameters": {
        "color": 5,
        "width": 560,
        "height": 496,
        "content": "# 📸 Telegram → AIMLAPI Vision Bot\n\nThis workflow receives photos from users in Telegram, \nencodes them to base64, and sends them to **AIMLAPI** \n(GPT-4o Vision) for analysis.\n\n---\n## 🚀 Features\n* Image content recognition\n* OCR (extract text from photos)\n* Concise description in the reply\n* Automatic response back to Telegram\n"
      },
      "typeVersion": 1
    },
    {
      "id": "fc3443dd-7c1d-478f-846b-e20b2d480898",
      "name": "Note adhésive — Guide d'installation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2320,
        944
      ],
      "parameters": {
        "color": 5,
        "width": 560,
        "height": 496,
        "content": "# 🛠 Setup Guide\n\n### 1. 📲 Create a Telegram Bot\n* In [@BotFather](https://t.me/BotFather) → /newbot\n* Save the API Token\n\n### 2. 🔐 Connect Telegram API in n8n\n* Go to Credentials → Telegram API\n* Paste the token from BotFather\n\n### 3. 🔌 Connect AIMLAPI\n* Go to Credentials → AI/ML API\n* Enter your API Key\n* Base URL: https://api.aimlapi.com/v1\n"
      },
      "typeVersion": 1
    },
    {
      "id": "a00ee4eb-0c89-48a2-87c1-000197b71a55",
      "name": "Note adhésive — Recevoir un message",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        944,
        1552
      ],
      "parameters": {
        "color": 3,
        "width": 384,
        "height": 448,
        "content": "# 📥 Step 1 — Receive Telegram Message\n\nListens for new messages in Telegram.\nExtracts:\n* chat.id (where to reply)\n* photo.file_id (photo file ID)\n"
      },
      "typeVersion": 1
    },
    {
      "id": "375019d6-a2c0-438c-950c-376603599dc5",
      "name": "Note adhésive — Traitement GPT‑5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1744,
        1552
      ],
      "parameters": {
        "width": 384,
        "height": 448,
        "content": "# 📷 Step 2 — Get Photo\n\nFetches the file by `file_id` from Telegram.\nResult: binary photo data (jpg/jpeg/png).\n"
      },
      "typeVersion": 1
    },
    {
      "id": "e58d2186-f12e-43a4-9b7c-a644d27e64fa",
      "name": "Note adhésive — Envoyer une réponse",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2144,
        1552
      ],
      "parameters": {
        "color": 4,
        "width": 384,
        "height": 448,
        "content": "# 🧩 Step 3 — Convert to base64\n\nConverts the binary file into a base64 string,\nwhich will be passed to AIMLAPI Vision.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "06a31bfb-15af-40fe-b468-057cf985180f",
      "name": "Note adhésive — Journalisation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2944,
        1552
      ],
      "parameters": {
        "color": 5,
        "width": 384,
        "height": 448,
        "content": "# 🧠 Step 4 — AIMLAPI Vision\n\nMakes a request to AIMLAPI GPT-4o with:\n1. Instruction: \"Describe this image. Extract visible text.\"\n2. The base64 image passed as `image_url`.\n\nResult: description + OCR text.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "7cc29371-2e04-440c-baea-4f7a716a5acf",
      "name": "Note adhésive — Recevoir un message1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1344,
        1552
      ],
      "parameters": {
        "color": 3,
        "width": 384,
        "height": 448,
        "content": "# 💬 Step 1.5 — Simulate Typing\n\nSends a \"typing…\" action to the user\nwhile the bot processes the photo.\n\nCreates a more natural user experience.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "3eb41a97-ae1e-45df-8699-99c7db819cf0",
      "name": "Note adhésive — Envoyer une réponse1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2544,
        1552
      ],
      "parameters": {
        "color": 4,
        "width": 384,
        "height": 448,
        "content": "# 🧑‍💻 Step 3.5 — Normalize MIME\n\nJS code builds a proper Data URI:\n`data:image/jpeg;base64,...`\n\nTelegram sometimes returns `image/jpg` — \nthis is replaced with the standard `image/jpeg`.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "d616db57-d547-42b7-8b75-d41d769ad814",
      "name": "Note adhésive — Journalisation1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3344,
        1552
      ],
      "parameters": {
        "color": 5,
        "width": 384,
        "height": 448,
        "content": "# 📤 Step 5 — Send Reply\n\nSends the model’s response back to the user \nin Telegram as a text message/caption.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "d9b3cdf6-096d-426a-811b-9b35fa15f759",
      "name": "Étape 1 · 📩 Déclencheur Telegram (Entrée)",
      "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": "Étape 1.5 · 💬 Saisie en cours…",
      "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": "Étape 2 · 📷 Obtenir la photo",
      "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": "Étape 3 · 🧩 Extraire → base64",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        2288,
        1824
      ],
      "parameters": {
        "options": {},
        "operation": "binaryToPropery"
      },
      "typeVersion": 1
    },
    {
      "id": "3cc458c3-ff28-4d34-9e40-769fa229f8ff",
      "name": "Étape 3.5 · 🧑‍💻 Construire l'URI de données",
      "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": "Étape 4 · 🧠 Vision AIMLAPI (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": "Étape 5 · 📤 Répondre à 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": {
    "e24fb8ae-5090-45b4-bc77-4d2ddb054245": {
      "main": [
        [
          {
            "node": "34e8b41b-ccd9-431c-92a0-0b1471295c55",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "969d9b61-fcab-4907-b670-ef12da530051": {
      "main": [
        [
          {
            "node": "e24fb8ae-5090-45b4-bc77-4d2ddb054245",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "34e8b41b-ccd9-431c-92a0-0b1471295c55": {
      "main": [
        [
          {
            "node": "3cc458c3-ff28-4d34-9e40-769fa229f8ff",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "d9b3cdf6-096d-426a-811b-9b35fa15f759": {
      "main": [
        [
          {
            "node": "969d9b61-fcab-4907-b670-ef12da530051",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "dbc396b9-d19a-4f7a-a26a-77b60d3cc9bc": {
      "main": [
        [
          {
            "node": "ca71edf8-19e8-4f9f-acbb-506a1bcb0240",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "3cc458c3-ff28-4d34-9e40-769fa229f8ff": {
      "main": [
        [
          {
            "node": "dbc396b9-d19a-4f7a-a26a-77b60d3cc9bc",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Foire aux questions

Comment utiliser ce workflow ?

Copiez le code de configuration JSON ci-dessus, créez un nouveau workflow dans votre instance n8n et sélectionnez "Importer depuis le JSON", collez la configuration et modifiez les paramètres d'authentification selon vos besoins.

Dans quelles scénarios ce workflow est-il adapté ?

Avancé - Extraction de documents, IA Multimodale

Est-ce payant ?

Ce workflow est entièrement gratuit et peut être utilisé directement. Veuillez noter que les services tiers utilisés dans le workflow (comme l'API OpenAI) peuvent nécessiter un paiement de votre part.

Informations sur le workflow
Niveau de difficulté
Avancé
Nombre de nœuds16
Catégorie2
Types de nœuds6
Description de la difficulté

Adapté aux utilisateurs avancés, avec des workflows complexes contenant 16+ nœuds

Liens externes
Voir sur n8n.io

Partager ce workflow

Catégories

Catégories: 34