Protect Gmail AI email workflows from prompt injection with Gemini and Sheets
Ready for 3.0What this workflow does
This AI workflow has 14 nodes and runs on Gmail events. Along the way it connects Gmail, Google Sheets and Google Gemini.
How it runs
Trigger: On Gmail events.
- Set config: Security settings (Edit Fields (Set)): sets 7 fields: dangerous_keywords, spreadsheet_id, sheet_name…
- Code: runs custom JavaScript code
- Code: runs custom JavaScript code
- If: checks a condition and branches into true / false
- Code: runs custom JavaScript code
- Gemini: Safely analyze email (Google Gemini): uses Google Gemini
- Sheets: Log blocked email (Google Sheets): append
- Code: runs custom JavaScript code
- Gmail: work with draft
- Sheets: Log analyzed email (Google Sheets): append
…plus 3 more steps. See the full node list below.
Services it uses
Other Google Sheets + Gmail templates (2,102) · Other Google Gemini + Google Sheets templates (819) · Other Google Gemini + Gmail templates (518)
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.
- Code node: the task timeout drops from 300s to 60s. Test with a realistic data volume.
Nodes used (8)
- Gmail Trigger
n8n-nodes-base.gmailTrigger - Edit Fields (Set)
n8n-nodes-base.set - Code
n8n-nodes-base.code - If
n8n-nodes-base.if - Google Sheets
n8n-nodes-base.googleSheets - Gmail
n8n-nodes-base.gmail - Google Gemini
@n8n/n8n-nodes-langchain.googleGemini - Switch
n8n-nodes-base.switch
From the author
Quick overview This workflow monitors Gmail for new support-style emails, scans them for prompt-injection signals, and only then sends safe messages to Google Gemini for structured triage. It logs outcomes to Google Sheets and creates Gmail drafts either for…