From b8f49e6a722b7add8924a2d15e56c43d00e6f8d6 Mon Sep 17 00:00:00 2001 From: nusquama Date: Mon, 23 Feb 2026 12:01:53 +0800 Subject: [PATCH] creation --- .../readme-13530.md | 303 ++++++++++++++++++ 1 file changed, 303 insertions(+) create mode 100644 workflows/Verify email content against Google Sheets and Gmail logs-13530/readme-13530.md diff --git a/workflows/Verify email content against Google Sheets and Gmail logs-13530/readme-13530.md b/workflows/Verify email content against Google Sheets and Gmail logs-13530/readme-13530.md new file mode 100644 index 000000000..ee8d22570 --- /dev/null +++ b/workflows/Verify email content against Google Sheets and Gmail logs-13530/readme-13530.md @@ -0,0 +1,303 @@ +Verify email content against Google Sheets and Gmail logs + +https://n8nworkflows.xyz/workflows/verify-email-content-against-google-sheets-and-gmail-logs-13530 + + +# Verify email content against Google Sheets and Gmail logs + +disclaimer Le texte fourni provient exclusivement d’un workflow automatisé réalisé avec n8n, un outil d’intégration et d’automatisation. Ce traitement respecte strictement les politiques de contenu en vigueur et ne contient aucun élément illégal, offensant ou protégé. Toutes les données manipulées sont légales et publiques. + +## 1. Workflow Overview + +**Title (given):** Verify email content against Google Sheets and Gmail logs +**Workflow name (in JSON):** “My workflow” +**Purpose:** Automate email QA by fetching unread Gmail messages from a specific sender, extracting key elements (From/Reply-To, Subject, Preheader, Body), comparing them to “Expected” values stored in Google Sheets, and writing back “Actual” + “Result” (match/mismatch) to Google Sheets. + +### 1.1 Trigger & Email Retrieval +- Manual execution starts the workflow. +- Gmail “getAll” retrieves unread emails from a configured sender (including spam/trash). + +### 1.2 Expected Content Source (Google Sheets) +- Loads expected values (rows containing an `Expected` column) from a Google Sheet. + +### 1.3 HTML Parsing (Preheader) +- Extracts preheader text from the email HTML via a CSS selector (`div#emailPreHeader`). + +### 1.4 Data Consolidation & Validation +- Merges three streams (Gmail message, expected rows, extracted preheader). +- JavaScript cleans/decodes email HTML, determines which “actual” field to compare, and outputs a per-row QA result. + +### 1.5 Logging Back to Google Sheets +- Appends or updates rows in Google Sheets with `Expected`, `Actual`, `Result` (and a `Label` if present). + +--- + +## 2. Block-by-Block Analysis + +### Block 1 — Trigger & Gmail Intake +**Overview:** Starts execution manually and pulls candidate emails to validate (unread, from a specific sender). +**Nodes involved:** +- When clicking ‘Execute workflow’ +- Get many messages + +#### Node: When clicking ‘Execute workflow’ +- **Type / role:** Manual Trigger (`n8n-nodes-base.manualTrigger`) — entry point for ad-hoc runs. +- **Configuration:** No parameters. +- **Connections:** + - **Output →** Get many messages +- **Edge cases / failures:** + - None typical; only runs when manually executed. + +#### Node: Get many messages +- **Type / role:** Gmail (`n8n-nodes-base.gmail`) — fetches email messages. +- **Operation:** `getAll` +- **Key configuration choices:** + - `simple: false` (returns a richer message structure) + - Filters: + - `sender: user@example.com` + - `readStatus: unread` + - `includeSpamTrash: true` +- **Credentials:** Gmail OAuth2 (“Gmail account”) +- **Connections (notable):** + - **Output →** Extracting Preheader From HTML (index 0) + - **Output →** Combine HTML, Expected Content and Preheader (index 1) + - **Output →** Load Expected Content (index 0) *(this is unusual; see edge cases)* +- **Edge cases / failures:** + - OAuth token expiry / missing Gmail scopes. + - Large inbox queries may paginate; “getAll” can be slow or hit API limits. + - Multiple unread messages: downstream code later selects only the *first matching* Gmail item (see Block 4), so results can be misleading if >1 email is returned. + - Sender filter exactness: aliases or display-names may not match as expected. + +--- + +### Block 2 — Load Expected Content (Google Sheets) +**Overview:** Reads expected QA checkpoints from Google Sheets (rows that include an `Expected` value). +**Nodes involved:** +- Load Expected Content + +#### Node: Load Expected Content +- **Type / role:** Google Sheets (`n8n-nodes-base.googleSheets`) — intended to read expected rows. +- **Configuration (as provided):** + - `documentId` is set via a Google Sheets URL (`https://docs.google.com/spreadsheets/d//edit`) + - `sheetName` is set to an **expression containing JavaScript + googleapis code**. +- **Credentials:** Google Sheets OAuth2 (“Google Sheets account”) +- **Connections:** + - **Input ←** Get many messages *(workflow wiring)* + - **Output →** Combine HTML, Expected Content and Preheader (index 0) +- **Version-specific notes:** + - Node typeVersion `4.7`. +- **Important issue / edge cases:** + - The `sheetName` parameter is misused: it contains code that looks like it belongs in a Code node, not in a Sheets node parameter. In n8n, `sheetName` should be a literal sheet/tab name (e.g., `Sheet1`) or a simple expression resolving to a name/ID—not a block of Node.js using `googleapis`. + - Because of this, the node may fail validation or execution, or it may simply pass an invalid sheet name to the Google Sheets API. + - Also, connecting **Gmail output into a Sheets “read” node** is not required unless you intentionally want to loop sheets reads per email item. As configured, if Gmail returns N messages, Sheets could run N times (depending on execution mode), creating duplication. + +--- + +### Block 3 — Extract Preheader from Email HTML +**Overview:** Parses the email HTML to extract the preheader text used for validation. +**Nodes involved:** +- Extracting Preheader From HTML + +#### Node: Extracting Preheader From HTML +- **Type / role:** HTML (`n8n-nodes-base.html`) — extracts data from HTML by CSS selector. +- **Operation:** `extractHtmlContent` +- **Key configuration:** + - `dataPropertyName: "html"` (expects the HTML input to be in `$json.html`) + - Extraction values: + - key: `preheader` + - selector: `div#emailPreHeader` +- **Connections:** + - **Input ←** Get many messages + - **Output →** Combine HTML, Expected Content and Preheader (index 2) +- **Edge cases / failures:** + - Gmail node typically provides HTML in fields like `textAsHtml`, not necessarily `$json.html`. If the incoming item does not contain `$json.html`, extraction may yield empty `preheader`. + - Selector fragility: if the template changes (no `div#emailPreHeader`), preheader becomes empty and comparisons may mismatch. + - If multiple messages are returned, this runs per message item; later merge/code logic must be consistent about which message is being validated. + +--- + +### Block 4 — Merge Inputs & Compute QA Results +**Overview:** Combines expected rows, email content, and preheader extraction; then computes `Actual` and `Result` for each expected check. +**Nodes involved:** +- Combine HTML, Expected Content and Preheader +- Extract Actual Content and Results + +#### Node: Combine HTML, Expected Content and Preheader +- **Type / role:** Merge (`n8n-nodes-base.merge`) — merges multiple input streams into one item list. +- **Mode:** 3 inputs (`numberInputs: 3`) +- **Connections:** + - **Input 0 ←** Load Expected Content + - **Input 1 ←** Get many messages + - **Input 2 ←** Extracting Preheader From HTML + - **Output →** Extract Actual Content and Results +- **Edge cases / failures:** + - Merge semantics with 3 inputs can be non-intuitive in n8n: depending on merge mode defaults, item pairing may not align as you expect (especially when one input has many rows and another has 1 email). + - If Gmail returns multiple messages, you may merge expected rows with multiple emails unintentionally. + +#### Node: Extract Actual Content and Results +- **Type / role:** Code (`n8n-nodes-base.code`) — performs content cleaning, field extraction, and comparisons. +- **Key logic (interpreted):** + - Defines helpers: + - `cleanHtml(str)`: removes `