Extract tracking numbers from Gmail PDF attachments to Google Sheets with okraPDF

Quick Overview This workflow monitors unread Gmail messages with PDF attachments, sends the first PDF to okraPDF for OCR parsing, then extracts likely tracking numbers from the OCR text and appends the email and parse details as a new row in Google Sheets.

How it works Triggers every minute when an unread Gmail email arrives that has a PDF attachment, and downloads attachments to the workflow. Checks that the first downloaded attachment (attachment_0) is a PDF before continuing. Uploads the PDF to okraPDF and starts an OCR parse job with the configured parser and page settings. Waits briefly, then polls okraPDF for the job status until it reaches a terminal state. Extracts tracking-number candidates from the OCR text using a regex and appends a row to Google Sheets with email metadata, parse status, IDs, a text preview, and the raw result JSON.

Setup Create and connect Gmail OAuth2 credentials with permission to read email and download attachments. Create and connect an okraPDF API key using HTTP Header Auth, and ensure your okraPDF account can access the /v1/files, /v1/parse, and job status endpoints. Create and connect Google Sheets OAuth2 credentials, then select the target spreadsheet and sheet (document ID and sheet name) where rows should be appended. Ensure your destination sheet has columns that match the mapped fields (for example: From, Subject, Attachment, Received At, Tracking Numbers, Status, Job ID, and Text Preview), and adjust the page count/parser values if needed.

0
Downloads
2
Views
7.54
Quality Score
beginner
Complexity
Author:stevent(View Original →)
Created:6/25/2026
Updated:6/25/2026

🔒 Please log in to import templates to n8n and favorite templates

Workflow Visualization

Loading...

Preparing workflow renderer

Comments (0)

Login to post comments