This workflow corresponds to n8n.io template #7525 — we link there as the canonical source.
This workflow follows the Agent → Gmail recipe pattern — see all workflows that pair these two integrations.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"id": "Kb8GjaSSiC75Pcdk",
"meta": {
"templateCredsSetupCompleted": true
},
"name": "Email Automation for Sponsored Deals",
"tags": [],
"nodes": [
{
"id": "26059112-67e7-4a81-b187-70dcbf8ff44f",
"name": "Gmail Trigger",
"type": "n8n-nodes-base.gmailTrigger",
"position": [
-440,
-100
],
"parameters": {
"simple": false,
"filters": {},
"options": {},
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
}
},
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "fbcb4645-50d3-4e2c-9c27-8c89333f39db",
"name": "Edit Fields",
"type": "n8n-nodes-base.set",
"position": [
-220,
-100
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "d78ea8f1-65f1-4cb6-bb27-c652a5a63d94",
"name": "From",
"type": "string",
"value": "={{ $json.headers.from }}"
},
{
"id": "1b4a5b47-5057-4ac2-9e03-f3bb0d98134b",
"name": "Subject",
"type": "string",
"value": "={{ $json.subject }}"
},
{
"id": "f9968f70-b3a0-4000-9a64-c6504317eeff",
"name": "Email_Body",
"type": "string",
"value": "={{ $json.text }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "1ecfa39b-9749-4364-96af-f4d5db5486c6",
"name": "AI Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
-20,
-100
],
"parameters": {
"text": "=# System Prompt for Sponsored Email Detection Agent\n\n## Role\nYou are an **Email Sentiment & Sponsorship Detection Agent**. \nYour primary task is to analyze incoming emails, determine if they are **sponsored emails**, identify the sender\u2019s **intention**, and return results in a structured JSON format. \n\n---\n\n## Behavior\n- Always be **objective and concise**. \n- Never provide extra explanations outside the defined output format. \n- Focus strictly on analyzing **email content, tone, and intent**. \n\n---\n\n## Output Format\nAlways respond in **Markdown** using the following JSON structure: \n\n```json\n{\n \"isSponsoredEmail\": true/false,\n \"reason\": \"Concise explanation of why you classified it this way\"\n}\n\n\n {{ $json.Email_Body }}",
"options": {},
"promptType": "define",
"hasOutputParser": true
},
"typeVersion": 2
},
{
"id": "7d9b4d22-b83a-43c6-b2d1-081c12771d56",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
-100,
120
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "b251365d-8bff-441e-8ab3-250ba216bac3",
"name": "Structured Output Parser",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
160,
200
],
"parameters": {
"schemaType": "manual",
"inputSchema": "{\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"isSponsoredEmail\": {\n\t\t\t\"type\": \"boolean\"\n\t\t},\n\t\t\"reason\": {\n\t\t\t\"type\": \"string\"\t\t\t\n\t\t}\n\t}\n}"
},
"typeVersion": 1.2
},
{
"id": "dc80f4ae-c9dd-4847-8142-b34598ee7f2c",
"name": "If",
"type": "n8n-nodes-base.if",
"position": [
360,
-100
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "a4ad6+1234567890-b106-d232132206fd",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{ $json.output.isSponsoredEmail }}",
"rightValue": "true"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "e089a21d-712d-4c85-991a-6a751ab6361f",
"name": "No Operation, do nothing",
"type": "n8n-nodes-base.noOp",
"position": [
680,
100
],
"parameters": {},
"typeVersion": 1
},
{
"id": "e27b672a-3cc6-45d7-a7b8-80f56e1c1c87",
"name": "AI Agent1",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
680,
-380
],
"parameters": {
"text": "=#Role\nYou are a professional and courteous email assistant responding on behalf of [Your Company Name]. You've just received a sponsored email offer. Please read the email content and draft a polite, professional reply informing the sender that while you appreciate their interest, your company is not currently accepting sponsored content.\n\nKindly explain that you have specific criteria that must be met before considering sponsorships, such as alignment with your brand values, audience relevance, and internal planning cycles. Offer to keep their information on file and encourage them to reach out in the future when sponsorship opportunities reopen.\n\nMaintain a friendly tone, express gratitude for their outreach, and do not close the door completely. End with a courteous sign-off.\n\n# Prepare Email body as below. \nHello,\n\nThank you for your interest in collaborating with [Your Company Name]. We truly appreciate the time and effort you\u2019ve taken to reach out to us.\n\nWe do occasionally accept sponsored content, provided it meets a few important criteria that ensure value and relevance for our audience. Specifically, we look for partnerships that: \n\n1. **Align with Our Brand Values** \u2013 The content should reflect the professionalism, integrity, and focus areas of our company. \n2. **Serve Our Audience** \u2013 Sponsored material should provide clear benefits, insights, or solutions that are relevant and meaningful to our community. \n3. **Complement Our Planning Cycles** \u2013 We accept sponsored opportunities at select times during the year to align with our editorial calendar and campaign schedule. \n\nIf your offer meets these guidelines, we\u2019d be glad to explore the possibility further. Please feel free to share details about your proposal, including the nature of the content, target audience, and how it aligns with the values above. \n\nWe carefully review all opportunities and will respond with next steps if there\u2019s a good fit. Even if the timing isn\u2019t right, we\u2019re happy to keep your information on file for future consideration. \n\nThank you again for thinking of [Your Company Name]. We look forward to staying connected. \n\nWarm regards, \n[Your Name] \n[Your Company Name] \n\n\n\nEmail Details are as below:\n{{ $('Gmail Trigger').item.json.headers.from }}\n{{ $('Gmail Trigger').item.json.headers.subject }}\n{{ $('Gmail Trigger').item.json.text }}\n\nNote: just prepare the email body and do not include message headers. ",
"options": {},
"promptType": "define"
},
"typeVersion": 2
},
{
"id": "e74356b8-3f5f-440c-81d8-9f62ec468711",
"name": "OpenAI Chat Model1",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
680,
-120
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "a0edd387-37ee-4ad6-b12f-9c1b5005f6ba",
"name": "Gmail",
"type": "n8n-nodes-base.gmail",
"position": [
1180,
-380
],
"parameters": {
"message": "={{ $json.output }}",
"options": {},
"emailType": "text",
"messageId": "={{ $('Gmail Trigger').item.json.id }}",
"operation": "reply"
},
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 2.1
},
{
"id": "8579055e-fca8-4b96-a02f-b41251841d16",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-620,
-300
],
"parameters": {
"width": 300,
"height": 360,
"content": "## Email Trigger\nRead inbox every minute and then send to next node for Analysis"
},
"typeVersion": 1
},
{
"id": "b5f4a066-8ee7-4fbc-a627-59b1f199647c",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-300,
-260
],
"parameters": {
"width": 260,
"height": 320,
"content": "## Extract\n- Header\n- Subject\n- EmailBody"
},
"typeVersion": 1
},
{
"id": "36ff7139-a3fe-40d5-ae61-30ee62910207",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
80,
-340
],
"parameters": {
"color": 4,
"width": 360,
"height": 220,
"content": "## Process and validate Confirm If Sponsored \n\n- The AI agent will read through the email and confirm if the email is an sponsored email or not.\n- It then pass this boolean to If Else node."
},
"typeVersion": 1
},
{
"id": "ce10097e-b873-4bfe-8171-3b86c7d2c0d5",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
500,
-560
],
"parameters": {
"color": 6,
"width": 440,
"content": "## Prepare Email Body \n- This node will prepare email body with company policies on accepting any sponsored deals."
},
"typeVersion": 1
},
{
"id": "7da70e7a-8805-4426-a639-afffc41bd1b6",
"name": "Sticky Note4",
"type": "n8n-nodes-base.stickyNote",
"position": [
1140,
-220
],
"parameters": {
"content": "## Reply\n- This node will send an email to the Sender\n"
},
"typeVersion": 1
},
{
"id": "2f793a0b-343e-4ab6-975a-0efafe48304c",
"name": "Sticky Note5",
"type": "n8n-nodes-base.stickyNote",
"position": [
740,
240
],
"parameters": {
"content": "## If not a Sponsored Email. Do Nothing. \n\n"
},
"typeVersion": 1
}
],
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "624043af-906a-4f2a-99d0-46399fdf2e2b",
"connections": {
"If": {
"main": [
[
{
"node": "AI Agent1",
"type": "main",
"index": 0
}
],
[
{
"node": "No Operation, do nothing",
"type": "main",
"index": 0
}
]
]
},
"AI Agent": {
"main": [
[
{
"node": "If",
"type": "main",
"index": 0
}
]
]
},
"AI Agent1": {
"main": [
[
{
"node": "Gmail",
"type": "main",
"index": 0
}
]
]
},
"Edit Fields": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"Gmail Trigger": {
"main": [
[
{
"node": "Edit Fields",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"OpenAI Chat Model1": {
"ai_languageModel": [
[
{
"node": "AI Agent1",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Structured Output Parser": {
"ai_outputParser": [
[
{
"node": "AI Agent",
"type": "ai_outputParser",
"index": 0
}
]
]
}
}
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
gmailOAuth2openAiApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
Managing inbound emails can be exhausting — especially when your inbox is flooded with sponsored deal requests that don’t always fit your brand. Manually reading, filtering, and politely declining each one eats up valuable time.
Source: https://n8n.io/workflows/7525/ — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
This n8n workflow automates sales processes using AI agents integrated with Airtable as a CRM and Gmail for email handling. It consists of two main workflows: one for handling Airtable status changes
mails2notion V2. Uses lmChatOpenAi, toolCalculator, outputParserStructured, gmail. Event-driven trigger; 38 nodes.
This workflow automatically creates Tasks from forwarded Emails, similar to Asana, but better. Emails are processed by AI and converted to rather actionable task.
This workflow automatically classifies every new email from your linked mailbox, drafts a personalized reply, and creates Linear tickets for bugs or feature requests. It uses a human-in-the-loop with
Enterprise-grade resume screening automation built for production environments. This workflow combines intelligent AI analysis with comprehensive error handling to ensure reliable processing of candid