Templates / Classify Gmail enquiries with GPT‑4o‑mini and log them to Google Sheets

Classify Gmail enquiries with GPT‑4o‑mini and log them to Google Sheets

Ready for 3.0

by TERA · 4 views · created 2026-08-04 · Ticket Management, AI Summarization

Ready for 3.0. This template uses no nodes that n8n 3.0 removes. No removed nodes, versions or helpers found. Static check, last run 2026-10-19.

Worth a look

Nodes used (5)

GmailGoogle Sheets

What it does

Quick overview This workflow polls a Gmail inbox, filters out auto-replies and bounce emails, classifies real enquiries with an OpenAI-compatible chat model, validates and sanitizes the AI output, and appends each enquiry as a structured row in Google Sheets. How it works 1. Triggers every 15 minutes and fetches emails from Gmail regardless of read status. 2. Filters out common machine-generated messages (such as out-of-office replies and delivery failures) and normalizes sender, reply-to, subject, body, and a short excerpt. 3. Sends the email content to the OpenAI Chat Completions API to generate a JSON classification (category, priority, sentiment, language, summary, and recommended action). 4. Validates the AI JSON against allowed values, escalates to high priority and records substituted fields when output is missing or out of range, and sanitizes text to prevent Google Sheets formula injection. 5. Appends one row per enquiry to a Google Sheets spreadsheet with the received time, sender details, AI classification, and excerpt. Setup 1. Connect your Gmail account credential and confirm the polling interval and search query settings in the Gmail trigger. 2. Add an OpenAI API credential (or compatible provider) and ensure the model name in the Settings step matches a model available to your account. 3. Connect your Google Sheets credential, select the target spreadsheet and sheet, and create the header row with the required columns in the expected order before mapping fields.

View the original on n8n.io → Check your own copy

Get the weekly “what broke” email

New templates, newly broken ones, and n8n release changes. One short email a week.

Form not loading? Subscribe here.