This workflow follows the Gmail → HTTP Request 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": "org-ai Dept Marketing",
"nodes": [
{
"parameters": {},
"id": "trigger",
"name": "Execute Workflow Trigger",
"type": "n8n-nodes-base.executeWorkflowTrigger",
"typeVersion": 1,
"position": [
240,
300
]
},
{
"parameters": {
"url": "={{ $json.runData.logUrl }}",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
},
{
"name": "x-webhook-token",
"value": "={{ $env.N8N_WEBHOOK_AUTH_TOKEN || 'org-ai-n8n-secret-token' }}"
}
]
},
"sendBody": true,
"bodyParameters": {
"parameters": [
{
"name": "taskId",
"value": "={{ $json.runData.taskId }}"
},
{
"name": "message",
"value": "\u30de\u30fc\u30b1\u90e8 (Marketing) \u30ef\u30fc\u30af\u30d5\u30ed\u30fc\u958b\u59cb"
},
{
"name": "level",
"value": "INFO"
}
]
},
"options": {}
},
"id": "log-start",
"name": "Log Start",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4,
"position": [
460,
300
]
},
{
"parameters": {
"jsCode": "const rd = $('Execute Workflow Trigger').item.json.runData;\nconst input = (rd.input ?? '').toLowerCase();\nconst hint = (rd.taskType ?? '').toLowerCase();\nconst kw = (words) => words.some(w => input.includes(w.toLowerCase()) || hint.includes(w.toLowerCase()));\n\nlet taskMode = 'sns';\nif (kw(['\u30e1\u30fc\u30eb','email','mail','\u30e1\u30eb\u30de\u30ac','newsletter'])) taskMode = 'email';\nelse if (kw(['\u30ab\u30ec\u30f3\u30c0\u30fc','\u30b3\u30f3\u30c6\u30f3\u30c4\u30ab\u30ec\u30f3\u30c0\u30fc','\u6295\u7a3f\u8a08\u753b'])) taskMode = 'content_calendar';\nelse if (kw(['SNS','\u6295\u7a3f','\u30c4\u30a4\u30fc\u30c8','twitter','x.com','instagram','linkedin','threads','\u30dd\u30b9\u30c8'])) taskMode = 'sns';\n\nconst prompts = {\n email: `\u3042\u306a\u305f\u306f\u30de\u30fc\u30b1\u90e8\u306e\u30e1\u30eb\u30de\u30acAI\u3067\u3059\u3002\u8aad\u307f\u624b\u306b\u523a\u3055\u308b\u30e1\u30eb\u30de\u30ac\u3092\u4f5c\u6210\u3057\u3066\u304f\u3060\u3055\u3044\u3002\\nJSON: {\"taskType\":\"email\",\"to\":\"\",\"cc\":\"\",\"subject\":\"\",\"body\":\"\u672c\u6587\uff08HTML\u53ef\u3001\u6539\u884c\u306f\\\\n\uff09\"}`,\n sns: `\u3042\u306a\u305f\u306fSNS\u30de\u30fc\u30b1AI\u3067\u3059\u3002\u30a8\u30f3\u30b2\u30fc\u30b8\u30e1\u30f3\u30c8\u9ad8\u3044\u6295\u7a3f\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\\nJSON: {\"taskType\":\"sns\",\"platform\":\"twitter\",\"content\":\"\u6295\u7a3f\u6587(280\u5b57\u4ee5\u5185)\",\"hashtags\":[],\"tone\":\"\",\"targetAudience\":\"\"}`,\n content_calendar: `\u3042\u306a\u305f\u306f\u30b3\u30f3\u30c6\u30f3\u30c4\u4f01\u753bAI\u3067\u3059\u3002\\nJSON: {\"taskType\":\"content_calendar\",\"title\":\"\",\"summary\":\"\",\"content\":[{\"date\":\"YYYY-MM-DD\",\"platform\":\"\",\"content\":\"\"}]}`\n};\nconst systemPrompt = prompts[taskMode] ?? prompts.sns;\nconst messages = [\n { role: 'system', content: systemPrompt },\n { role: 'user', content: rd.input }\n];\nreturn [{ json: { messages, taskMode, useJsonMode: true, department: 'MARKETING', org_id: rd.orgId, plan: rd.plan ?? 'STARTER', aiEngineUrl: rd.aiEngineUrl ?? 'http://ai-engine:8000' } }];"
},
"id": "build-prompt",
"name": "Build Prompt",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
680,
300
]
},
{
"parameters": {
"method": "POST",
"url": "={{ $json.aiEngineUrl }}/llm/chat",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"contentType": "raw",
"rawContentType": "application/json",
"body": "={{ JSON.stringify({ messages: $json.messages, department: $json.department, org_id: $json.org_id, plan: $json.plan, json_mode: $json.useJsonMode }) }}",
"options": {}
},
"id": "ai-chat",
"name": "AI Engine Chat",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4,
"position": [
900,
300
]
},
{
"parameters": {
"rules": {
"values": [
{
"conditions": {
"options": {
"caseSensitive": false,
"leftValue": "",
"typeValidation": "strict"
},
"conditions": [
{
"leftValue": "={{ $('Build Prompt').item.json.taskMode }}",
"rightValue": "email",
"operator": {
"type": "string",
"operation": "equals"
}
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "email"
}
]
},
"options": {
"fallbackOutput": "extra"
}
},
"id": "switch-mode",
"name": "Switch Email vs Other",
"type": "n8n-nodes-base.switch",
"typeVersion": 3,
"position": [
1120,
300
]
},
{
"parameters": {
"jsCode": "const raw = $json.content ?? '';\nlet parsed = {};\ntry { parsed = JSON.parse(raw); } catch { parsed = { to: '', subject: '(AI \u51fa\u529b\u3092JSON\u30d1\u30fc\u30b9\u5931\u6557)', body: raw }; }\nreturn [{ json: { ...parsed, _ai: $json } }];"
},
"id": "parse-email",
"name": "Parse Email JSON",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
1340,
200
]
},
{
"parameters": {
"sendTo": "={{ $json.to }}",
"subject": "={{ $json.subject }}",
"emailType": "text",
"message": "={{ $json.body }}",
"options": {
"ccList": "={{ $json.cc || '' }}",
"appendAttribution": false
}
},
"id": "send-email",
"name": "Send Email (Gmail)",
"type": "n8n-nodes-base.gmail",
"typeVersion": 2.1,
"position": [
1560,
200
]
},
{
"parameters": {
"url": "={{ $('Execute Workflow Trigger').item.json.runData.callbackUrl }}",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
},
{
"name": "x-webhook-token",
"value": "={{ $env.N8N_WEBHOOK_AUTH_TOKEN || 'org-ai-n8n-secret-token' }}"
}
]
},
"sendBody": true,
"bodyParameters": {
"parameters": [
{
"name": "taskId",
"value": "={{ $('Execute Workflow Trigger').item.json.runData.taskId }}"
},
{
"name": "status",
"value": "DONE"
},
{
"name": "output",
"value": "={{ JSON.stringify({ taskType: 'email', sentTo: $('Parse Email JSON').item.json.to, subject: $('Parse Email JSON').item.json.subject }) }}"
},
{
"name": "workflowId",
"value": "={{ $workflow.id }}"
}
]
},
"options": {}
},
"id": "callback-email",
"name": "Callback (Email Done)",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4,
"position": [
1780,
200
]
},
{
"parameters": {
"url": "={{ $('Execute Workflow Trigger').item.json.runData.callbackUrl }}",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
},
{
"name": "x-webhook-token",
"value": "={{ $env.N8N_WEBHOOK_AUTH_TOKEN || 'org-ai-n8n-secret-token' }}"
}
]
},
"sendBody": true,
"bodyParameters": {
"parameters": [
{
"name": "taskId",
"value": "={{ $('Execute Workflow Trigger').item.json.runData.taskId }}"
},
{
"name": "status",
"value": "DONE"
},
{
"name": "output",
"value": "={{ $('AI Engine Chat').item.json.content }}"
},
{
"name": "workflowId",
"value": "={{ $workflow.id }}"
}
]
},
"options": {}
},
"id": "callback-other",
"name": "Callback (Other Done)",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4,
"position": [
1340,
400
]
}
],
"connections": {
"Execute Workflow Trigger": {
"main": [
[
{
"node": "Log Start",
"type": "main",
"index": 0
}
]
]
},
"Log Start": {
"main": [
[
{
"node": "Build Prompt",
"type": "main",
"index": 0
}
]
]
},
"Build Prompt": {
"main": [
[
{
"node": "AI Engine Chat",
"type": "main",
"index": 0
}
]
]
},
"AI Engine Chat": {
"main": [
[
{
"node": "Switch Email vs Other",
"type": "main",
"index": 0
}
]
]
},
"Switch Email vs Other": {
"main": [
[
{
"node": "Parse Email JSON",
"type": "main",
"index": 0
}
],
[
{
"node": "Callback (Other Done)",
"type": "main",
"index": 0
}
]
]
},
"Parse Email JSON": {
"main": [
[
{
"node": "Send Email (Gmail)",
"type": "main",
"index": 0
}
]
]
},
"Send Email (Gmail)": {
"main": [
[
{
"node": "Callback (Email Done)",
"type": "main",
"index": 0
}
]
]
}
},
"settings": {
"executionOrder": "v1",
"saveManualExecutions": true
},
"staticData": null
}
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
org-ai Dept Marketing. Uses httpRequest, gmail. Webhook trigger; 9 nodes.
Source: https://github.com/hamahiro1668/org-ai-platform/blob/f36c4297a8e19382d8bbceeac39baf13028094d2/apps/n8n-workflows/dept-marketing.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.
This workflow automates bulk email campaigns with built-in validation, deliverability protection, and smart send-time optimization.
Universal Lead Processing Workflow. Uses googleSheets, gmail, httpRequest, gmailTrigger. Webhook trigger; 34 nodes.
This workflow acts as an instant SDR that replies to new inbound leads across multiple channels in real time. It first captures and normalizes all incoming lead data into a unified structure. The work
A comprehensive n8n workflow template for streamlining influencer application processing with real-time social media data validation, intelligent scoring algorithms, and automated onboarding workflows
Cana V2 Lead Processor. Uses httpRequest, gmail, dataTable. Webhook trigger; 20 nodes.