This workflow follows the Execute Workflow Trigger → 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 →
{
"name": "org-ai Dept Sales",
"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": "\u55b6\u696d\u90e8 (Sales) \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 = 'proposal';\nif (kw(['\u30e1\u30fc\u30eb','email','mail','\u9001\u4fe1','\u9001\u3063\u3066'])) taskMode = 'email';\nelse if (kw(['\u8b70\u4e8b\u9332','\u5546\u8ac7\u30e1\u30e2','\u30df\u30fc\u30c6\u30a3\u30f3\u30b0','\u4f1a\u8b70\u30e1\u30e2'])) taskMode = 'meeting_notes';\nelse if (kw(['\u63d0\u6848\u66f8','\u4f01\u753b\u66f8','\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8','\u8cc7\u6599','\u5831\u544a\u66f8','\u30ec\u30dd\u30fc\u30c8'])) taskMode = 'proposal';\nelse if (kw(['\u898b\u7a4d','\u898b\u7a4d\u66f8','quote'])) taskMode = 'quote';\nelse if (kw(['\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb','\u65e5\u7a0b','\u30ab\u30ec\u30f3\u30c0\u30fc','\u4e88\u5b9a'])) taskMode = 'schedule';\n\nconst prompts = {\n email: `\u3042\u306a\u305f\u306f\u55b6\u696d\u90e8\u306e\u30e1\u30fc\u30eb\u4f5c\u6210AI\u3067\u3059\u3002\u30e6\u30fc\u30b6\u30fc\u306e\u6307\u793a\u306b\u57fa\u3065\u304d\u3001\u4e01\u5be7\u304b\u3064\u30d3\u30b8\u30cd\u30b9\u30e9\u30a4\u30af\u306a\u30e1\u30fc\u30eb\u3092\u4f5c\u6210\u3057\u3066\u304f\u3060\u3055\u3044\u3002\\n\u5fc5\u305a\u4ee5\u4e0b\u306eJSON\u5f62\u5f0f\u306e\u307f\u3092\u8fd4\u3057\u3066\u304f\u3060\u3055\u3044\u3002\\n{\"taskType\":\"email\",\"to\":\"\u5b9b\u5148\",\"cc\":\"\",\"subject\":\"\u4ef6\u540d\",\"body\":\"\u672c\u6587\uff08\u6539\u884c\u306f\\\\n\u3067\u8868\u73fe\uff09\"}`,\n meeting_notes: `\u3042\u306a\u305f\u306f\u55b6\u696d\u8b70\u4e8b\u9332AI\u3067\u3059\u3002\u5546\u8ac7\u30e1\u30e2\u3092\u69cb\u9020\u5316\u3057\u3066\u307e\u3068\u3081\u307e\u3059\u3002\\nJSON: {\"taskType\":\"meeting_notes\",\"title\":\"\",\"date\":\"YYYY-MM-DD\",\"attendees\":[],\"agenda\":[],\"decisions\":[],\"actionItems\":[{\"assignee\":\"\",\"task\":\"\",\"deadline\":\"\"}],\"summary\":\"\"}`,\n proposal: `\u3042\u306a\u305f\u306f\u55b6\u696d\u63d0\u6848\u66f8AI\u3067\u3059\u3002\u30d7\u30ed\u30d5\u30a7\u30c3\u30b7\u30e7\u30ca\u30eb\u306a\u63d0\u6848\u66f8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\\nJSON: {\"taskType\":\"proposal\",\"title\":\"\",\"summary\":\"\",\"content\":\"\"}`,\n quote: `\u3042\u306a\u305f\u306f\u55b6\u696d\u898b\u7a4d\u66f8AI\u3067\u3059\u3002\u898b\u7a4d\u3092\u69cb\u9020\u5316\u3057\u307e\u3059\u3002\\nJSON: {\"taskType\":\"quote\",\"client\":\"\",\"items\":[{\"name\":\"\",\"qty\":1,\"unitPrice\":0}],\"totalAmount\":0,\"notes\":\"\"}`,\n schedule: `\u3042\u306a\u305f\u306f\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u8abf\u6574AI\u3067\u3059\u3002\\nJSON: {\"taskType\":\"schedule\",\"title\":\"\",\"preferredDates\":[\"YYYY-MM-DD\"],\"duration\":60,\"participants\":[],\"notes\":\"\"}`\n};\nconst systemPrompt = prompts[taskMode] ?? prompts.proposal;\nconst messages = [\n { role: 'system', content: systemPrompt },\n { role: 'user', content: rd.input }\n];\nreturn [{ json: { messages, taskMode, useJsonMode: true, department: 'SALES', 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, body: $('Parse Email JSON').item.json.body }) }}"
},
{
"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 Sales. Uses executeWorkflowTrigger, httpRequest, gmail. Event-driven trigger; 9 nodes.
Source: https://github.com/hamahiro1668/org-ai-platform/blob/f36c4297a8e19382d8bbceeac39baf13028094d2/apps/n8n-workflows.bak.1779237077/dept-sales.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.
Splitout Code. Uses manualTrigger, httpRequest, stickyNote, splitOut. Event-driven trigger; 46 nodes.
Automate CSV imports into HubSpot without the mess. Powered by n8n. Supercharged by Pollup AI.
Echo Brand Voice Analysis (Processor) - TASK-074 Dec 10 Fix. Uses formTrigger, httpRequest, executeWorkflowTrigger, moveBinaryData. Event-driven trigger; 40 nodes.
org-ai Dept Analytics. Uses executeWorkflowTrigger, httpRequest, gmail. Event-driven trigger; 9 nodes.
org-ai Dept Accounting. Uses executeWorkflowTrigger, httpRequest, gmail. Event-driven trigger; 9 nodes.