AI Invoice Data Extraction from Telegram to Airtable - n8n Workflow

Use this powerful n8n workflow to automate invoice data extraction from PDFs sent via Telegram. It leverages OpenAI's GPT-4o and logs structured data into Airtable. Explore more n8n templates.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

• Accountants and finance teams needing to streamline invoice processing.
• Users who require immediate, mobile-friendly data capture from documents.
• Automation specialists looking for advanced examples of conversational AI using the n8n agent framework.
• Businesses utilizing Airtable as a robust backend for tracking financial documents.

Overview

Manual entry of invoice data is time-consuming and prone to errors. This robust n8n workflow solves this problem by creating an intelligent, conversational Telegram bot that automates data capture from documents. Upon receiving a PDF invoice via Telegram, this specific n8n workflow takes over. It employs advanced text extraction techniques combined with a powerful OpenAI GPT-4o model to parse complex financial documents, identifying key fields like supplier details, tax amounts, and detailed line items. All extracted information is meticulously logged into two linked tables in Airtable—one for the main invoice record and one for associated line items. This seamless integration showcases how effective n8n templates can be for achieving high-accuracy, low-friction financial process automation.

How it Works

The process begins with the Telegram Trigger1 n8n trigger node, which activates upon receiving a message, ideally containing a PDF file. The Switch1 n8n node immediately filters the incoming data, ensuring only PDF files are processed. If a PDF is detected, the Telegram2 n8n node downloads the file, and the Extract from File1 n8n node performs OCR or text extraction on the PDF content. This extracted text, along with the chat context, is prepared by the Edit Fields1 n8n node for input into the core logic engine: the AI Agent1 n8n node. This agent, powered by the OpenAI Chat Model (GPT-4o) and maintaining context using the Simple Memory n8n node (keyed by chat ID), orchestrates the data logging. It first calls the Create Invoice1 tool to create the header record in Airtable, capturing fields like Invoice Number and Total Amount. Using the resulting record ID, it then calls the Create Line Item1 tool multiple times to log every individual line item, ensuring they are correctly linked to the parent invoice. Once all data is successfully logged in Airtable, the Telegram3 n8n node sends a final confirmation message back to the user, completing the fully automated n8n workflow.

Installation Guide

Installation and Setup


  1. Import the n8n Workflow: Copy the provided JSON and import it directly into your n8n instance.

  2. Credentials Setup:

Telegram: Set up a Telegram Bot credential using your Bot Token. The Telegram Trigger requires setting up a webhook via n8n.
OpenAI: Configure an OpenAI credential using an API key that has access to the GPT-4o model.
* Airtable: Configure an Airtable credential. You will need a Personal Access Token with read/write permissions for the target base.

  1. Airtable Configuration: The workflow is preset for specific Base and Table IDs (Invoice Tracker Proper). You must update the configurations in both the Create Invoice1 n8n node and the Create Line Item1 n8n node to match your actual Airtable Base ID, 'Invoices' Table ID, and 'Line Items' Table ID.

  2. Activation: Ensure the n8n workflow is active. Start a conversation with your Telegram bot and follow the prompts to test the extraction process.

Node Details

Telegram Trigger1 (n8n trigger): Initiates the n8n workflow upon receiving a message or update in the configured Telegram chat. It captures initial user messages and file attachments.
Switch1 (n8n node): Acts as a conditional router. It checks the MIME type of the incoming document, only proceeding along the main path if the document is application/pdf.
Telegram2 (n8n node): Downloads the file content (the PDF document) using the fileId provided by the Telegram trigger.
Extract from File1 (n8n node): Processes the binary PDF file downloaded in the previous step, extracting all readable text content for AI processing.
Edit Fields1 (n8n node): Prepares the data payload for the AI agent, combining the extracted text content and user messages into a single Message field and deriving the chat ID for memory.
OpenAI Chat Model (n8n node): Configured as the language model component for the AI Agent, utilizing the highly capable gpt-4o model.
Simple Memory (n8n node): Stores conversation history using the Telegram chat ID as the session key, allowing the AI Agent to remember previous inputs (like the client name).
AI Agent1 (n8n node): The core intelligence. It uses a structured prompt to guide the AI to first extract header data and then line item data, making sequential calls to the connected Airtable tools.
Create Invoice1 (Airtable n8n node): An AI tool used to create the parent record in the 'Invoices' table, mapping AI-extracted fields like Total Amount, Invoice Number, and Supplier.
Create Line Item1 (Airtable n8n node): An AI tool used iteratively to create linked records in the 'Line Items' table for every product or service line item detected in the invoice text. Crucially, it links these records back to the parent invoice ID using the required Airtable array format.


  • Telegram3 (n8n node): Sends the final confirmation or result message generated by the AI agent back to the original Telegram chat.

Related n8n Workflows

Free

Nodes: 10 Nodes
Updated: December 26 2025
View all
Created by

We are an automation company providing businesses with automations to improve productivity and save on costs. We also provide Ai solutions including Ai Voice Receptionists.

Featured*