AutomationFlowsAI & RAG › Extract Text from Images with Telegram Bot

Extract Text from Images with Telegram Bot

Original n8n title: Extract Text From Images with Telegram Bot & Gemini 2.0 Flash OCR

ByRudi Afandi @fanfanra on n8n.io

Description Turn your Telegram bot into a powerful OCR (Optical Character Recognition) tool. This workflow allows you to send any image (like a screenshot, a photo of a document, or a picture of a sign) to your bot, and it will instantly extract and send back the text from that…

Event trigger★★★★☆ complexity8 nodesTelegram TriggerTelegramHTTP Request
AI & RAG Trigger: Event Nodes: 8 Complexity: ★★★★☆ Added:

This workflow corresponds to n8n.io template #5864 — we link there as the canonical source.

This workflow follows the HTTP Request → Telegram recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "XqNsiUSOpgO7PRPD",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Image Reader Gemini OCR",
  "tags": [],
  "nodes": [
    {
      "id": "fa672106-597a-43d6-b3c8-d7d73e9ad499",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -360,
        -140
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {
          "download": true
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "552d5953-2b1e-48ff-a39b-112cae330f32",
      "name": "Clean Input Data",
      "type": "n8n-nodes-base.set",
      "position": [
        -140,
        -140
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "c8cd1608-2326-401d-9c47-79a6a72f5fc7",
              "name": "chatID",
              "type": "number",
              "value": "={{ $json.message.chat.id }}"
            },
            {
              "id": "0f1a41cb-8630-4e10-b445-f6bbbcf91d33",
              "name": "Image",
              "type": "string",
              "value": "={{ $json[\"message\"][\"photo\"][$json[\"message\"][\"photo\"].length - 1][\"file_id\"] }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "4127fe82-7700-4292-b4fc-6fc27aa9e27c",
      "name": "get file",
      "type": "n8n-nodes-base.telegram",
      "position": [
        80,
        -140
      ],
      "parameters": {
        "fileId": "={{ $json.Image.replace(/\\n/g, '') }}",
        "resource": "file"
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "cdee68db-f387-48d6-8b1c-2f1de0fbefea",
      "name": "Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        80,
        120
      ],
      "parameters": {
        "text": "={{ $json.output }}",
        "chatId": "={{ $('Clean Input Data').item.json.chatID }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "d9ef5251-9fb1-4810-aa78-4a393f4355e7",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -440,
        -200
      ],
      "parameters": {
        "color": 4,
        "width": 920,
        "height": 620,
        "content": "## Image Reader"
      },
      "typeVersion": 1
    },
    {
      "id": "ecb87468-671d-484c-9baf-01d40e6f5de6",
      "name": "Gemini OCR",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -360,
        120
      ],
      "parameters": {
        "url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"contents\": [\n    {\n      \"role\": \"user\",\n      \"parts\": [\n        {\n          \"inlineData\": {\n            \"mimeType\": \"image/jpeg\",\n            \"data\": \"{{ $json.data }}\"\n          }\n        },\n        {\n          \"text\": \"Extract text\"\n        }\n      ]\n    }\n  ]\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpQueryAuth"
      },
      "credentials": {
        "httpQueryAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "2990b76a-536e-48b4-8202-21b82ead2ef1",
      "name": "Extract from File",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        320,
        -140
      ],
      "parameters": {
        "options": {},
        "operation": "binaryToPropery"
      },
      "typeVersion": 1
    },
    {
      "id": "71b92a9e-8393-4f00-a99d-123ea4f3ed19",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -700,
        -200
      ],
      "parameters": {
        "height": 1060,
        "content": "## HTTP Gemini OCR Setting\n\nDefine Gemini Model on URL\n\nhttps://generativelanguage.googleapis.com/v1beta/models/[Gemini Model]:generateContent\n\nexample:\nhttps://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent\n\n...\n\nAuthentication\nGeneric Credential Type\n\nGeneric Auth Type\nQuery Auth\n\nQuery Auth\n+ Create new credential (take if from https://aistudio.google.com/)\n\n...\n\nBody Content Type\nJSON\n\nSpecify Body\nUsing JSON\n\nJSON\n{\n  \"contents\": [\n    {\n      \"role\": \"user\",\n      \"parts\": [\n        {\n          \"inlineData\": {\n            \"mimeType\": \"image/jpeg\",\n            \"data\": \"{{ $json.data }}\"\n          }\n        },\n        {\n          \"text\": \"Extract text\"\n        }\n      ]\n    }\n  ]\n}"
      },
      "typeVersion": 1
    }
  ],
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "c571dd01-5b7e-4ee1-88d1-d33abb86e78b",
  "connections": {
    "get file": {
      "main": [
        [
          {
            "node": "Extract from File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini OCR": {
      "main": [
        [
          {
            "node": "Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clean Input Data": {
      "main": [
        [
          {
            "node": "get file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Clean Input Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from File": {
      "main": [
        [
          {
            "node": "Gemini OCR",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Description Turn your Telegram bot into a powerful OCR (Optical Character Recognition) tool. This workflow allows you to send any image (like a screenshot, a photo of a document, or a picture of a sign) to your bot, and it will instantly extract and send back the text from that…

Source: https://n8n.io/workflows/5864/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

Receive PDF Files - Users send PDF documents via Telegram to the bot OCR Processing - Mistral AI's OCR service extracts Arabic text from document pages Text Organization - Processes and formats extrac

Telegram, Telegram Trigger, HTTP Request +1
AI & RAG

automation_financial_recording. Uses telegramTrigger, telegram, googleGemini, lmChatGoogleGemini. Event-driven trigger; 35 nodes.

Telegram Trigger, Telegram, Google Gemini +4
AI & RAG

automation_financial_recording. Uses telegramTrigger, telegram, googleGemini, lmChatGoogleGemini. Event-driven trigger; 35 nodes.

Telegram Trigger, Telegram, Google Gemini +4
AI & RAG

automation_financial_recording. Uses telegramTrigger, telegram, googleGemini, lmChatGoogleGemini. Event-driven trigger; 35 nodes.

Telegram Trigger, Telegram, Google Gemini +4
AI & RAG

Social Media Audio Extractor. Uses telegramTrigger, telegram, openAi, httpRequest. Event-driven trigger; 31 nodes.

Telegram Trigger, Telegram, OpenAI +2