AutomationFlowsEmail & Gmail › Org-ai Dept Accounting

Org-ai Dept Accounting

org-ai Dept Accounting. Uses executeWorkflowTrigger, httpRequest, gmail. Event-driven trigger; 9 nodes.

Event trigger★★★★☆ complexity9 nodesExecute Workflow TriggerHTTP RequestGmail
Email & Gmail Trigger: Event Nodes: 9 Complexity: ★★★★☆ Added:

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 →

Download .json
{
  "name": "org-ai Dept Accounting",
  "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": "\u7d4c\u7406\u90e8 (Accounting) \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 = 'expense_report';\nif (kw(['\u30e1\u30fc\u30eb','email','mail','\u9001\u4fe1','\u901a\u77e5'])) taskMode = 'email';\nelse if (kw(['\u8acb\u6c42\u66f8','\u30a4\u30f3\u30dc\u30a4\u30b9','invoice'])) taskMode = 'invoice_check';\nelse if (kw(['\u9818\u53ce\u66f8','\u30ec\u30b7\u30fc\u30c8','receipt'])) taskMode = 'receipt_summary';\nelse if (kw(['\u7d4c\u8cbb\u30ec\u30dd\u30fc\u30c8','\u6708\u6b21','\u4e88\u7b97','expense'])) taskMode = 'expense_report';\n\nconst prompts = {\n  email: `\u3042\u306a\u305f\u306f\u7d4c\u7406\u90e8\u306e\u30e1\u30fc\u30ebAI\u3067\u3059\u3002\u8acb\u6c42/\u652f\u6255\u3044/\u7d4c\u8cbb\u306b\u95a2\u3059\u308b\u4e8b\u52d9\u30e1\u30fc\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\\nJSON: {\"taskType\":\"email\",\"to\":\"\",\"cc\":\"\",\"subject\":\"\",\"body\":\"\"}`,\n  invoice_check: `\u3042\u306a\u305f\u306f\u7d4c\u7406AI\u3067\u3059\u3002\u8acb\u6c42\u66f8\u30c1\u30a7\u30c3\u30af\u7d50\u679c\u3092\u6574\u7406\u3057\u3066\u304f\u3060\u3055\u3044\u3002\\nJSON: {\"taskType\":\"invoice_check\",\"title\":\"\",\"receipts\":[{\"date\":\"YYYY-MM-DD\",\"vendor\":\"\",\"amount\":0,\"category\":\"\"}],\"totalAmount\":0,\"summary\":\"\"}`,\n  receipt_summary: `\u3042\u306a\u305f\u306f\u7d4c\u7406AI\u3067\u3059\u3002\u9818\u53ce\u66f8\u3092\u307e\u3068\u3081\u307e\u3059\u3002\\nJSON: {\"taskType\":\"receipt_summary\",\"receipts\":[{\"date\":\"YYYY-MM-DD\",\"vendor\":\"\",\"amount\":0,\"category\":\"\"}],\"totalAmount\":0,\"summary\":\"\"}`,\n  expense_report: `\u3042\u306a\u305f\u306f\u7d4c\u7406AI\u3067\u3059\u3002\u6708\u6b21\u7d4c\u8cbb\u30ec\u30dd\u30fc\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\\nJSON: {\"taskType\":\"expense_report\",\"title\":\"\",\"receipts\":[{\"date\":\"YYYY-MM-DD\",\"vendor\":\"\",\"amount\":0,\"category\":\"\"}],\"totalAmount\":0,\"summary\":\"\"}`\n};\nconst systemPrompt = prompts[taskMode] ?? prompts.expense_report;\nconst messages = [\n  { role: 'system', content: systemPrompt },\n  { role: 'user', content: rd.input }\n];\nreturn [{ json: { messages, taskMode, useJsonMode: true, department: 'ACCOUNTING', 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
}
Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

org-ai Dept Accounting. 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-accounting.json — original creator credit. Request a take-down →

More Email & Gmail workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Email & Gmail

Splitout Code. Uses manualTrigger, httpRequest, stickyNote, splitOut. Event-driven trigger; 46 nodes.

HTTP Request, Execute Workflow Trigger, Gmail +1
Email & Gmail

Automate CSV imports into HubSpot without the mess. Powered by n8n. Supercharged by Pollup AI.

HTTP Request, Execute Workflow Trigger, Gmail +1
Email & Gmail

Echo Brand Voice Analysis (Processor) - TASK-074 Dec 10 Fix. Uses formTrigger, httpRequest, executeWorkflowTrigger, moveBinaryData. Event-driven trigger; 40 nodes.

Form Trigger, HTTP Request, Execute Workflow Trigger +2
Email & Gmail

org-ai Dept Sales. Uses executeWorkflowTrigger, httpRequest, gmail. Event-driven trigger; 9 nodes.

Execute Workflow Trigger, HTTP Request, Gmail
Email & Gmail

org-ai Dept Analytics. Uses executeWorkflowTrigger, httpRequest, gmail. Event-driven trigger; 9 nodes.

Execute Workflow Trigger, HTTP Request, Gmail