n8n

How to Automate Gmail to Sheets Invoice Processing?

Receive documents from Gmail or a webhook, extract the text, and turn it into useful data for finance work. The setup suits teams that handle invoices and reports by email and need quick summaries, structured fields, and instant alerts.

A Gmail trigger watches for emails with attachments and pulls only the latest messages. The flow downloads the first attachment, checks if the file type is supported, and uploads it to LlamaIndex for parsing with a callback webhook. When the parsed text arrives, the system classifies the document, builds a clear summary, and saves files to Google Drive. It writes the LlamaParse job ID and summary to Google Sheets, then extracts invoice fields as JSON and updates the row by job ID. Telegram sends a concise message with totals and dates, and error paths notify if parsing fails or the file type is not allowed.

Connect Gmail, Google Drive, Google Sheets, LlamaIndex, OpenAI, and Telegram. Set your public webhook URL, choose Drive folders, and create a sheet with jobid, summary, and any invoice fields you track. Expect faster approvals and fewer errors, with time saved on manual data entry. Common uses include accounts payable intake, invoice triage, and simple document summaries for quick review.

What are the key features?

  • Gmail Trigger monitors new emails with attachments and limits to the latest messages
  • File type validation checks supported extensions before processing
  • LlamaIndex upload with a webhook callback to return parsed text
  • Document classification and concise summaries using OpenAI
  • Invoice field extraction to JSON including dates, totals, and line items
  • Google Drive storage for original, parsed, and summarized files
  • Google Sheets append or update using the LlamaParse job ID key
  • Telegram alerts for invoice details and error notifications on failures

What are the benefits?

  • Reduce manual invoice entry from 30 minutes to 3 minutes per document
  • Automate up to 80 percent of invoice capture and logging
  • Improve data accuracy by 70 percent with structured JSON fields
  • Handle 5 to 10 times more documents each week without extra staff
  • Connect Gmail, LlamaIndex, Google Drive, Google Sheets, and Telegram in one flow
  • Shorten approval time with instant Telegram summaries and totals

How do you set it up?

  1. Import the template into n8n: Create a new workflow in n8n > Click the three dots menu > Select 'Import from File' > Choose the downloaded JSON file.
  2. You'll need accounts with Gmail, Google Drive, Google Sheets, LlamaIndex, OpenAI and Telegram. See the Tools Required section above for links to create accounts with these services.
  3. Open the Gmail Trigger node, click Credential to connect with, select Create new credential, and follow the on screen steps to sign in to your Gmail account. Keep the poll interval as needed.
  4. Open the Gmail Get All and Get Message nodes. Set the search query to has:attachment and adjust sender or from filters if you want to limit sources. Ensure download attachments is enabled.
  5. Check the Limit node so only the most recent messages are processed. Keep the first attachment rule in mind for your tests.
  6. Open the HTTP Request node that retrieves supported file extensions from LlamaIndex. Leave the default URL and method, as it is preconfigured to fetch the list.
  7. Open the Parse Document with LlamaParse node. In the credential dropdown, Create new credential and choose HTTP Header Auth. In your LlamaIndex account, create an API key, then add an Authorization header with value Bearer YOUR_API_KEY. Set the webhook_url field to your public n8n webhook URL from the Webhook node labeled parse.
  8. Open the Webhook node and copy the Production URL. Make sure your n8n instance URL is public so LlamaIndex can send the callback.
  9. Open the Google Drive nodes. Select or create folders for original files, parsed outputs, and summarized documents. Test by saving a sample file to confirm the connection.
  10. Open the Google Sheets nodes. Create a sheet with columns like jobid, summary, image_url and any invoice fields you plan to track. Map jobid to the LlamaParse job ID and set the operation to append or update.
  11. Open each OpenAI node, click Credential to connect with, and Create new credential. Enter your OpenAI API key from your OpenAI account. Keep the default gpt 4o mini model unless you need a change.
  12. Open the Telegram nodes. Create a bot with BotFather, copy the bot token, and add it as a new Telegram credential. Set the chat ID to your chosen channel or user and send a test message.
  13. Run a full test: email a PDF invoice to the monitored inbox. Confirm Drive contains the original and parsed files, Sheets shows the jobid and summary, and Telegram posts the invoice details.
  14. Troubleshoot issues: if no callback arrives, verify the webhook URL is reachable and correct in the LlamaIndex node. If Sheets is not updating, check the jobid mapping. If Telegram is silent, confirm the bot is added to the chat and the chat ID is correct.

Tools Required

$24 / mo or $20 / mo billed annually to use n8n in the cloud. However, the local or self-hosted n8n Community Edition is free.

Gmail

Sign up

No cost: Personal Gmail (Gmail API has no usage-based pricing; quotas apply)

Google Drive

Sign up

Drive API: $0 (no additional cost; quota-limited)

Google Sheets

Sign up

Free: $0 (Google Sheets API usage has no additional cost; quota limits apply)

LlamaIndex

Sign up

Free: $0 / mo, includes 10,000 credits; API key available

OpenAI

Sign up

Pay-as-you-go: GPT-5 at $1.25 per 1M input tokens and $10 per 1M output tokens

Telegram

Sign up

Free: $0, Telegram Bot API usage is free for developers

Similar Templates

Join Futurise to access 1,200+ automation templates

Get instant access to ready-made automation workflows for n8n, Make.com, AI agents, and more. Download, customise, and deploy in minutes.