This workflow follows the Gmail → Gmail Trigger 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 →
{
"name": "AI Unsubscribe Handler",
"nodes": [
{
"parameters": {
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
},
"filters": {
"readStatus": "unread"
},
"options": {}
},
"id": "b1b2c3d4-2004-4000-8000-000000000001",
"name": "Gmail Trigger",
"type": "n8n-nodes-base.gmailTrigger",
"typeVersion": 1.1,
"position": [
250,
300
]
},
{
"parameters": {
"resource": "chat",
"model": "gpt-4",
"messages": {
"values": [
{
"content": "Analyze this email to determine if the sender wants to unsubscribe from our mailing list.\n\nFrom: {{ $json.from }}\nSubject: {{ $json.subject }}\nBody: {{ $json.snippet }}\n\nReturn JSON with keys:\n- isUnsubscribeRequest (boolean)\n- confidence (0-1)\n- detectedIntent (string: 'unsubscribe', 'complaint', 'reduce_frequency', 'other')\n- suggestedAction (string)"
}
]
},
"options": {
"temperature": 0.2,
"maxTokens": 300
}
},
"id": "b1b2c3d4-2004-4000-8000-000000000002",
"name": "OpenAI Detect Intent",
"type": "@n8n/n8n-nodes-langchain.openAi",
"typeVersion": 1.3,
"position": [
500,
300
]
},
{
"parameters": {
"jsCode": "const response = JSON.parse($input.first().json.message.content);\nconst emailData = $('Gmail Trigger').first().json;\nreturn [{\n json: {\n ...response,\n from: emailData.from,\n subject: emailData.subject,\n messageId: emailData.id,\n receivedAt: new Date().toISOString()\n }\n}];"
},
"id": "b1b2c3d4-2004-4000-8000-000000000003",
"name": "Parse Intent",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
750,
300
]
},
{
"parameters": {
"conditions": {
"boolean": [
{
"value1": "={{ $json.isUnsubscribeRequest }}",
"value2": true
}
]
}
},
"id": "b1b2c3d4-2004-4000-8000-000000000004",
"name": "Is Unsubscribe?",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
1000,
300
]
},
{
"parameters": {
"operation": "append",
"documentId": {
"__rl": true,
"mode": "id",
"value": "your-unsubscribe-log-sheet-id"
},
"sheetName": {
"__rl": true,
"mode": "name",
"value": "UnsubscribeLog"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"Email": "={{ $json.from }}",
"Subject": "={{ $json.subject }}",
"Intent": "={{ $json.detectedIntent }}",
"Confidence": "={{ $json.confidence }}",
"Date": "={{ $json.receivedAt }}"
}
}
},
"id": "b1b2c3d4-2004-4000-8000-000000000005",
"name": "Log to Sheets",
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.2,
"position": [
1250,
200
]
},
{
"parameters": {
"resource": "message",
"operation": "send",
"sendTo": "={{ $json.from }}",
"subject": "Unsubscribe Confirmation",
"message": "Hi,\n\nWe've received your request to unsubscribe and have removed your email address from our mailing list. You will no longer receive marketing emails from us.\n\nIf this was done in error, you can re-subscribe at any time by visiting our website.\n\nBest regards,\nThe Team",
"options": {}
},
"id": "b1b2c3d4-2004-4000-8000-000000000006",
"name": "Send Confirmation",
"type": "n8n-nodes-base.gmail",
"typeVersion": 2.1,
"position": [
1500,
200
]
}
],
"connections": {
"Gmail Trigger": {
"main": [
[
{
"node": "OpenAI Detect Intent",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Detect Intent": {
"main": [
[
{
"node": "Parse Intent",
"type": "main",
"index": 0
}
]
]
},
"Parse Intent": {
"main": [
[
{
"node": "Is Unsubscribe?",
"type": "main",
"index": 0
}
]
]
},
"Is Unsubscribe?": {
"main": [
[
{
"node": "Log to Sheets",
"type": "main",
"index": 0
}
],
[]
]
},
"Log to Sheets": {
"main": [
[
{
"node": "Send Confirmation",
"type": "main",
"index": 0
}
]
]
}
},
"settings": {
"executionOrder": "v1"
}
}
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
AI Unsubscribe Handler. Uses gmailTrigger, openAi, googleSheets, gmail. Event-driven trigger; 6 nodes.
Source: https://github.com/mlnjsh/n8n-workflows-mega/blob/main/workflows/ai-email/04-unsubscribe-handler.json — 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.
Send A Chatgpt Email Reply And Save Responses To Google Sheets. Uses openAi, gmailTrigger, stickyNote, gmail. Event-driven trigger; 49 nodes.
Code. Uses openAi, gmailTrigger, stickyNote, gmail. Event-driven trigger; 49 nodes.
This workflow sends a OpenAI GPT reply when an email is received from specific email recipients. It then saves the initial email and the GPT response to an automatically generated Google spreadsheet.
n8n Recruitment. Uses gmailTrigger, openAi, googleSheets, gmail. Event-driven trigger; 20 nodes.
Email AI Agent. Uses gmailTrigger, textClassifier, lmChatOpenAi, gmail. Event-driven trigger; 18 nodes.