AutomationFlowsAI & RAG › Extract & Store Receipt Data with Gpt-4, Ocr, Google Sheets & Notion via…

Extract & Store Receipt Data with Gpt-4, Ocr, Google Sheets & Notion via…

Original n8n title: Extract & Store Receipt Data with Gpt-4, Ocr, Google Sheets & Notion via Telegram Bot

ByTegar karunia ilham @tegarkaruniailham on n8n.io

Transform your receipt management with this comprehensive n8n workflow that automatically processes receipts through Telegram, extracts transaction data using AI, and stores it across multiple platforms for seamless expense tracking. 📱 Telegram Bot Integration: Send receipts via…

Event trigger★★★★☆ complexityAI-powered14 nodesTelegram TriggerTelegramHTTP RequestOpenAIGoogle SheetsGoogle DriveNotion
AI & RAG Trigger: Event Nodes: 14 Complexity: ★★★★☆ AI nodes: yes Added:

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

This workflow follows the Google Drive → Google Sheets 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": "YGDpr1ZwlWwPwpsD",
  "name": "AI-Powered Receipt Tracker with Multi-Platform Storage via Telegram Bot",
  "tags": [],
  "nodes": [
    {
      "id": "1ab8188b-b92f-4e84-9d49-1baf01e999cc",
      "name": "Telegram Bot Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -512,
        160
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "50cecf34-87c8-4fa6-9599-30f656a4b593",
      "name": "Message Type Router",
      "type": "n8n-nodes-base.switch",
      "position": [
        -272,
        160
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "exists"
                    },
                    "leftValue": "={{ $json.message.photo }}",
                    "rightValue": ""
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "exists"
                    },
                    "leftValue": "={{ $json.message.text }}",
                    "rightValue": ""
                  }
                ]
              }
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "32cc964e-d4b2-4072-b3d2-3d41c3f2925f",
      "name": "Download Telegram Image",
      "type": "n8n-nodes-base.telegram",
      "position": [
        0,
        0
      ],
      "parameters": {
        "fileId": "={{ $json.message.photo[$json.message.photo.length - 1].file_id }}",
        "resource": "file",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "e4c88939-58a3-4dea-b754-d6e542edd530",
      "name": "OCR Receipt Processing",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        176,
        80
      ],
      "parameters": {
        "url": "https://api.ocr.space/parse/image",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "url",
              "value": "https://api.telegram.org/file/bot{{ $credentials.telegramApi.accessToken }}/{{ $('Download Telegram Image').item.json.file_path }}"
            },
            {
              "name": "language",
              "value": "eng"
            },
            {
              "name": "detectOrientation",
              "value": "true"
            },
            {
              "name": "isTable",
              "value": "true"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "apikey",
              "value": "={{ $credentials.ocrSpaceApi.apiKey }}"
            }
          ]
        }
      },
      "credentials": {
        "ocrSpaceApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "3ae3a207-260f-440f-a06d-956aeb675244",
      "name": "Handle Text Message",
      "type": "n8n-nodes-base.function",
      "position": [
        0,
        272
      ],
      "parameters": {
        "functionCode": "// Handle text messages - could be manual transaction entry\nconst text = $input.first().json.message.text;\n\n// Simple text parsing for manual entries like: \"McDonald's $12.50 lunch food\"\nconst parts = text.split(' ');\nif (parts.length >= 3) {\n  const vendor = parts[0];\n  const amountMatch = text.match(/\\$?([0-9]+\\.?[0-9]*)/); \n  const amount = amountMatch ? parseFloat(amountMatch[1]) : 0;\n\n  return {\n    json: {\n      ParsedResults: [{\n        ParsedText: `Vendor: ${vendor}\\nAmount: $${amount}\\nDate: ${new Date().toISOString().split('T')[0]}\\nType: purchase`\n      }]\n    }\n  };\n} else {\n  throw new Error('Invalid text format. Use: \"Vendor $amount description\"');\n}"
      },
      "typeVersion": 1
    },
    {
      "id": "0d04b8c2-27c7-45a4-9175-43705b0bf9cd",
      "name": "AI Purchase Data Extractor",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        320,
        208
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4"
        },
        "options": {
          "maxTokens": 500,
          "temperature": 0.1
        },
        "messages": {
          "values": [
            {
              "role": "user",
              "content": "You are an expert receipt and transaction data extractor. Extract transaction data from the provided text and return ONLY a JSON object with these exact fields:\n\n{\n  \"vendor\": \"vendor/store name\",\n  \"amount\": \"numeric amount (without currency symbol)\",\n  \"currency\": \"USD\",\n  \"date\": \"YYYY-MM-DD format\",\n  \"transaction_type\": \"purchase/refund/payment\",\n  \"category\": \"food/shopping/transport/entertainment/other\"\n}\n\nInput text: {{ $json.ParsedResults[0].ParsedText || $json.message.text }}\n\nReturn only the JSON object, no additional text or explanation."
            }
          ]
        }
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "ff76dcfc-40d3-469b-9308-7dec5dcfe4a2",
      "name": "Transaction Data Validator",
      "type": "n8n-nodes-base.function",
      "position": [
        608,
        176
      ],
      "parameters": {
        "functionCode": "try {\n  // Parse AI response\n  let aiResponse = $input.first().json.content || $input.first().json.response || $input.first().json;\n\n  // Handle if response is string\n  if (typeof aiResponse === 'string') {\n    // Try to extract JSON from string response\n    const jsonMatch = aiResponse.match(/\\{[\\s\\S]*\\}/);\n    if (jsonMatch) {\n      aiResponse = jsonMatch[0];\n    }\n    aiResponse = JSON.parse(aiResponse);\n  }\n\n  // Validate required fields\n  const requiredFields = ['vendor', 'amount', 'date', 'transaction_type'];\n  const missingFields = requiredFields.filter(field => !aiResponse[field]);\n\n  if (missingFields.length > 0) {\n    throw new Error(`Missing required fields: ${missingFields.join(', ')}`);\n  }\n\n  // Generate UUID alternative\n  const generateId = () => {\n    return 'txn_' + Math.random().toString(36).substring(2) + Date.now().toString(36);\n  };\n\n  // Standardize and clean data\n  const transaction = {\n    id: generateId(),\n    vendor: String(aiResponse.vendor).trim(),\n    amount: parseFloat(aiResponse.amount),\n    currency: aiResponse.currency || 'USD',\n    date: aiResponse.date,\n    transaction_type: aiResponse.transaction_type,\n    category: aiResponse.category || 'uncategorized',\n    processed_date: new Date().toISOString(),\n    user_id: $('Telegram Bot Trigger').item.json.message.from.id,\n    username: $('Telegram Bot Trigger').item.json.message.from.username || 'unknown'\n  };\n\n  // Validate amount is a valid number\n  if (isNaN(transaction.amount) || transaction.amount <= 0) {\n    throw new Error('Invalid amount detected');\n  }\n\n  // Validate date format\n  if (!transaction.date.match(/^\\d{4}-\\d{2}-\\d{2}$/)) {\n    transaction.date = new Date().toISOString().split('T')[0];\n  }\n\n  return { json: transaction };\n\n} catch (error) {\n  // Pass error info for error handler\n  return {\n    json: {\n      error: true,\n      message: error.message,\n      user_id: $('Telegram Bot Trigger').item.json.message.from.id,\n      original_data: $input.first().json\n    }\n  };\n}"
      },
      "typeVersion": 1
    },
    {
      "id": "7c57c8da-7156-48d2-936c-33f33c31f797",
      "name": "Check for Errors",
      "type": "n8n-nodes-base.switch",
      "position": [
        800,
        176
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "boolean",
                      "operation": "true"
                    },
                    "leftValue": "={{ $json.error }}",
                    "rightValue": ""
                  }
                ]
              }
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "06af3c07-0613-4990-95ae-2395aeda7725",
      "name": "Send Error Message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        960,
        176
      ],
      "parameters": {
        "text": "\u274c Error processing your receipt:\\n\\n{{ $json.message }}\\n\\nPlease try again or send a clearer image of your receipt.\\n\\nFor text input, use format: \"Vendor $amount description\"",
        "chatId": "={{ $json.user_id }}",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "9fb86db3-19dd-4dab-9309-69151fffd0d1",
      "name": "Record to Database",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1184,
        96
      ],
      "parameters": {
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "Transactions"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_GOOGLE_SHEET_ID_HERE"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "181ea179-c278-422a-934e-4d5ec899ba3f",
      "name": "Store Receipt Image",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1184,
        -32
      ],
      "parameters": {
        "name": "receipt_{{ $json.id }}_{{ $json.date }}.jpg",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "root"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "4249d4f3-e394-4d03-9ee9-d608ba94082f",
      "name": "Save to Notion Database",
      "type": "n8n-nodes-base.notion",
      "position": [
        1184,
        240
      ],
      "parameters": {
        "options": {},
        "resource": "databasePage",
        "databaseId": "YOUR_NOTION_DATABASE_ID_HERE"
      },
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "96f32d63-a79b-4154-a223-76d00336f76e",
      "name": "Send to Website API",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1248,
        384
      ],
      "parameters": {
        "url": "https://yourwebsite.com/api/transactions",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {}
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "Authorization",
              "value": "Bearer YOUR_TOKEN_HERE"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "c4e931b6-5988-4cd4-ae38-48650d523213",
      "name": "Send Confirmation",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1424,
        176
      ],
      "parameters": {
        "text": "\u2705 Transaction Recorded Successfully!\\n\\n\ud83d\udcca Details:\\n\u2022 Vendor: {{ $json.vendor }}\\n\u2022 Amount: {{ $json.currency || 'USD' }} {{ $json.amount }}\\n\u2022 Type: {{ $json.transaction_type }}\\n\u2022 Category: {{ $json.category }}\\n\u2022 Date: {{ $json.date }}\\n\u2022 ID: {{ $json.id }}\\n\\n\ud83d\udcbe Receipt stored and data recorded in all systems.",
        "chatId": "={{ $json.user_id }}",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "1d2c44d6-1f06-4c6e-a25d-87c7d8c5e894",
  "connections": {
    "Check for Errors": {
      "main": [
        [
          {
            "node": "Send Error Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Record to Database": {
      "main": [
        [
          {
            "node": "Send Confirmation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Error Message": {
      "main": [
        [
          {
            "node": "Save to Notion Database",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send to Website API",
            "type": "main",
            "index": 0
          },
          {
            "node": "Record to Database",
            "type": "main",
            "index": 0
          },
          {
            "node": "Store Receipt Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Handle Text Message": {
      "main": [
        [
          {
            "node": "AI Purchase Data Extractor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Message Type Router": {
      "main": [
        [
          {
            "node": "Download Telegram Image",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Handle Text Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send to Website API": {
      "main": [
        [
          {
            "node": "Send Confirmation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Store Receipt Image": {
      "main": [
        [
          {
            "node": "Send Confirmation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Bot Trigger": {
      "main": [
        [
          {
            "node": "Message Type Router",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OCR Receipt Processing": {
      "main": [
        [
          {
            "node": "AI Purchase Data Extractor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Telegram Image": {
      "main": [
        [
          {
            "node": "OCR Receipt Processing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save to Notion Database": {
      "main": [
        [
          {
            "node": "Send Confirmation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Purchase Data Extractor": {
      "main": [
        [
          {
            "node": "Transaction Data Validator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transaction Data Validator": {
      "main": [
        [
          {
            "node": "Check for Errors",
            "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

Transform your receipt management with this comprehensive n8n workflow that automatically processes receipts through Telegram, extracts transaction data using AI, and stores it across multiple platforms for seamless expense tracking. 📱 Telegram Bot Integration: Send receipts via…

Source: https://n8n.io/workflows/8279/ — 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

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

Telegram Trigger, Telegram, OpenAI +2
AI & RAG

Generate AI viral videos with NanoBanana & VEO3, shared on socials via Blotato 2. Uses @blotato/n8n-nodes-blotato, googleSheets, lmChatOpenAi, toolThink. Event-driven trigger; 94 nodes.

@Blotato/N8N Nodes Blotato, Google Sheets, OpenAI Chat +9
AI & RAG

This template is designed for marketers, content creators, and e-commerce brands who want to automate the creation of professional ad videos at scale. It’s ideal for teams looking to generate consiste

Telegram, Telegram Trigger, Google Drive +8
AI & RAG

This automation is designed to help you generate AI-powered music tracks, cover art, and fully rendered music videos — all triggered from a simple Telegram chat and managed via Google Sheets.

OpenAI Chat, Memory Buffer Window, Output Parser Structured +11
AI & RAG

Create Video Ia. Uses @blotato/n8n-nodes-blotato, googleSheets, lmChatOpenAi, toolThink. Event-driven trigger; 47 nodes.

@Blotato/N8N Nodes Blotato, Google Sheets, OpenAI Chat +8