N8N + GEMINI EMAIL AUTOMATION — STARTER
Author: Harpal Singh / SimplifyAITools
Prepared: 19 October 2026

WHAT THIS DOWNLOAD IS
A starter template created from current official documentation and node source. Local JavaScript logic and graph checks passed. It has NOT been imported into an n8n runtime or tested end to end with Gmail, Google Sheets or Gemini. Do not describe it as a live-tested production workflow.

FILES
n8n-gemini-email-approval-starter.json — main workflow, inactive
n8n-email-error-alert.json — error notification workflow, inactive
EmailLog-headers.csv — import as the first row of an EmailLog tab
classifier-prompt.txt and classifier-schema.json — editable AI prompt and schema
workflow-logic.cjs and test-workflow-logic.cjs — readable logic and local tests
validation-results.txt — test output and scope

SETUP
1. Create a Google Sheet with the tab name EmailLog; import the CSV headers.
2. Import the main workflow into a current n8n release. If a node version is unavailable, update n8n or recreate that node with the documented settings. Do not assume static JSON checks prove import compatibility.
3. Connect Gmail credentials in Get Full Email, Request Human Approval, Send Approved Reply and the disabled Gmail Trigger.
4. Connect Google Sheets credentials in every Sheets node. Confirm document ID and EmailLog tab after filling Configuration. Refresh the column list if your editor requires it.
5. Connect a Gemini credential and select an available text model. The supplied model name is models/gemini-3.5-flash-lite.
6. In Configuration, fill mailboxEmail, reviewerEmail, sheetId and testMessageId. Keep enableReply=false. Values are deliberately blank and no credentials are embedded.
7. Find a Gmail API message ID with Gmail Get Many and a search for one unique harmless test subject. Copy its id, not the RFC Message-ID header.
8. Run Manual Test. Approve the internal review request. Expect approved_dry_run and no customer reply. The internal review request itself is still sent during dry runs.
9. Test decline, timeout, duplicate, manual-review, no-reply and failed-node outcomes. Use fresh test messages because existing keys are skipped.
10. Use only your own harmless test sender when setting enableReply=true for a live reply test. Verify one reply in the original thread and the saved Gmail reply ID. This real-account test is required; it has not been performed for you.
11. Import the error-alert workflow, configure its fixed reviewerEmail and Gmail credential, and choose it under the main workflow's Settings > Error Workflow. Error Trigger handles automatic execution failures; inspect manual failures in Executions.
12. Create a Gmail label AI-Test. Enable the previously disabled Gmail Trigger, then publish/activate the main workflow. Test new labelled incoming messages before changing the filter. Read status is both; deduplication relies on the recorded key, not unread state alone.

DESIGN LIMITS
- This is a controlled, low-volume starter. One email is processed per loop iteration; waiting for approval holds later messages in that batch.
- A Sheets lookup plus append is not atomic. Overlapping runs can race. Use a database unique key, atomic message claims and a single-use send state before concurrent production deployment.
- All existing message keys are skipped, even rejected, failed or unfinished ones. Recovery is deliberate and manual.
- Before sending, status becomes sending. A timeout or failed final log may leave this status even when Gmail already accepted the reply. Inspect Sent and the thread before retrying. Never blindly delete a sending/sent key.
- The model cannot choose recipients, message IDs or workflow actions. Approval sends the exact saved reply, not a new generation.
- Manual queue includes billing, other, different Reply-To addresses and the model's manual-review flag. Newsletters, spam and recognised automated messages are not replied to by this starter.
- No attachments, HTML-only fallback, thread-history analysis or edited-reply form. Missing plain text and bodies over 12,000 characters stop for manual inspection.
- The approver should inspect the current thread before approving; this starter has no automatic stale-thread check.
- Approval links are signed actions, not authenticated reviewer identity. Keep them private. Use authenticated approval for stronger controls.
- n8n error alerts depend on n8n and Gmail still being available. This is not an independent outage monitor.
- Email text is sent to Gemini. Review service terms, billing status, access controls and execution-data retention before using real mail.

RUN LOCAL CHECKS
With Node.js installed, run: node test-workflow-logic.cjs
The tests make no network calls and send no messages.
