{
  "workflow": {
    "id": 5423,
    "name": "Gmail MCP workflow - AI-powered email management",
    "views": 1362,
    "recentViews": 0,
    "totalViews": 1362,
    "createdAt": "2025-06-28T03:32:17.894Z",
    "description": "*This workflow contains community nodes that are only compatible with the self-hosted version of n8n.* \n\n## MCP Gmail Workflow – AI-Powered Email Management\n\n## ✨ What It Does\nA smart n8n workflow that connects Gmail with an AI agent (via MCP), letting you send, read, and organize emails using natural language.\n\n## ⚙️ Key Features\n🧠 AI Commands: “Send email to John about the budget”\n📥 Inbox Control: Mark read/unread, apply/remove labels\n🗂 Smart Organization: Auto-label based on content\n🤖 MCP-Ready: Works with Claude, ChatGPT, etc.\n## 🎯 Use Cases\n“📤 Send a follow-up to the client about yesterday’s meeting”\n“📬 Mark all newsletters as read and label ‘Newsletter’”\n“🧾 Summarize latest email from Sarah”\n“🗃 Label all Project X emails as ‘Project-X-2024’”\n“⭐ Find unread emails from my manager and mark as important”\n🛠 Setup Guide\n🔑 Prerequisites\n\nn8n (self-hosted or cloud)\nGmail API credentials\nMCP-compatible AI (optional but powerful)\n## 📥 1. Import Workflow\n\nCopy JSON → Open n8n → Import → Paste → Done ✅\n## 🔐 2. Gmail OAuth2 Setup\n\nCreate Google project → Enable Gmail API\nCreate OAuth2 creds → Add n8n redirect URI\nIn n8n: Add Gmail OAuth2 → Paste Client ID/Secret → Connect\n## 🧩 3. Update Credential References\n\nFind your credential ID in n8n\nUpdate each Gmail node with your ID\n## 🧠 4. MCP Trigger (Optional)\n\nUse provided webhook URL in your AI system\nSend test prompts to verify connection\n## 🧪 5. Test Key Actions\n\n✅ “Send a test email”\n✅ “Read latest email”\n✅ “Label last email as ‘Test’”\n✅ “Mark latest email as unread”\n## ⚙️ 6. Advanced Tips\n\nCreate custom labels in Gmail\nUse HTTPS + webhook auth\nAdd retries and error handling in n8n\n🧯 Troubleshooting\n❗ Gmail Auth Error? → Re-auth and check redirect URI\n❗ Webhook not firing? → Check endpoint + manual test\n❗ Label errors? → Use correct label names or IDs\n✅ Required Gmail Scopes:\ngmail.modify\ngmail.send\n📈 Best Practices\n🔁 Test regularly\n🔒 Use minimal permissions\n🏷 Consistent label naming\n🔍 Monitor execution + webhook logs\n🎉 You’re All Set!\nControl Gmail with your voice or text through AI. Make managing emails smarter, faster, and 100% automated 💌\n",
    "workflow": {
      "meta": {
        "instanceId": "2000c64071c20843606b95c63795bb0797c41036047055a6586498e855b96efc",
        "templateCredsSetupCompleted": true
      },
      "nodes": [
        {
          "id": "984b6aba-c9ea-4b12-9274-c8d479c2719f",
          "name": "MCP Server Trigger",
          "type": "@n8n/n8n-nodes-langchain.mcpTrigger",
          "notes": "🚀 MCP TRIGGER\n\nThis is the entry point for AI interactions with Gmail. The MCP (Model Context Protocol) trigger allows AI models to call any of the connected Gmail tools based on user requests.\n\nKey Features:\n• Enables natural language Gmail commands\n• Routes AI requests to appropriate Gmail operations\n• Provides context-aware email management\n• Supports complex multi-step email workflows",
          "position": [
            -1640,
            200
          ],
          "webhookId": "fe5e5e6c-07d6-48c1-a1f8-d554bae77daf",
          "parameters": {
            "path": "fe5e5e6c-07d6-48c1-a1f8-d554bae77daf"
          },
          "typeVersion": 1.1
        },
        {
          "id": "64fd5646-c65b-4142-944f-7046a745690b",
          "name": "Gmail - Send Email",
          "type": "n8n-nodes-base.gmailTool",
          "notes": "📧 SEND EMAIL\n\nCompose and send emails through AI commands. The AI extracts recipient, subject, and message content from natural language requests.\n\nUse Cases:\n• \"Send an email to john@example.com about the meeting\"\n• \"Compose a follow-up email to the client\"\n• \"Send a thank you note to the team\"\n\nAI Parameters:\n• To: Email recipient(s)\n• Subject: Email subject line\n• Message: Email body content",
          "position": [
            -1020,
            700
          ],
          "webhookId": "3000cd3a-79cd-4af9-949c-6f04955a725a",
          "parameters": {
            "sendTo": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('To', ``, 'string') }}",
            "message": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Message', ``, 'string') }}",
            "options": {},
            "subject": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Subject', ``, 'string') }}"
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "credential-id",
              "name": "gmailOAuth2 Credential"
            }
          },
          "typeVersion": 2.1
        },
        {
          "id": "c57c28ce-2353-4f18-b7db-91f508ebe4da",
          "name": "Gmail - Get Email",
          "type": "n8n-nodes-base.gmailTool",
          "notes": "📖 READ EMAIL\n\nRetrieve and read email content by message ID. Perfect for AI to analyze, summarize, or extract information from specific emails.\n\nUse Cases:\n• \"Read the latest email from Sarah\"\n• \"Get the content of message ID 123456\"\n• \"Show me the email about the project update\"\n\nReturns:\n• Full email content\n• Headers and metadata\n• Attachments information\n• Thread context",
          "position": [
            -800,
            600
          ],
          "webhookId": "305f98e4-e58c-486d-b66e-eb67fb0201a4",
          "parameters": {
            "operation": "get"
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "credential-id",
              "name": "gmailOAuth2 Credential"
            }
          },
          "typeVersion": 2.1
        },
        {
          "id": "d164fa99-97f4-4544-8ea6-c74ae06bb2b4",
          "name": "Gmail - Mark Unread",
          "type": "n8n-nodes-base.gmailTool",
          "notes": "👁️ MARK AS UNREAD\n\nMark emails as unread to ensure they get attention later. Useful for emails that need follow-up or further action.\n\nUse Cases:\n• \"Mark that important email as unread\"\n• \"I need to revisit this email later\"\n• \"Flag this message for follow-up\"\n\nBest Practices:\n• Use for emails requiring action\n• Combine with labels for better organization\n• Great for creating manual reminders",
          "position": [
            -600,
            500
          ],
          "webhookId": "0a16a6f4-f36a-4774-9229-bd2a6ed30fde",
          "parameters": {
            "operation": "markAsUnread"
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "credential-id",
              "name": "gmailOAuth2 Credential"
            }
          },
          "typeVersion": 2.1
        },
        {
          "id": "d5712ba7-9db0-4203-b5b9-1a0ece642cce",
          "name": "Gmail - Add Labels",
          "type": "n8n-nodes-base.gmailTool",
          "notes": "🏷️ ADD LABELS\n\nOrganize emails by adding labels for better categorization and workflow management.\n\nUse Cases:\n• \"Label this email as 'Important'\"\n• \"Add 'Project-X' label to recent emails\"\n• \"Categorize this as 'Follow-up Required'\"\n\nAI Parameters:\n• Message_ID: Target email ID\n• Label_Names_or_IDs: Labels to apply\n\nTip: Use descriptive labels for AI-driven organization",
          "position": [
            -280,
            400
          ],
          "webhookId": "d2ae386f-e833-4129-ad97-94e3b3bcb950",
          "parameters": {
            "labelIds": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Label_Names_or_IDs', ``, 'string') }}",
            "messageId": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Message_ID', ``, 'string') }}",
            "operation": "addLabels"
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "credential-id",
              "name": "gmailOAuth2 Credential"
            }
          },
          "typeVersion": 2.1
        },
        {
          "id": "558332d6-5ff4-4eea-9aa1-7851ad94397e",
          "name": "Gmail - Mark Read",
          "type": "n8n-nodes-base.gmailTool",
          "notes": "✅ MARK AS READ\n\nMark emails as read to maintain inbox organization and track processed messages.\n\nUse Cases:\n• \"Mark all emails from today as read\"\n• \"I've processed this email, mark it read\"\n• \"Clean up my unread messages\"\n\nAutomation Ideas:\n• Auto-mark newsletters as read\n• Mark processed support tickets\n• Bulk mark promotional emails",
          "position": [
            -600,
            60
          ],
          "webhookId": "4c54b980-dccb-47af-b9aa-672cc0cf687c",
          "parameters": {
            "operation": "markAsRead"
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "credential-id",
              "name": "gmailOAuth2 Credential"
            }
          },
          "typeVersion": 2.1
        },
        {
          "id": "ea878786-f87d-4734-bed0-f4d96c459593",
          "name": "Gmail - Remove Labels",
          "type": "n8n-nodes-base.gmailTool",
          "notes": "🗑️ REMOVE LABELS\n\nRemove labels from emails to update categorization or clean up organization system.\n\nUse Cases:\n• \"Remove 'Urgent' label from this email\"\n• \"Clean up old project labels\"\n• \"Update email categorization\"\n\nAI Parameters:\n• Message_ID: Target email ID\n• Label_Names_or_IDs: Labels to remove\n\nWorkflow Tip: Combine with add labels for label migration",
          "position": [
            -1460,
            640
          ],
          "webhookId": "830a9b14-2bbe-4969-a3a9-fd76a8069339",
          "parameters": {
            "labelIds": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Label_Names_or_IDs', ``, 'string') }}",
            "messageId": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Message_ID', ``, 'string') }}",
            "operation": "removeLabels"
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "credential-id",
              "name": "gmailOAuth2 Credential"
            }
          },
          "typeVersion": 2.1
        },
        {
          "id": "98f2cb9e-d0a9-48a9-9b9a-26a195128180",
          "name": "Sticky Note - MCP Trigger",
          "type": "n8n-nodes-base.stickyNote",
          "position": [
            -2020,
            -60
          ],
          "parameters": {
            "color": 5,
            "width": 689,
            "height": 424,
            "content": "## 🚀 MCP TRIGGER EXPLANATION\n\n**What it does:**\nThis is the entry point for AI interactions with Gmail. The MCP (Model Context Protocol) trigger allows AI models to call any of the connected Gmail tools based on user requests.\n\n**Key Features:**\n• Enables natural language Gmail commands\n• Routes AI requests to appropriate Gmail operations\n• Provides context-aware email management\n• Supports complex multi-step email workflows\n\n**Example Commands:**\n\"Send an email to john@example.com\"\n\"Mark the latest email as important\"\n\"Read my unread messages\""
          },
          "typeVersion": 1
        },
        {
          "id": "f3431de6-e652-44d0-9060-d8f320e148eb",
          "name": "Sticky Note - Send Email",
          "type": "n8n-nodes-base.stickyNote",
          "position": [
            -1180,
            840
          ],
          "parameters": {
            "width": 350,
            "height": 284,
            "content": "## 📧 SEND EMAIL\n\n**Purpose:**\nCompose and send emails through AI commands. The AI extracts recipient, subject, and message content from natural language requests.\n\n**Use Cases:**\n• \"Send an email to john@example.com about the meeting\"\n• \"Compose a follow-up email to the client\"\n• \"Send a thank you note to the team\"\n\n**AI Parameters:**\n• **To:** Email recipient(s)\n• **Subject:** Email subject line\n• **Message:** Email body content"
          },
          "typeVersion": 1
        },
        {
          "id": "763d55d6-9c23-4997-b877-594e4c89d81d",
          "name": "Sticky Note - Get Email",
          "type": "n8n-nodes-base.stickyNote",
          "position": [
            -700,
            780
          ],
          "parameters": {
            "color": 7,
            "width": 320,
            "height": 264,
            "content": "## 📖 READ EMAIL\n\n**Purpose:**\nRetrieve and read email content by message ID. Perfect for AI to analyze, summarize, or extract information from specific emails.\n\n**Use Cases:**\n• \"Read the latest email from Sarah\"\n• \"Get the content of message ID 123456\"\n• \"Show me the email about the project update\"\n\n**Returns:**\n• Full email content\n• Headers and metadata\n• Attachments information\n• Thread context"
          },
          "typeVersion": 1
        },
        {
          "id": "7e7eb446-0483-4c47-9420-c8c9292f48c1",
          "name": "Sticky Note - Mark Unread",
          "type": "n8n-nodes-base.stickyNote",
          "position": [
            -400,
            580
          ],
          "parameters": {
            "width": 300,
            "height": 244,
            "content": "## 👁️ MARK AS UNREAD\n\n**Purpose:**\nMark emails as unread to ensure they get attention later. Useful for emails that need follow-up or further action.\n\n**Use Cases:**\n• \"Mark that important email as unread\"\n• \"I need to revisit this email later\"\n• \"Flag this message for follow-up\"\n\n**Best Practices:**\n• Use for emails requiring action\n• Combine with labels for better organization\n• Great for creating manual reminders"
          },
          "typeVersion": 1
        },
        {
          "id": "976116f9-1b9e-466c-b3cf-46aa9a484320",
          "name": "Sticky Note - Add Labels",
          "type": "n8n-nodes-base.stickyNote",
          "position": [
            -300,
            60
          ],
          "parameters": {
            "color": 6,
            "width": 320,
            "height": 444,
            "content": "## 🏷️ ADD LABELS\n\n**Purpose:**\nOrganize emails by adding labels for better categorization and workflow management.\n\n**Use Cases:**\n• \"Label this email as 'Important'\"\n• \"Add 'Project-X' label to recent emails\"\n• \"Categorize this as 'Follow-up Required'\"\n\n**AI Parameters:**\n• **Message_ID:** Target email ID\n• **Label_Names_or_IDs:** Labels to apply\n\n**Tip:** Use descriptive labels for AI-driven organization"
          },
          "typeVersion": 1
        },
        {
          "id": "835c248d-e384-419b-a22f-9e590afa56c6",
          "name": "Sticky Note - Mark Read",
          "type": "n8n-nodes-base.stickyNote",
          "position": [
            -900,
            -60
          ],
          "parameters": {
            "width": 400,
            "height": 244,
            "content": "## ✅ MARK AS READ\n\n**Purpose:**\nMark emails as read to maintain inbox organization and track processed messages.\n\n**Use Cases:**\n• \"Mark all emails from today as read\"\n• \"I've processed this email, mark it read\"\n• \"Clean up my unread messages\"\n\n**Automation Ideas:**\n• Auto-mark newsletters as read\n• Mark processed support tickets\n• Bulk mark promotional emails"
          },
          "typeVersion": 1
        },
        {
          "id": "faae81d9-bf04-4b66-8bb4-649b22f6cd5b",
          "name": "Sticky Note - Remove Labels",
          "type": "n8n-nodes-base.stickyNote",
          "position": [
            -1640,
            780
          ],
          "parameters": {
            "width": 320,
            "height": 264,
            "content": "## 🗑️ REMOVE LABELS\n\n**Purpose:**\nRemove labels from emails to update categorization or clean up organization system.\n\n**Use Cases:**\n• \"Remove 'Urgent' label from this email\"\n• \"Clean up old project labels\"\n• \"Update email categorization\"\n\n**AI Parameters:**\n• **Message_ID:** Target email ID\n• **Label_Names_or_IDs:** Labels to remove\n\n**Workflow Tip:** Combine with add labels for label migration"
          },
          "typeVersion": 1
        },
        {
          "id": "f2da52ae-39ce-40b7-a162-4c4cb369e7f4",
          "name": "Sticky Note - Overview",
          "type": "n8n-nodes-base.stickyNote",
          "position": [
            -2620,
            280
          ],
          "parameters": {
            "color": 7,
            "width": 400,
            "height": 664,
            "content": "## 🎯 WORKFLOW OVERVIEW\n\n**Gmail MCP - AI-Powered Email Management**\n\nThis workflow provides a complete toolkit for intelligent email management through AI interactions using the Model Context Protocol (MCP).\n\n**Core Capabilities:**\n• 📧 Send personalized emails\n• 📖 Read and analyze email content\n• 🏷️ Organize with smart labeling\n• ✅ Manage read/unread status\n• 🤖 Natural language commands\n\n**Getting Started:**\n1. Ensure Gmail OAuth2 is configured\n2. Test each tool individually\n3. Use natural language with your AI\n4. Monitor workflow execution logs"
          },
          "typeVersion": 1
        }
      ],
      "pinData": {},
      "connections": {
        "Gmail - Get Email": {
          "ai_tool": [
            [
              {
                "node": "MCP Server Trigger",
                "type": "ai_tool",
                "index": 0
              }
            ]
          ]
        },
        "Gmail - Mark Read": {
          "ai_tool": [
            [
              {
                "node": "MCP Server Trigger",
                "type": "ai_tool",
                "index": 0
              }
            ]
          ]
        },
        "Gmail - Add Labels": {
          "ai_tool": [
            [
              {
                "node": "MCP Server Trigger",
                "type": "ai_tool",
                "index": 0
              }
            ]
          ]
        },
        "Gmail - Send Email": {
          "ai_tool": [
            [
              {
                "node": "MCP Server Trigger",
                "type": "ai_tool",
                "index": 0
              }
            ]
          ]
        },
        "Gmail - Mark Unread": {
          "ai_tool": [
            [
              {
                "node": "MCP Server Trigger",
                "type": "ai_tool",
                "index": 0
              }
            ]
          ]
        },
        "Gmail - Remove Labels": {
          "ai_tool": [
            [
              {
                "node": "MCP Server Trigger",
                "type": "ai_tool",
                "index": 0
              }
            ]
          ]
        }
      }
    },
    "lastUpdatedBy": 51,
    "workflowInfo": {
      "nodeCount": 15,
      "nodeTypes": {
        "n8n-nodes-base.gmailTool": {
          "count": 6
        },
        "n8n-nodes-base.stickyNote": {
          "count": 8
        },
        "@n8n/n8n-nodes-langchain.mcpTrigger": {
          "count": 1
        }
      }
    },
    "status": "published",
    "user": {
      "name": "David Olusola",
      "username": "dae221",
      "bio": "I design enterprise-grade automation systems that eliminate bottlenecks, cut manual work by 70%+, and unlock millions in lost revenue opportunities. My clients — typically achieve 5–10x ROI within the first 90 days. Currently partnering with select high-growth companies ready to scale faster with AI automation.  david@daexai.com",
      "verified": true,
      "links": [
        ""
      ],
      "avatar": "https://gravatar.com/avatar/2abbc4c9e828c54a8d8838beda1382e8e4a66684ef9fa8451dbeb3e72b0c9f9c?r=pg&d=retro&size=200"
    },
    "nodes": [
      {
        "id": 565,
        "icon": "fa:sticky-note",
        "name": "n8n-nodes-base.stickyNote",
        "codex": {
          "data": {
            "alias": [
              "Comments",
              "Notes",
              "Sticky"
            ],
            "categories": [
              "Core Nodes"
            ],
            "nodeVersion": "1.0",
            "codexVersion": "1.0",
            "subcategories": {
              "Core Nodes": [
                "Helpers"
              ]
            }
          }
        },
        "group": "[\"input\"]",
        "defaults": {
          "name": "Sticky Note",
          "color": "#FFD233"
        },
        "iconData": {
          "icon": "sticky-note",
          "type": "icon"
        },
        "displayName": "Sticky Note",
        "typeVersion": 1,
        "nodeCategories": [
          {
            "id": 9,
            "name": "Core Nodes"
          }
        ]
      },
      {
        "id": 1293,
        "icon": "file:../mcp.svg",
        "name": "@n8n/n8n-nodes-langchain.mcpTrigger",
        "codex": {
          "data": {
            "alias": [
              "Model Context Protocol",
              "MCP Server"
            ],
            "resources": {
              "primaryDocumentation": [
                {
                  "url": "https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-langchain.mcptrigger/"
                }
              ]
            },
            "categories": [
              "AI",
              "Core Nodes",
              "Langchain"
            ],
            "subcategories": {
              "AI": [
                "Root Nodes",
                "Model Context Protocol"
              ],
              "Core Nodes": [
                "Other Trigger Nodes"
              ]
            }
          }
        },
        "group": "[\"trigger\"]",
        "defaults": {
          "name": "MCP Server Trigger"
        },
        "iconData": {
          "type": "file",
          "fileBuffer": "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTgwIiBoZWlnaHQ9IjE4MCIgdmlld0JveD0iMCAwIDE5NSAxOTUiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+Cgk8ZyBzdHJva2U9IiMwMDAiIHN0cm9rZS13aWR0aD0iMTIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCI+CgkJPHBhdGggZD0iTTI1IDk3Ljg1MjhMOTIuODgyMyAyOS45NzA2QzEwMi4yNTUgMjAuNTk4IDExNy40NTEgMjAuNTk4IDEyNi44MjMgMjkuOTcwNlYyOS45NzA2QzEzNi4xOTYgMzkuMzQzMSAxMzYuMTk2IDU0LjUzOTEgMTI2LjgyMyA2My45MTE3TDc1LjU1ODEgMTE1LjE3NyIvPgoJCTxwYXRoIGQ9Ik03Ni4yNjUzIDExNC40N0wxMjYuODIzIDYzLjkxMTdDMTM2LjE5NiA1NC41MzkxIDE1MS4zOTIgNTQuNTM5MSAxNjAuNzY1IDYzLjkxMTdMMTYxLjExOCA2NC4yNjUyQzE3MC40OTEgNzMuNjM3OCAxNzAuNDkxIDg4LjgzMzggMTYxLjExOCA5OC4yMDYzTDk5LjcyNDggMTU5LjZDOTYuNjAwNiAxNjIuNzI0IDk2LjYwMDYgMTY3Ljc4OSA5OS43MjQ4IDE3MC45MTNMMTEyLjMzMSAxODMuNTIiLz4KCQk8cGF0aCBkPSJNMTA5Ljg1MyA0Ni45NDExTDU5LjY0ODIgOTcuMTQ1N0M1MC4yNzU3IDEwNi41MTggNTAuMjc1NyAxMjEuNzE0IDU5LjY0ODIgMTMxLjA4N1YxMzEuMDg3QzY5LjAyMDggMTQwLjQ1OSA4NC4yMTY4IDE0MC40NTkgOTMuNTg5NCAxMzEuMDg3TDE0My43OTQgODAuODgyMiIvPgoJPC9nPgo8L3N2Zz4K"
        },
        "displayName": "MCP Server Trigger",
        "typeVersion": 2,
        "nodeCategories": [
          {
            "id": 9,
            "name": "Core Nodes"
          },
          {
            "id": 25,
            "name": "AI"
          },
          {
            "id": 26,
            "name": "Langchain"
          }
        ]
      }
    ],
    "categories": [
      {
        "id": 41,
        "name": "Ticket Management"
      },
      {
        "id": 47,
        "name": "AI Chatbot"
      }
    ],
    "image": []
  }
}