Generate DOCX documents from Gmail using OpenAI, Google Sheets and Drive
Ready for 3.0What this workflow does
This AI workflow has 20 nodes and runs on Gmail events. Along the way it connects Gmail, Google Sheets, OpenAI and Google Drive.
How it runs
Trigger: On Gmail events.
- Set Deployment Configuration (Edit Fields (Set)): sets 8 fields: catalogSpreadsheetId, catalogSheet, outputFolderId…
- Validate Sender & Extract Request (Code): runs custom JavaScript code
- If: checks a condition and branches into true / false
- Fetch Template Catalog (Google Sheets): uses Google Sheets
- Build Template Catalog for AI (Code): runs custom JavaScript code
- AI Match Template & Extract Data (OpenAI): uses OpenAI
- Parse Template Match Decision (Code): runs custom JavaScript code
- If: checks a condition and branches into true / false
- Download Template Document (Google Drive): download
- Prepare No-Match Reply (Edit Fields (Set)): sets 1 field: replyBody
…plus 8 more steps. See the full node list below.
Services it uses
Other Google Sheets + Gmail templates (2,102) · Other OpenAI + Google Sheets templates (2,011) · Other OpenAI + Gmail templates (1,623)
Before you upgrade to n8n 3.0
Nothing in this workflow is removed in n8n 3.0, so it should import and run after the upgrade.
- Still check Gmail Trigger below v1.4 runs as v1.4 (drafts skipped, max emails per poll) (When New Email Received).
- Code node: the task timeout drops from 300s to 60s. Test with a realistic data volume.
Nodes used (10)
- Gmail Trigger
n8n-nodes-base.gmailTrigger - Edit Fields (Set)
n8n-nodes-base.set - Code
n8n-nodes-base.code - If
n8n-nodes-base.if - No Operation, do nothing
n8n-nodes-base.noOp - Google Sheets
n8n-nodes-base.googleSheets - OpenAI
@n8n/n8n-nodes-langchain.openAi - Gmail
n8n-nodes-base.gmail - Google Drive
n8n-nodes-base.googleDrive - HTTP Request
n8n-nodes-base.httpRequest
From the author
Quick Overview This workflow monitors Gmail for document-generation requests, validates the sender, looks up available DOCX templates in Google Sheets and Google Drive, uses OpenAI to select and fill the right template, converts the result to DOCX via a…