Starbase / 02 RecipeAgents

RecipeAgents / Recipes / Personal admin

Personal admin recipe

Order emails to a Google Sheet with Gemini

Order confirmations pile up in Gmail, and when you need a return date or an order number you're searching again. This sends each order email to Gemini 3.5 Flash-Lite, which has a free tier in the Gemini API, and logs shop, order number, total, items and return date as one row in a Google Sheet.

InputOrder and receipt emails in Gmail
ToolsGmail, n8n (or Zapier or Make), Google Gemini API (Gemini 3.5 Flash-Lite), Google Sheets
TimeSetup about 30 minutes (our estimate).
CostGemini 3.5 Flash-Lite has a free tier. On the paid tier it costs $0.30 per million input tokens and $2.50 per million output tokens (Google's pricing page, last updated 2026-10-22, read 2026-10-24). Our arithmetic: 200 order emails a month at about 3,000 tokens each is 600,000 input tokens, roughly $0.18 on the paid tier, plus a little for the short JSON replies.

Download it

The n8n file has four nodes (Gmail trigger, Gemini, a Code node that parses the JSON, Google Sheets) plus a read-me note. We check that its JSON structure is valid, but we haven't run every file in a live n8n instance, so test it with sample data before you switch it on. All 23 files, the logins each needs and how to fix common import errors are on our n8n templates page.

Steps

  1. Create an API key in Google AI Studio (aistudio.google.com/apikey). In n8n, add a Google Gemini(PaLM) API credential with that key; the host stays https://generativelanguage.googleapis.com.
  2. Make a Google Sheet with these headers in row 1: logged_at, order_date, shop, order_number, currency, total, items, delivery_estimate, return_by, from, subject, gmail_id, parse_error.
  3. Trigger: Gmail Trigger, polling every hour, search subject:(order OR receipt OR confirmation) -category:promotions, with Simplify turned off so the full email text comes through.
  4. Google Gemini node, version 1.1: Text → Message a Model, model ID models/gemini-3.5-flash-lite. Paste the prompt below, turn on Output Content as JSON, and under Options turn on Include Merged Response. Don't add Maximum Number of Tokens.
  5. Code node (in our file): parses the JSON, drops emails the model marked as not an order, and adds the sender, subject and Gmail ID so every row can be traced back to its email.
  6. Google Sheets → Append Row, mapping column data automatically, pointed at your sheet.
  7. Run it on a few old receipts first and compare each row with the email before you leave it running.

The prompt

Read this email. If it is not an order confirmation or a purchase receipt (for example a newsletter, an ad, or a shipping update), return {"is_order": false}. Otherwise return JSON: {"is_order": true, "shop", "order_number", "order_date" (YYYY-MM-DD), "currency" (3-letter code), "total" (number, exactly as printed), "items" (list of short names), "delivery_estimate", "return_by" (YYYY-MM-DD)}. Use null for anything the email doesn't state. Never calculate a total or a return date yourself. Return only the JSON. From: {{from}} Subject: {{subject}} Email: {{text}}

Sample run

Example input (written for illustration)
From: Paper Lantern Books <orders@paperlantern.example>
Subject: Your order PL-48213 is confirmed
Thanks for your order, placed 14 Oct 2026. Items: Winter Harbour Notes (paperback), A Small Guide to Moss (paperback). Total paid: €36.90 incl. VAT. Estimated delivery: 17–19 Oct.
Example output (shows the format, not a real log)
{"is_order": true, "shop": "Paper Lantern Books", "order_number": "PL-48213", "order_date": "2026-10-14", "currency": "EUR", "total": 36.90, "items": ["Winter Harbour Notes", "A Small Guide to Moss"], "delivery_estimate": "17–19 Oct", "return_by": null}
SPONSOR SLOT · AVAILABLEFeature your product here

Where it breaks

  • Free tier means Google can use the emails. Google's pricing page says content sent on the free tier is used to improve Google's products, and paid-tier content isn't. Receipts carry your address and what you bought. If that matters to you, link billing to the project; at the volumes in the worked example the cost is well under a dollar a month.
  • 429 RESOURCE_EXHAUSTED. Free-tier limits apply per Google Cloud project, not per API key, and your exact numbers are shown only in AI Studio. Daily request quotas reset at midnight Pacific time. If a backlog of old emails trips the limit, turn on Retry On Fail in the Gemini node's settings with a wait between tries, or let the backlog run over a few days.
  • The node picks a preview model. Version 1.2 of n8n's Gemini node preselects a preview model (gemini-3-flash-preview in the n8n source we read on 2026-10-24), and Google's rate-limits page says limits are more restricted for preview models. Our file pins node version 1.1 and the stable models/gemini-3.5-flash-lite.
  • Answers cut off after a few words. If you add Maximum Number of Tokens under the node's Options, n8n starts it at 16, which breaks the JSON. Remove the option or set it to 1,000 or more. The Code node logs anything it can't parse in the parse_error column instead of dropping it.
  • Old tutorials use gemini-2.5-flash. Google's models page says the Gemini 2.5 models are limited to users who used them before, so a new key can't call them. Use Gemini 3.5 Flash-Lite, or 3.8 Flash if you need more reasoning: it has a free tier too, and on the paid tier costs $0.75/$3.75 per million tokens until Dec 31, 2026, then $1.50/$7.50.
  • Shipping updates and duplicates. “Your order has shipped” emails match the search too. The prompt tells the model to skip them, but some will slip through, so sort the sheet by order_number now and then and delete repeats.
  • Totals and return dates. The prompt asks for the total exactly as printed and never a calculated return date, so return_by is often empty: many shops only link to a returns policy. Check the first 20 rows against the emails before you rely on the sheet.
  • Anything customer-facing or money-related. Keep a human approval step until you've watched a few dozen runs and trust it.

Use Claude or ChatGPT instead

The Code node in our file reads the answer from Gemini (mergedResponse), Anthropic (merged_response) or OpenAI (message.content), so to switch models you replace only the Gemini node.

  • Claude in n8n: Anthropic → Text → Message a Model, model claude-haiku-5-5, Include Merged Response on, Maximum Number of Tokens about 1,000 (the node sends 1,024 if unset, which is enough here). The Anthropic node has no JSON switch, so the prompt's “Return only the JSON” line does that job. Haiku 5.5 costs $0.10 per million input tokens and $0.50 per million output tokens for prompts up to 100k tokens (Anthropic pricing, read 2026-10-24). There's no ongoing free tier.
  • ChatGPT in n8n: OpenAI → Message a Model with Output Content as JSON, as in our other files. Check OpenAI's pricing page for the current rate.
  • Zapier: Gmail (New Email Matching Search) → Google AI Studio (Gemini): Send Prompt → Formatter or Code by Zapier to split the JSON → Google Sheets (Create Spreadsheet Row). Swap in Anthropic (Claude): Send Message for Claude.
  • Make: Gmail (Watch emails) → Google Gemini AI: Extract structured data, with the fields from the prompt → Google Sheets (Add a row). Make's Gemini app needs a Google Cloud project, and on Make's free plan its simple prompt offers only Gemini 2.5 Flash (Make docs, read 2026-10-24).

Tool names and pricing change often, so check each tool's current docs before you build. Times on this page are estimates, not measurements.

More personal admin recipes

All collections · Full inbox-triage walkthrough

New to building agents? Plan this one first with the free agent planner on PlainAgent, our sister site with plain-English guides. Not sure which AI model to use? See the writing and chat assistant ranking on TaskRank.

Newsletter

One small automation every Friday

Each Friday email has one recipe, the prompt for it, and the way it broke when we wrote it up. It's free, and every email has an unsubscribe link.