Quick overview
This workflow monitors Gmail for PDF attachments, uploads them to Google Drive, extracts invoice text from PDFs, uses Google Gemini to detect and parse Turkish invoice fields into structured data, and logs both invoice headers and line items into Google Sheets.
How it works
- Runs every hour and triggers on new Gmail messages that contain PDF attachments.
- Splits the email’s attachments into individual items and loops through each PDF.
- Uploads each PDF to a specified Google Drive folder, then downloads it and extracts text from the PDF.
- Uses Google Gemini to decide whether the extracted text is an invoice.
- If it is not an invoice, deletes the uploaded file from Google Drive.
- If it is an invoice, uses Google Gemini with a structured JSON schema to extract invoice details and line items from the PDF text.
- Appends the invoice header fields to a Google Sheets “Faturalar” sheet and appends each invoice line item to a “Kalem Detay” sheet.
Setup
- Connect your Gmail OAuth2 account and ensure the Gmail query filter (filename:pdf has:attachment) matches the emails you want to process.
- Connect your Google Drive OAuth2 account and set the target Drive folder ID where PDFs are uploaded.
- Add a Google Gemini (Google PaLM) API credential for the two Gemini chat model nodes.
- Connect your Google Sheets OAuth2 account and update the spreadsheet ID and sheet tabs/columns for both the invoice header (“Faturalar”) and line item (“Kalem Detay”) sheets.