280+ free n8n automation templates — ready-to-use workflows for Gmail, Telegram, Slack, Discord, WhatsApp, Google Drive, Notion, OpenAI, and more. AI agents, RAG chatbots, email automation, social media, DevOps, and document processing. The largest open-source n8n template collection.
HTML ai-agentsai-automationautomationautomation-templatesawesomeawesome-listintegrationlow-coden8nn8n-automationn8n-templateno-code-aino-code-automationself-hostedtelegram-botworkflow-automation
Add order to fulfilment, spend approval and month end close templates
Hamza Jamal Janjuad8dd8e9497d5
diff --git a/Other_Integrations_and_Use_Cases/Process store orders from webhook to supplier, shipping, CRM and ERP with stock checks.json b/Other_Integrations_and_Use_Cases/Process store orders from webhook to supplier, shipping, CRM and ERP with stock checks.jsonnew file mode 100644index 0000000..31f19ae--- /dev/null+++ b/Other_Integrations_and_Use_Cases/Process store orders from webhook to supplier, shipping, CRM and ERP with stock checks.json@@ -0,0 +1,722 @@+{+ "name": "Process store orders from webhook to supplier, shipping, CRM and ERP with stock checks",+ "nodes": [+ {+ "parameters": {+ "content": "## Process store orders from webhook to supplier, shipping, CRM and ERP with stock checks\n\n**Who it is for.** Online stores and trading companies that still update supplier, shipping, CRM and ERP by hand after every order.\n\n**What it does**\n- Verifies the store webhook signature on the raw body, normalises the order and de-duplicates by order id.\n- Checks stock with the supplier. In stock: purchase order, shipping label with tracking, customer email, CRM upsert, ERP inventory update.\n- Out of stock: BACKORDER tag, customer email with the lead time, alert to operations.\n- A scheduled branch syncs ERP inventory to the CRM every six hours and posts a low stock digest.\n- Retries on every API call; bad signatures dropped and alerted; duplicates acknowledged and not re-run.\n\n**Setup**\n1. Set base and the store signing secret in Config, or swap each HTTP Request node for your store, supplier, carrier, CRM and ERP nodes.\n2. Register the Webhook URL as the store's order created webhook.\n3. Activate; the six hourly schedule runs the inventory sync.\n\nAll external systems are reached through HTTP Request nodes against `base` in the Config node, so the whole flow imports and runs against any REST backend; swap any of them for the native n8n node of your system. Built and tested on sample data by Finamatik: https://finamatik.com/work/order-to-fulfilment\n\n**Requirements.** n8n 1.100 or later; for the AI steps, a model endpoint at `base`/llm/complete or the OpenAI or Anthropic node in its place; your own systems reachable over HTTPS.\n\n**How to customise.** Every rule lives in one Code or Config node and is named for what it decides; change the thresholds there, not in the branches.",+ "height": 1000,+ "width": 560,+ "color": 1+ },+ "name": "Read me first",+ "type": "n8n-nodes-base.stickyNote",+ "typeVersion": 1,+ "position": [+ -600,+ 60+ ]+ },+ {+ "parameters": {+ "httpMethod": "POST",+ "path": "shopify-order",+ "responseMode": "lastNode",+ "options": {+ "rawBody": true+ }+ },+ "name": "Webhook: store order paid (Shopify / WooCommerce / Salla)",+ "type": "n8n-nodes-base.webhook",+ "typeVersion": 2,+ "position": [+ 0,+ 300+ ]+ },+ {+ "parameters": {+ "assignments": {+ "assignments": [+ {+ "id": "c1",+ "name": "base",+ "value": "https://api.your-company.example",+ "type": "string"+ },+ {+ "id": "c2",+ "name": "webhook_secret",+ "value": "CHANGE-ME-webhook-secret",+ "type": "string"+ },+ {+ "id": "c3",+ "name": "sku_map",+ "value": "{\"Walnut floating shelf 120x25cm\":\"SHELF-WAL-120\",\"White Oak floating shelf 150x30cm\":\"SHELF-OAK-150\",\"Maple floating shelf 90x25cm\":\"SHELF-MAP-90\"}",+ "type": "string"+ }+ ]+ },+ "includeOtherFields": true,+ "options": {}+ },+ "name": "Config",+ "type": "n8n-nodes-base.set",+ "typeVersion": 3.4,+ "position": [+ 220,+ 300+ ]+ },+ {+ "parameters": {+ "jsCode": "// 1) Verify the store's HMAC signature on the raw body before trusting anything.\nconst crypto = require('crypto');\nconst cfg = $('Config').first().json;\nconst item = $('Webhook: store order paid (Shopify / WooCommerce / Salla)').first();\nconst headers = item.json.headers || {};\nconst raw = item.binary?.data ? Buffer.from(item.binary.data.data, 'base64').toString() : JSON.stringify(item.json.body || {});\nconst expected = crypto.createHmac('sha256', cfg.webhook_secret).update(raw).digest('base64');\nconst given = headers['x-shopify-hmac-sha256'] || headers['x-sample-hmac'] || '';\nif (given !== expected) throw new Error('Webhook signature mismatch, request dropped');\nconst o = item.json.body || JSON.parse(raw);\n// 2) Normalise\nconst map = JSON.parse(cfg.sku_map);\nconst li = (o.line_items || [])[0] || {};\nconst order = {\n order_id: 'SH-' + (o.order_number || o.id), channel: o.channel || 'Shopify',\n customer: [o.customer?.first_name, o.customer?.last_name].filter(Boolean).join(' ') || o.customer?.name || 'Unknown',\n email: (o.email || o.customer?.email || '').toLowerCase(), phone: o.phone || o.customer?.phone || '',\n product: li.title, sku: li.sku || map[li.title] || 'UNMAPPED', qty: Number(li.quantity || 1), amount: Number(o.total_price || 0),\n ship_to: o.shipping_address || {}, base: cfg.base, received_at: new Date().toISOString()\n};\nif (!order.email) throw new Error('Order without customer email');\n// 3) Idempotency: same order id twice = second delivery ignored\nconst seen = $getWorkflowStaticData('global'); seen.orders = seen.orders || {};\norder.duplicate = !!seen.orders[order.order_id]; seen.orders[order.order_id] = Date.now();\nreturn [{ json: order }];"+ },+ "name": "Verify HMAC, normalise, idempotency",+ "type": "n8n-nodes-base.code",+ "typeVersion": 2,+ "position": [+ 440,+ 300+ ]+ },+ {+ "parameters": {+ "conditions": {+ "options": {+ "caseSensitive": true,+ "leftValue": "",+ "typeValidation": "strict"+ },+ "conditions": [+ {+ "id": "d1",+ "leftValue": "={{ $json.duplicate }}",+ "rightValue": true,+ "operator": {+ "type": "boolean",+ "operation": "false"+ }+ }+ ],+ "combinator": "and"+ },+ "options": {}+ },+ "name": "First delivery?",+ "type": "n8n-nodes-base.if",+ "typeVersion": 2,+ "position": [+ 660,+ 300+ ]+ },+ {+ "parameters": {+ "method": "POST",+ "url": "={{ $json.base }}/supplier/stock",+ "sendBody": true,+ "specifyBody": "json",+ "jsonBody": "={{ JSON.stringify({ sku: $json.sku, qty: $json.qty }) }}",+ "options": {}+ },+ "name": "Supplier API: stock check",+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ 900,+ 200+ ],+ "retryOnFail": true,+ "maxTries": 3,+ "waitBetweenTries": 2000+ },+ {+ "parameters": {+ "conditions": {+ "options": {+ "caseSensitive": true,+ "leftValue": "",+ "typeValidation": "strict"+ },+ "conditions": [+ {+ "id": "e1",+ "leftValue": "={{ $json.ok }}",+ "rightValue": true,+ "operator": {+ "type": "boolean",+ "operation": "true"+ }+ }+ ],+ "combinator": "and"+ },+ "options": {}+ },+ "name": "In stock?",+ "type": "n8n-nodes-base.if",+ "typeVersion": 2,+ "position": [+ 1120,+ 200+ ]+ },+ {+ "parameters": {+ "method": "POST",+ "url": "={{ $('Verify HMAC, normalise, idempotency').first().json.base }}/supplier/orders",+ "sendBody": true,+ "specifyBody": "json",+ "jsonBody": "={{ JSON.stringify({ order_id: $('Verify HMAC, normalise, idempotency').first().json.order_id, sku: $('Verify HMAC, normalise, idempotency').first().json.sku, qty: $('Verify HMAC, normalise, idempotency').first().json.qty, ship_to: $('Verify HMAC, normalise, idempotency').first().json.ship_to }) }}",+ "options": {}+ },+ "name": "Supplier API: place PO",+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ 1340,+ 100+ ],+ "retryOnFail": true,+ "maxTries": 3,+ "waitBetweenTries": 2000+ },+ {+ "parameters": {+ "method": "POST",+ "url": "={{ $('Verify HMAC, normalise, idempotency').first().json.base }}/shipping/label",+ "sendBody": true,+ "specifyBody": "json",+ "jsonBody": "={{ JSON.stringify({ order_id: $('Verify HMAC, normalise, idempotency').first().json.order_id, po_number: $json.po_number }) }}",+ "options": {}+ },+ "name": "Shipping API: create label + tracking",+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ 1560,+ 100+ ],+ "retryOnFail": true,+ "maxTries": 3,+ "waitBetweenTries": 2000+ },+ {+ "parameters": {+ "method": "POST",+ "url": "={{ $('Verify HMAC, normalise, idempotency').first().json.base }}/messages/send",+ "sendBody": true,+ "specifyBody": "json",+ "jsonBody": "={{ JSON.stringify({ channel: 'email', to: $('Verify HMAC, normalise, idempotency').first().json.email, body: 'Hi ' + $('Verify HMAC, normalise, idempotency').first().json.customer.split(' ')[0] + ', your ' + $('Verify HMAC, normalise, idempotency').first().json.product + ' is on its way. ' + $json.carrier + ' tracking: ' + $json.tracking }) }}",+ "options": {}+ },+ "name": "Customer: shipping email",+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ 1780,+ 100+ ]+ },+ {+ "parameters": {+ "method": "POST",+ "url": "={{ $('Verify HMAC, normalise, idempotency').first().json.base }}/crm/contacts/upsert",+ "sendBody": true,+ "specifyBody": "json",+ "jsonBody": "={{ JSON.stringify({ email: $('Verify HMAC, normalise, idempotency').first().json.email, name: $('Verify HMAC, normalise, idempotency').first().json.customer, last_order: $('Verify HMAC, normalise, idempotency').first().json.order_id, ltv_add: $('Verify HMAC, normalise, idempotency').first().json.amount, status: 'shipped', tracking: $('Shipping API: create label + tracking').first().json.tracking }) }}",+ "options": {}+ },+ "name": "CRM: upsert customer + order",+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ 2000,+ 100+ ]+ },+ {+ "parameters": {+ "method": "POST",+ "url": "={{ $('Verify HMAC, normalise, idempotency').first().json.base }}/erp/inventory/upsert",+ "sendBody": true,+ "specifyBody": "json",+ "jsonBody": "={{ JSON.stringify({ sku: $('Verify HMAC, normalise, idempotency').first().json.sku, qty: $('Supplier API: stock check').first().json.available - $('Verify HMAC, normalise, idempotency').first().json.qty }) }}",+ "options": {}+ },+ "name": "ERP: inventory sync",+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ 2220,+ 100+ ]+ },+ {+ "parameters": {+ "method": "POST",+ "url": "={{ $('Verify HMAC, normalise, idempotency').first().json.base }}/crm/contacts/upsert",+ "sendBody": true,+ "specifyBody": "json",+ "jsonBody": "={{ JSON.stringify({ email: $('Verify HMAC, normalise, idempotency').first().json.email, name: $('Verify HMAC, normalise, idempotency').first().json.customer, last_order: $('Verify HMAC, normalise, idempotency').first().json.order_id, status: 'backorder', eta_days: $json.lead_days }) }}",+ "options": {}+ },+ "name": "CRM: tag BACKORDER",+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ 1340,+ 360+ ]+ },+ {+ "parameters": {+ "method": "POST",+ "url": "={{ $('Verify HMAC, normalise, idempotency').first().json.base }}/messages/send",+ "sendBody": true,+ "specifyBody": "json",+ "jsonBody": "={{ JSON.stringify({ channel: 'email', to: $('Verify HMAC, normalise, idempotency').first().json.email, body: 'Hi ' + $('Verify HMAC, normalise, idempotency').first().json.customer.split(' ')[0] + ', your ' + $('Verify HMAC, normalise, idempotency').first().json.product + ' is on backorder; current lead time ' + $('Supplier API: stock check').first().json.lead_days + ' days. Reply if you would like to change or cancel.' }) }}",+ "options": {}+ },+ "name": "Customer: backorder email",+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ 1560,+ 360+ ]+ },+ {+ "parameters": {+ "method": "POST",+ "url": "={{ $('Verify HMAC, normalise, idempotency').first().json.base }}/alerts",+ "sendBody": true,+ "specifyBody": "json",+ "jsonBody": "={{ JSON.stringify({ channel: '#ops-backorders', text: 'BACKORDER ' + $('Verify HMAC, normalise, idempotency').first().json.order_id + ' ' + $('Verify HMAC, normalise, idempotency').first().json.sku + ' x' + $('Verify HMAC, normalise, idempotency').first().json.qty + ', supplier lead ' + $('Supplier API: stock check').first().json.lead_days + 'd' }) }}",+ "options": {}+ },+ "name": "Ops alert (Slack)",+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ 1780,+ 360+ ]+ },+ {+ "parameters": {+ "jsCode": "const o = $('Verify HMAC, normalise, idempotency').first().json;\nconst stock = $('Supplier API: stock check').first().json;\nlet tracking = null; try { tracking = $('Shipping API: create label + tracking').first().json.tracking; } catch (e) {}\nreturn [{ json: { ok: true, order_id: o.order_id, sku: o.sku, route: stock.ok ? 'fulfilled' : 'backorder', tracking, lead_days: stock.lead_days } }];"+ },+ "name": "Respond to webhook",+ "type": "n8n-nodes-base.code",+ "typeVersion": 2,+ "position": [+ 2440,+ 300+ ]+ },+ {+ "parameters": {+ "jsCode": "return [{ json: { ok: true, skipped: 'duplicate webhook delivery', order_id: $json.order_id } }];"+ },+ "name": "Skip duplicate delivery",+ "type": "n8n-nodes-base.code",+ "typeVersion": 2,+ "position": [+ 900,+ 480+ ]+ },+ {+ "parameters": {+ "rule": {+ "interval": [+ {+ "field": "hours",+ "hoursInterval": 6+ }+ ]+ }+ },+ "name": "Every 6 h: ERP to CRM inventory sync",+ "type": "n8n-nodes-base.scheduleTrigger",+ "typeVersion": 1.2,+ "position": [+ 0,+ 760+ ]+ },+ {+ "parameters": {+ "method": "GET",+ "url": "={{ $('Config (schedule)').first().json.base }}/erp/inventory",+ "options": {}+ },+ "name": "ERP: read inventory",+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ 440,+ 760+ ]+ },+ {+ "parameters": {+ "jsCode": "const items = $input.first().json.items || [];\nconst low = items.filter(i => i.qty <= 5);\nreturn [{ json: { checked: items.length, low_stock: low, text: low.length ? 'Low stock: ' + low.map(i => i.sku + '=' + i.qty).join(', ') : 'All SKUs above threshold' } }];"+ },+ "name": "Low-stock rule (≤5)",+ "type": "n8n-nodes-base.code",+ "typeVersion": 2,+ "position": [+ 440,+ 760+ ]+ },+ {+ "parameters": {+ "method": "POST",+ "url": "={{ $('Config (schedule)').first().json.base }}/alerts",+ "sendBody": true,+ "specifyBody": "json",+ "jsonBody": "={{ JSON.stringify({ channel: '#ops-inventory', text: $json.text }) }}",+ "options": {}+ },+ "name": "Post inventory digest",+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ 660,+ 760+ ]+ },+ {+ "parameters": {},+ "name": "Error trigger",+ "type": "n8n-nodes-base.errorTrigger",+ "typeVersion": 1,+ "position": [+ 0,+ 1000+ ]+ },+ {+ "parameters": {+ "method": "POST",+ "url": "={{ $('Config (errors)').first().json.base }}/alerts",+ "sendBody": true,+ "specifyBody": "json",+ "jsonBody": "={{ JSON.stringify({ channel: '#ops-alerts', text: 'Order integration failed: ' + ($json.execution?.error?.message || 'unknown') }) }}",+ "options": {}+ },+ "name": "Alert ops",+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ 440,+ 1000+ ]+ },+ {+ "parameters": {+ "assignments": {+ "assignments": [+ {+ "id": "c1",+ "name": "base",+ "value": "https://api.your-company.example",+ "type": "string"+ }+ ]+ },+ "includeOtherFields": true,+ "options": {}+ },+ "name": "Config (schedule)",+ "type": "n8n-nodes-base.set",+ "typeVersion": 3.4,+ "position": [+ 130,+ 760+ ]+ },+ {+ "parameters": {+ "assignments": {+ "assignments": [+ {+ "id": "c1",+ "name": "base",+ "value": "https://api.your-company.example",+ "type": "string"+ }+ ]+ },+ "includeOtherFields": true,+ "options": {}+ },+ "name": "Config (errors)",+ "type": "n8n-nodes-base.set",+ "typeVersion": 3.4,+ "position": [+ 130,+ 1000+ ]+ },+ {+ "parameters": {+ "content": "## Setup in three steps\n\n1. Open **Config** and set `base` (your API root) and `webhook_secret`, or replace each HTTP Request node with the native node for your store, supplier, carrier, CRM and ERP.\n2. Copy the Webhook URL into your store's *order created* webhook.\n3. Activate. The schedule branch syncs inventory every six hours.\n\nTest first with one order that is in stock and one that is not.",+ "height": 300,+ "width": 560,+ "color": 7+ },+ "name": "Setup steps",+ "type": "n8n-nodes-base.stickyNote",+ "typeVersion": 1,+ "position": [+ -600,+ 1080+ ]+ }+ ],+ "connections": {+ "Webhook: store order paid (Shopify / WooCommerce / Salla)": {+ "main": [+ [+ {+ "node": "Config",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Config": {+ "main": [+ [+ {+ "node": "Verify HMAC, normalise, idempotency",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Verify HMAC, normalise, idempotency": {+ "main": [+ [+ {+ "node": "First delivery?",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "First delivery?": {+ "main": [+ [+ {+ "node": "Supplier API: stock check",+ "type": "main",+ "index": 0+ }+ ],+ [+ {+ "node": "Skip duplicate delivery",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Supplier API: stock check": {+ "main": [+ [+ {+ "node": "In stock?",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "In stock?": {+ "main": [+ [+ {+ "node": "Supplier API: place PO",+ "type": "main",+ "index": 0+ }+ ],+ [+ {+ "node": "CRM: tag BACKORDER",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Supplier API: place PO": {+ "main": [+ [+ {+ "node": "Shipping API: create label + tracking",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Shipping API: create label + tracking": {+ "main": [+ [+ {+ "node": "Customer: shipping email",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Customer: shipping email": {+ "main": [+ [+ {+ "node": "CRM: upsert customer + order",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "CRM: upsert customer + order": {+ "main": [+ [+ {+ "node": "ERP: inventory sync",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "ERP: inventory sync": {+ "main": [+ [+ {+ "node": "Respond to webhook",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "CRM: tag BACKORDER": {+ "main": [+ [+ {+ "node": "Customer: backorder email",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Customer: backorder email": {+ "main": [+ [+ {+ "node": "Ops alert (Slack)",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Ops alert (Slack)": {+ "main": [+ [+ {+ "node": "Respond to webhook",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Every 6 h: ERP to CRM inventory sync": {+ "main": [+ [+ {+ "node": "Config (schedule)",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "ERP: read inventory": {+ "main": [+ [+ {+ "node": "Low-stock rule (≤5)",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Low-stock rule (≤5)": {+ "main": [+ [+ {+ "node": "Post inventory digest",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Error trigger": {+ "main": [+ [+ {+ "node": "Config (errors)",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Config (schedule)": {+ "main": [+ [+ {+ "node": "ERP: read inventory",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Config (errors)": {+ "main": [+ [+ {+ "node": "Alert ops",+ "type": "main",+ "index": 0+ }+ ]+ ]+ }+ },+ "settings": {+ "executionOrder": "v1"+ },+ "pinData": {}+}\ No newline at end of filediff --git a/Other_Integrations_and_Use_Cases/Route spend requests to approvers by threshold with deputies, reminders and escalation.json b/Other_Integrations_and_Use_Cases/Route spend requests to approvers by threshold with deputies, reminders and escalation.jsonnew file mode 100644index 0000000..a140784--- /dev/null+++ b/Other_Integrations_and_Use_Cases/Route spend requests to approvers by threshold with deputies, reminders and escalation.json@@ -0,0 +1,927 @@+{+ "name": "Route spend requests to approvers by threshold with deputies, reminders and escalation",+ "nodes": [+ {+ "parameters": {+ "content": "## Route spend requests to approvers by threshold with deputies, reminders and escalation\n\n**Who it is for.** Any company where purchase and expense approvals live in chat threads and nobody can say who approved what.\n\n**What it does**\n- A request arrives from a form, the ERP or Slack. The policy picks the tier by type and amount: under the threshold approved automatically, then manager, director, CEO.\n- Checks who is out of office and routes to the named deputy. A requester can never approve their own request; it escalates instead.\n- Sends the request to the approver and tells the requester where it went and why.\n- A decision callback is validated: only the current approver can decide, and only once. Anyone else gets a 409.\n- An hourly sweep escalates anything past the SLA and logs it.\n\n**Setup**\n1. Edit the policy table (tiers, thresholds, deputies, SLA) in Config.\n2. Set base or replace the HTTP Request nodes with your HR (out of office), Slack or email and ERP nodes.\n3. Point your request form at approval-in and your approve or reject buttons at approval-decision. Activate; the hourly schedule runs the sweep.\n\nAll external systems are reached through HTTP Request nodes against `base` in the Config node, so the whole flow imports and runs against any REST backend; swap any of them for the native n8n node of your system. Built and tested on sample data by Finamatik: https://finamatik.com/work/approval-workflow\n\n**Requirements.** n8n 1.100 or later; for the AI steps, a model endpoint at `base`/llm/complete or the OpenAI or Anthropic node in its place; your own systems reachable over HTTPS.\n\n**How to customise.** Every rule lives in one Code or Config node and is named for what it decides; change the thresholds there, not in the branches.",+ "height": 1000,+ "width": 560,+ "color": 1+ },+ "name": "Read me first",+ "type": "n8n-nodes-base.stickyNote",+ "typeVersion": 1,+ "position": [+ -600,+ -160+ ]+ },+ {+ "parameters": {+ "httpMethod": "POST",+ "path": "approval-in",+ "responseMode": "responseNode",+ "options": {}+ },+ "name": "Webhook: approval request (form, ERP or Slack)",+ "type": "n8n-nodes-base.webhook",+ "typeVersion": 2,+ "position": [+ 0,+ 0+ ]+ },+ {+ "parameters": {+ "assignments": {+ "assignments": [+ {+ "id": "a0",+ "name": "base",+ "value": "https://api.your-company.example",+ "type": "string"+ },+ {+ "id": "a1",+ "name": "policy",+ "value": "{\"purchase\": [{\"max\": 5000, \"approver\": \"auto\"}, {\"max\": 25000, \"approver\": \"[email protected]\"}, {\"max\": 100000, \"approver\": \"[email protected]\"}, {\"max\": null, \"approver\": \"[email protected]\"}], \"expense\": [{\"max\": 1000, \"approver\": \"auto\"}, {\"max\": 10000, \"approver\": \"[email protected]\"}, {\"max\": null, \"approver\": \"[email protected]\"}], \"sla_hours\": 24, \"escalate_to\": \"[email protected]\"}",+ "type": "string"+ },+ {+ "id": "a2",+ "name": "channel",+ "value": "slack",+ "type": "string"+ }+ ]+ },+ "includeOtherFields": true,+ "options": {}+ },+ "name": "Config",+ "type": "n8n-nodes-base.set",+ "typeVersion": 3.4,+ "position": [+ 260,+ 0+ ]+ },+ {+ "parameters": {+ "method": "GET",+ "url": "={{ $('Config').first().json.base }}/hr/out_of_office",+ "options": {}+ },+ "name": "HR: who is out of office",+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ 520,+ 0+ ],+ "retryOnFail": true,+ "maxTries": 3,+ "waitBetweenTries": 2000+ },+ {+ "parameters": {+ "jsCode": "\n// The rule is written down here, in one place, and the workflow applies it the same way every time.\nconst cfg = $('Config').first().json; const policy = JSON.parse(cfg.policy);\nconst req = $('Webhook: approval request (form, ERP or Slack)').first().json.body;\nconst ooo = $json.rows || [];\nconst today = new Date().toISOString().slice(0, 10);\nconst tiers = policy[req.type] || policy.purchase;\nconst tier = tiers.find(t => t.max === null || Number(req.amount) <= t.max);\nlet approver = tier.approver, deputy = null, reason = `${req.type} up to AED ${tier.max ?? 'no limit'} goes to ${tier.approver}`;\nif (approver !== 'auto') {\n const away = ooo.find(o => o.person === approver && o.from <= today && today <= o.to);\n if (away) { deputy = away.deputy; reason += `; ${approver} is out of office until ${away.to}, routed to deputy ${deputy}`; }\n}\nif (req.requester === approver || req.requester === deputy) { approver = policy.escalate_to; deputy = null; reason += '; requester cannot approve own request, escalated'; }\nconst sd = $getWorkflowStaticData('global'); sd.log = sd.log || [];\nconst decision = approver === 'auto' ? 'APPROVED' : 'PENDING';\nconst rec = { request_id: req.request_id || ('REQ-' + Date.now().toString(36).toUpperCase()), type: req.type, amount: Number(req.amount), requester: req.requester, vendor: req.vendor, description: req.description,\n approver: deputy || approver, original_approver: approver, deputy, decision, reason, sla_hours: policy.sla_hours, escalate_to: policy.escalate_to, created_at: new Date().toISOString() };\nsd.log.push({ request_id: rec.request_id, decision, approver: rec.approver, at: rec.created_at });\nreturn [{ json: rec }];\n"+ },+ "name": "Apply policy: threshold, approver, deputy",+ "type": "n8n-nodes-base.code",+ "typeVersion": 2,+ "position": [+ 780,+ 0+ ]+ },+ {+ "parameters": {+ "conditions": {+ "options": {+ "caseSensitive": true,+ "leftValue": "",+ "typeValidation": "loose"+ },+ "conditions": [+ {+ "id": "c",+ "leftValue": "={{ $json.decision }}",+ "rightValue": "APPROVED",+ "operator": {+ "type": "string",+ "operation": "equals"+ }+ }+ ],+ "combinator": "and"+ },+ "options": {}+ },+ "name": "Auto approved?",+ "type": "n8n-nodes-base.if",+ "typeVersion": 2,+ "position": [+ 1040,+ 0+ ]+ },+ {+ "parameters": {+ "method": "POST",+ "url": "={{ $('Config').first().json.base }}/approvals/log",+ "options": {},+ "sendBody": true,+ "specifyBody": "json",+ "jsonBody": "={{ JSON.stringify({ approval_id: $json.request_id, decision: 'APPROVED', by: 'policy', reason: $json.reason, amount: $json.amount, requester: $json.requester }) }}"+ },+ "name": "Approvals: log decision (auto)",+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ 1300,+ -120+ ],+ "retryOnFail": true,+ "maxTries": 3,+ "waitBetweenTries": 2000+ },+ {+ "parameters": {+ "method": "POST",+ "url": "={{ $('Config').first().json.base }}/approvals/request",+ "options": {},+ "sendBody": true,+ "specifyBody": "json",+ "jsonBody": "={{ JSON.stringify({ request_id: $json.request_id, approver: $json.approver, deputy: $json.deputy, amount: $json.amount, type: $json.type, vendor: $json.vendor, description: $json.description, requester: $json.requester, channel: $('Config').first().json.channel, sla_hours: $json.sla_hours }) }}"+ },+ "name": "Send approval request (Slack, email)",+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ 1300,+ 120+ ],+ "retryOnFail": true,+ "maxTries": 3,+ "waitBetweenTries": 2000+ },+ {+ "parameters": {+ "method": "POST",+ "url": "={{ $('Config').first().json.base }}/messages/send",+ "options": {},+ "sendBody": true,+ "specifyBody": "json",+ "jsonBody": "={{ JSON.stringify({ channel: \"email\", to: $(\"Apply policy: threshold, approver, deputy\").first().json.requester, body: \"Request \" + $(\"Apply policy: threshold, approver, deputy\").first().json.request_id + \": \" + ($json.approval_id ? \"sent to \" + $json.sent_to + \" for approval (\" + $(\"Apply policy: threshold, approver, deputy\").first().json.reason + \")\" : \"approved automatically under policy\") }) }}"+ },+ "name": "Notify requester",+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ 1560,+ 0+ ],+ "retryOnFail": true,+ "maxTries": 3,+ "waitBetweenTries": 2000+ },+ {+ "parameters": {+ "jsCode": "\nconst p = $('Apply policy: threshold, approver, deputy').first().json;\nreturn [{ json: { request_id: p.request_id, type: p.type, amount: p.amount, decision: p.decision, approver: p.approver, deputy: p.deputy, reason: p.reason } }];\n"+ },+ "name": "Outcome",+ "type": "n8n-nodes-base.code",+ "typeVersion": 2,+ "position": [+ 1820,+ 0+ ]+ },+ {+ "parameters": {+ "respondWith": "json",+ "responseBody": "={{ JSON.stringify($json) }}",+ "options": {+ "responseCode": 200+ }+ },+ "name": "Respond 200 (request routed)",+ "type": "n8n-nodes-base.respondToWebhook",+ "typeVersion": 1.1,+ "position": [+ 2080,+ 0+ ]+ },+ {+ "parameters": {+ "httpMethod": "POST",+ "path": "approval-decision",+ "responseMode": "responseNode",+ "options": {}+ },+ "name": "Webhook: decision received (Slack button)",+ "type": "n8n-nodes-base.webhook",+ "typeVersion": 2,+ "position": [+ 0,+ 480+ ]+ },+ {+ "parameters": {+ "assignments": {+ "assignments": [+ {+ "id": "a0",+ "name": "base",+ "value": "https://api.your-company.example",+ "type": "string"+ }+ ]+ },+ "includeOtherFields": true,+ "options": {}+ },+ "name": "Config (decisions)",+ "type": "n8n-nodes-base.set",+ "typeVersion": 3.4,+ "position": [+ 260,+ 480+ ]+ },+ {+ "parameters": {+ "jsCode": "\nconst b = $('Webhook: decision received (Slack button)').first().json.body;\nconst sd = $getWorkflowStaticData('global'); sd.log = sd.log || [];\nconst prior = sd.log.find(x => x.request_id === b.request_id);\nif (!prior) return [{ json: { request_id: b.request_id, ok: false, error: 'unknown request' } }];\nif (prior.decision !== 'PENDING') return [{ json: { request_id: b.request_id, ok: false, error: 'already decided: ' + prior.decision } }];\nif (b.decided_by !== prior.approver) return [{ json: { request_id: b.request_id, ok: false, error: `decision from ${b.decided_by} but request is with ${prior.approver}` } }];\nprior.decision = b.decision; prior.decided_by = b.decided_by; prior.decided_at = new Date().toISOString();\nreturn [{ json: { request_id: b.request_id, ok: true, decision: b.decision, decided_by: b.decided_by, comment: b.comment || '' } }];\n"+ },+ "name": "Validate decision",+ "type": "n8n-nodes-base.code",+ "typeVersion": 2,+ "position": [+ 520,+ 480+ ]+ },+ {+ "parameters": {+ "conditions": {+ "options": {+ "caseSensitive": true,+ "leftValue": "",+ "typeValidation": "loose"+ },+ "conditions": [+ {+ "id": "c",+ "leftValue": "={{ $json.ok }}",+ "operator": {+ "type": "boolean",+ "operation": "true",+ "singleValue": true+ }+ }+ ],+ "combinator": "and"+ },+ "options": {}+ },+ "name": "Decision valid?",+ "type": "n8n-nodes-base.if",+ "typeVersion": 2,+ "position": [+ 780,+ 480+ ]+ },+ {+ "parameters": {+ "method": "POST",+ "url": "={{ $('Config (decisions)').first().json.base }}/approvals/log",+ "options": {},+ "sendBody": true,+ "specifyBody": "json",+ "jsonBody": "={{ JSON.stringify({ approval_id: $json.request_id, decision: $json.decision, by: $json.decided_by, comment: $json.comment }) }}"+ },+ "name": "Approvals: log decision",+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ 1040,+ 400+ ],+ "retryOnFail": true,+ "maxTries": 3,+ "waitBetweenTries": 2000+ },+ {+ "parameters": {+ "respondWith": "json",+ "responseBody": "={{ JSON.stringify($('Validate decision').first().json) }}",+ "options": {+ "responseCode": 200+ }+ },+ "name": "Respond 200 (decision recorded)",+ "type": "n8n-nodes-base.respondToWebhook",+ "typeVersion": 1.1,+ "position": [+ 1300,+ 400+ ]+ },+ {+ "parameters": {+ "respondWith": "json",+ "responseBody": "={{ JSON.stringify($json) }}",+ "options": {+ "responseCode": 409+ }+ },+ "name": "Respond 409 (invalid decision)",+ "type": "n8n-nodes-base.respondToWebhook",+ "typeVersion": 1.1,+ "position": [+ 1040,+ 560+ ]+ },+ {+ "parameters": {+ "rule": {+ "interval": [+ {+ "field": "hours",+ "hoursInterval": 1+ }+ ]+ }+ },+ "name": "Schedule: every hour",+ "type": "n8n-nodes-base.scheduleTrigger",+ "typeVersion": 1.2,+ "position": [+ 0,+ 820+ ]+ },+ {+ "parameters": {+ "httpMethod": "POST",+ "path": "approval-sweep",+ "responseMode": "responseNode",+ "options": {}+ },+ "name": "Webhook: run escalation sweep now",+ "type": "n8n-nodes-base.webhook",+ "typeVersion": 2,+ "position": [+ 0,+ 980+ ]+ },+ {+ "parameters": {+ "assignments": {+ "assignments": [+ {+ "id": "a0",+ "name": "base",+ "value": "https://api.your-company.example",+ "type": "string"+ },+ {+ "id": "a1",+ "name": "sla_hours",+ "value": "24",+ "type": "string"+ },+ {+ "id": "a2",+ "name": "force",+ "value": "={{ $json.body && $json.body.force ? 'true' : 'false' }}",+ "type": "string"+ }+ ]+ },+ "includeOtherFields": true,+ "options": {}+ },+ "name": "Config (sweep)",+ "type": "n8n-nodes-base.set",+ "typeVersion": 3.4,+ "position": [+ 260,+ 900+ ]+ },+ {+ "parameters": {+ "method": "GET",+ "url": "={{ $('Config (sweep)').first().json.base }}/approvals/pending",+ "options": {},+ "sendQuery": true,+ "queryParameters": {+ "parameters": [+ {+ "name": "older_than_sec",+ "value": "={{ $json.force === 'true' ? 0 : Number($json.sla_hours) * 3600 }}"+ }+ ]+ }+ },+ "name": "Approvals: pending past SLA",+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ 520,+ 900+ ],+ "retryOnFail": true,+ "maxTries": 3,+ "waitBetweenTries": 2000+ },+ {+ "parameters": {+ "jsCode": "\nconst rows = $json.rows || [];\nconst out = rows.map(a => ({ json: { approval_id: a.id, approver: a.request.approver, escalate_to: a.request.deputy || '[email protected]', amount: a.request.amount, requester: a.request.requester, waited_hours: Math.round((Date.now() / 1000 - a.created) / 36) / 100 } }));\nreturn out.length ? out : [{ json: { none: true } }];\n"+ },+ "name": "Pick overdue requests",+ "type": "n8n-nodes-base.code",+ "typeVersion": 2,+ "position": [+ 780,+ 900+ ]+ },+ {+ "parameters": {+ "conditions": {+ "options": {+ "caseSensitive": true,+ "leftValue": "",+ "typeValidation": "loose"+ },+ "conditions": [+ {+ "id": "c",+ "leftValue": "={{ $json.none === true }}",+ "operator": {+ "type": "boolean",+ "operation": "false",+ "singleValue": true+ }+ }+ ],+ "combinator": "and"+ },+ "options": {}+ },+ "name": "Anything overdue?",+ "type": "n8n-nodes-base.if",+ "typeVersion": 2,+ "position": [+ 1040,+ 900+ ]+ },+ {+ "parameters": {+ "method": "POST",+ "url": "={{ $('Config (sweep)').first().json.base }}/alerts",+ "options": {},+ "sendBody": true,+ "specifyBody": "json",+ "jsonBody": "={{ JSON.stringify({ channel: \"#approvals\", text: \"Escalation: \" + $json.approval_id + \" (AED \" + $json.amount + \" from \" + $json.requester + \") waited \" + $json.waited_hours + \" h with \" + $json.approver + \", now with \" + $json.escalate_to }) }}"+ },+ "name": "Escalate to deputy or CEO (Slack)",+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ 1300,+ 820+ ],+ "retryOnFail": true,+ "maxTries": 3,+ "waitBetweenTries": 2000+ },+ {+ "parameters": {+ "method": "POST",+ "url": "={{ $('Config (sweep)').first().json.base }}/approvals/log",+ "options": {},+ "sendBody": true,+ "specifyBody": "json",+ "jsonBody": "={{ JSON.stringify({ approval_id: $('Pick overdue requests').item.json.approval_id, decision: 'pending', escalated_to: $('Pick overdue requests').item.json.escalate_to, by: 'sla-sweep' }) }}"+ },+ "name": "Approvals: log escalation",+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ 1560,+ 820+ ],+ "retryOnFail": true,+ "maxTries": 3,+ "waitBetweenTries": 2000+ },+ {+ "parameters": {+ "jsCode": "\nconst items = $input.all().map(i => i.json);\nreturn [{ json: { escalated: items.filter(i => i.approval_id).length, ids: items.map(i => i.approval_id).filter(Boolean) } }];\n"+ },+ "name": "Sweep summary",+ "type": "n8n-nodes-base.code",+ "typeVersion": 2,+ "position": [+ 1820,+ 900+ ]+ },+ {+ "parameters": {+ "respondWith": "json",+ "responseBody": "={{ JSON.stringify($json) }}",+ "options": {+ "responseCode": 200+ }+ },+ "name": "Respond 200 (sweep done)",+ "type": "n8n-nodes-base.respondToWebhook",+ "typeVersion": 1.1,+ "position": [+ 2080,+ 900+ ]+ },+ {+ "parameters": {},+ "name": "Error trigger",+ "type": "n8n-nodes-base.errorTrigger",+ "typeVersion": 1,+ "position": [+ 0,+ 1220+ ]+ },+ {+ "parameters": {+ "assignments": {+ "assignments": [+ {+ "id": "a0",+ "name": "base",+ "value": "https://api.your-company.example",+ "type": "string"+ }+ ]+ },+ "includeOtherFields": true,+ "options": {}+ },+ "name": "Config (errors)",+ "type": "n8n-nodes-base.set",+ "typeVersion": 3.4,+ "position": [+ 260,+ 1220+ ]+ },+ {+ "parameters": {+ "method": "POST",+ "url": "={{ $('Config (errors)').first().json.base }}/alerts",+ "options": {},+ "sendBody": true,+ "specifyBody": "json",+ "jsonBody": "={{ JSON.stringify({ channel: \"#ops-alerts\", text: \"Approvals workflow failed: \" + ($json.execution?.error?.message || \"unknown\") }) }}"+ },+ "name": "Alert ops (Slack)",+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ 520,+ 1220+ ],+ "retryOnFail": true,+ "maxTries": 3,+ "waitBetweenTries": 2000+ },+ {+ "parameters": {+ "content": "## Setup in three steps\n\n1. Open **Config** and set `base`, the approval thresholds and the approver and deputy list.\n2. Connect the request source (form, ERP or chat) to the Webhook URL.\n3. Activate. The schedule branch sends reminders and escalates overdue approvals.\n\nTest with one request under the threshold and one above it.",+ "height": 300,+ "width": 560,+ "color": 7+ },+ "name": "Setup steps",+ "type": "n8n-nodes-base.stickyNote",+ "typeVersion": 1,+ "position": [+ -600,+ 860+ ]+ }+ ],+ "connections": {+ "Webhook: approval request (form, ERP or Slack)": {+ "main": [+ [+ {+ "node": "Config",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Config": {+ "main": [+ [+ {+ "node": "HR: who is out of office",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "HR: who is out of office": {+ "main": [+ [+ {+ "node": "Apply policy: threshold, approver, deputy",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Apply policy: threshold, approver, deputy": {+ "main": [+ [+ {+ "node": "Auto approved?",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Auto approved?": {+ "main": [+ [+ {+ "node": "Approvals: log decision (auto)",+ "type": "main",+ "index": 0+ }+ ],+ [+ {+ "node": "Send approval request (Slack, email)",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Approvals: log decision (auto)": {+ "main": [+ [+ {+ "node": "Notify requester",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Send approval request (Slack, email)": {+ "main": [+ [+ {+ "node": "Notify requester",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Notify requester": {+ "main": [+ [+ {+ "node": "Outcome",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Outcome": {+ "main": [+ [+ {+ "node": "Respond 200 (request routed)",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Webhook: decision received (Slack button)": {+ "main": [+ [+ {+ "node": "Config (decisions)",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Config (decisions)": {+ "main": [+ [+ {+ "node": "Validate decision",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Validate decision": {+ "main": [+ [+ {+ "node": "Decision valid?",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Decision valid?": {+ "main": [+ [+ {+ "node": "Approvals: log decision",+ "type": "main",+ "index": 0+ }+ ],+ [+ {+ "node": "Respond 409 (invalid decision)",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Approvals: log decision": {+ "main": [+ [+ {+ "node": "Respond 200 (decision recorded)",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Schedule: every hour": {+ "main": [+ [+ {+ "node": "Config (sweep)",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Webhook: run escalation sweep now": {+ "main": [+ [+ {+ "node": "Config (sweep)",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Config (sweep)": {+ "main": [+ [+ {+ "node": "Approvals: pending past SLA",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Approvals: pending past SLA": {+ "main": [+ [+ {+ "node": "Pick overdue requests",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Pick overdue requests": {+ "main": [+ [+ {+ "node": "Anything overdue?",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Anything overdue?": {+ "main": [+ [+ {+ "node": "Escalate to deputy or CEO (Slack)",+ "type": "main",+ "index": 0+ }+ ],+ [+ {+ "node": "Sweep summary",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Escalate to deputy or CEO (Slack)": {+ "main": [+ [+ {+ "node": "Approvals: log escalation",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Approvals: log escalation": {+ "main": [+ [+ {+ "node": "Sweep summary",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Sweep summary": {+ "main": [+ [+ {+ "node": "Respond 200 (sweep done)",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Error trigger": {+ "main": [+ [+ {+ "node": "Config (errors)",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Config (errors)": {+ "main": [+ [+ {+ "node": "Alert ops (Slack)",+ "type": "main",+ "index": 0+ }+ ]+ ]+ }+ },+ "settings": {+ "executionOrder": "v1"+ },+ "pinData": {}+}\ No newline at end of filediff --git a/Other_Integrations_and_Use_Cases/Run month end close checks and send a management pack with AI commentary.json b/Other_Integrations_and_Use_Cases/Run month end close checks and send a management pack with AI commentary.jsonnew file mode 100644index 0000000..d532ac6--- /dev/null+++ b/Other_Integrations_and_Use_Cases/Run month end close checks and send a management pack with AI commentary.json@@ -0,0 +1,654 @@+{+ "name": "Run month end close checks and send a management pack with AI commentary",+ "nodes": [+ {+ "parameters": {+ "content": "## Run month end close checks and send a management pack with AI commentary\n\n**Who it is for.** Finance teams closing the month by hand from a trial balance and a checklist.\n\n**What it does**\n- Runs on the second working day or on demand. Pulls this month's and last month's trial balance and the close data.\n- Seven checks against a materiality figure: trial balance balances, bank reconciled, invoices posted, suspense cleared, VAT control agrees, fixed asset register agrees, receivables over 90 days reviewed.\n- Builds the P&L against last month with the change on every line; an AI step drafts the commentary from the figures and the check results.\n- Renders the management pack and distributes it, or BLOCKS the close and sends the failed checks instead.\n\n**Setup**\n1. Set base, period and materiality in Config, or replace the HTTP Request nodes with your accounting system (Zoho Books, QuickBooks Online, Xero) nodes.\n2. Set the AI credential on the commentary step. Point distribution at your email or Slack node.\n3. Activate; the schedule runs on the second working day.\n\nAll external systems are reached through HTTP Request nodes against `base` in the Config node, so the whole flow imports and runs against any REST backend; swap any of them for the native n8n node of your system. Built and tested on sample data by Finamatik: https://finamatik.com/work/month-end-close-pack\n\n**Requirements.** n8n 1.100 or later; for the AI steps, a model endpoint at `base`/llm/complete or the OpenAI or Anthropic node in its place; your own systems reachable over HTTPS.\n\n**How to customise.** Every rule lives in one Code or Config node and is named for what it decides; change the thresholds there, not in the branches.",+ "height": 1000,+ "width": 560,+ "color": 1+ },+ "name": "Read me first",+ "type": "n8n-nodes-base.stickyNote",+ "typeVersion": 1,+ "position": [+ -600,+ -80+ ]+ },+ {+ "parameters": {+ "rule": {+ "interval": [+ {+ "field": "cronExpression",+ "expression": "0 8 2 * *"+ }+ ]+ }+ },+ "name": "Schedule: 2nd working day 08:00",+ "type": "n8n-nodes-base.scheduleTrigger",+ "typeVersion": 1.2,+ "position": [+ 0,+ 0+ ]+ },+ {+ "parameters": {+ "httpMethod": "POST",+ "path": "close-run",+ "responseMode": "responseNode",+ "options": {}+ },+ "name": "Webhook: run close now",+ "type": "n8n-nodes-base.webhook",+ "typeVersion": 2,+ "position": [+ 0,+ 160+ ]+ },+ {+ "parameters": {+ "assignments": {+ "assignments": [+ {+ "id": "a0",+ "name": "base",+ "value": "https://api.your-company.example",+ "type": "string"+ },+ {+ "id": "a1",+ "name": "period",+ "value": "2026-08",+ "type": "string"+ },+ {+ "id": "a2",+ "name": "finance_channel",+ "value": "#finance-close",+ "type": "string"+ },+ {+ "id": "a3",+ "name": "owner_email",+ "value": "[email protected]",+ "type": "string"+ },+ {+ "id": "a4",+ "name": "materiality_aed",+ "value": "5000",+ "type": "string"+ }+ ]+ },+ "includeOtherFields": true,+ "options": {}+ },+ "name": "Config",+ "type": "n8n-nodes-base.set",+ "typeVersion": 3.4,+ "position": [+ 260,+ 80+ ]+ },+ {+ "parameters": {+ "method": "GET",+ "url": "={{ $('Config').first().json.base }}/accounting/trial_balance",+ "options": {},+ "sendQuery": true,+ "queryParameters": {+ "parameters": [+ {+ "name": "period",+ "value": "={{ $json.period }}"+ }+ ]+ }+ },+ "name": "Accounting: trial balance",+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ 520,+ -40+ ],+ "retryOnFail": true,+ "maxTries": 3,+ "waitBetweenTries": 2000+ },+ {+ "parameters": {+ "method": "GET",+ "url": "={{ $('Config').first().json.base }}/accounting/prior_period",+ "options": {}+ },+ "name": "Accounting: prior period",+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ 520,+ 80+ ],+ "retryOnFail": true,+ "maxTries": 3,+ "waitBetweenTries": 2000+ },+ {+ "parameters": {+ "method": "GET",+ "url": "={{ $('Config').first().json.base }}/accounting/close_checks",+ "options": {},+ "sendQuery": true,+ "queryParameters": {+ "parameters": [+ {+ "name": "period",+ "value": "={{ $json.period }}"+ }+ ]+ }+ },+ "name": "Accounting: close checks",+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ 520,+ 200+ ],+ "retryOnFail": true,+ "maxTries": 3,+ "waitBetweenTries": 2000+ },+ {+ "parameters": {+ "numberInputs": 3+ },+ "name": "Merge sources",+ "type": "n8n-nodes-base.merge",+ "typeVersion": 3,+ "position": [+ 780,+ 80+ ]+ },+ {+ "parameters": {+ "jsCode": "\n// Everything a close reviewer would tick off by hand, decided by rule. Materiality from Config.\nconst cfg = $('Config').first().json;\nconst mat = Number(cfg.materiality_aed);\nconst tb = $('Accounting: trial balance').first().json.rows;\nconst prior = $('Accounting: prior period').first().json.rows;\nconst chk = $('Accounting: close checks').first().json;\nconst num = v => Number(String(v || '0').replace(/,/g, ''));\nconst checks = [];\nconst dr = tb.reduce((s, r) => s + num(r.debit), 0), cr = tb.reduce((s, r) => s + num(r.credit), 0);\nchecks.push({ check: 'Trial balance balances', result: Math.abs(dr - cr) < 1 ? 'PASS' : 'FAIL', detail: `Dr ${dr.toFixed(0)} / Cr ${cr.toFixed(0)}` });\nconst bu = chk.bank_unreconciled || [];\nconst oldBank = bu.filter(x => num(x.days_open) > 5);\nchecks.push({ check: 'Bank reconciled', result: oldBank.length ? 'FAIL' : bu.length ? 'WARN' : 'PASS', detail: `${bu.length} open items, ${oldBank.length} older than 5 days` });\nconst up = chk.unposted_invoices || [];\nconst upTotal = up.reduce((s, x) => s + num(x.amount), 0);\nchecks.push({ check: 'Supplier invoices posted', result: upTotal > mat ? 'FAIL' : up.length ? 'WARN' : 'PASS', detail: `${up.length} unposted, AED ${upTotal.toFixed(0)}` });\nchecks.push({ check: 'Suspense cleared', result: num(chk.suspense_balance) === 0 ? 'PASS' : num(chk.suspense_balance) > mat ? 'FAIL' : 'WARN', detail: `AED ${num(chk.suspense_balance).toFixed(0)} in suspense` });\nconst vat = chk.vat_control || {};\nchecks.push({ check: 'VAT control agrees to return', result: vat.return_filed ? 'PASS' : 'WARN', detail: `Output ${num(vat.output_vat).toFixed(0)}, input ${num(vat.input_vat).toFixed(0)}, net ${(num(vat.output_vat) - num(vat.input_vat)).toFixed(0)}; return ${vat.return_filed ? 'filed' : 'not yet filed'}` });\nchecks.push({ check: 'Fixed asset register agrees to GL', result: num(chk.fixed_asset_register_total) === num(chk.gl_fixed_assets) ? 'PASS' : 'FAIL', detail: `Register ${num(chk.fixed_asset_register_total).toFixed(0)} vs GL ${num(chk.gl_fixed_assets).toFixed(0)}` });\nconst ar90 = chk.aged_receivables_over_90 || [];\nconst ar90Total = ar90.reduce((s, x) => s + num(x.amount), 0);\nchecks.push({ check: 'Receivables over 90 days reviewed', result: ar90Total > mat ? 'WARN' : 'PASS', detail: `${ar90.length} invoices, AED ${ar90Total.toFixed(0)} over 90 days` });\n// P&L lines, this month vs prior, from the two trial balances (credits negative)\nconst bal = rows => { const m = {}; for (const r of rows) { const k = r.account.slice(0, 1); const v = num(r.debit) - num(r.credit); m[r.name] = (m[r.name] || 0) + v; } return m; };\nconst cur = bal(tb), prv = bal(prior);\nconst plNames = tb.filter(r => /^[4-8]/.test(r.account)).map(r => r.name).filter((v, i, a) => a.indexOf(v) === i);\nconst pl = plNames.map(n => { const c = -(cur[n] || 0), p = -(prv[n] || 0); const isRev = /revenue/i.test(n); const cc = isRev ? c : -c, pp = isRev ? p : -p; return { line: n, current: Math.round(cc), prior: Math.round(pp), change: Math.round(cc - pp), change_pct: pp ? Math.round(1000 * (cc - pp) / Math.abs(pp)) / 10 : null }; });\nconst revenue = pl.find(x => /revenue/i.test(x.line)) || { current: 0, prior: 0 };\nconst costs = pl.filter(x => !/revenue/i.test(x.line)).reduce((s, x) => s + x.current, 0);\nconst costsPrior = pl.filter(x => !/revenue/i.test(x.line)).reduce((s, x) => s + x.prior, 0);\nconst fails = checks.filter(c => c.result === 'FAIL').length, warns = checks.filter(c => c.result === 'WARN').length;\nreturn [{ json: { period: cfg.period, checks, pl, fails, warns, revenue: revenue.current, revenue_prior: revenue.prior, costs, costs_prior: costsPrior,\n profit: revenue.current - costs, profit_prior: revenue.prior - costsPrior, status: fails ? 'BLOCKED' : warns ? 'READY WITH NOTES' : 'READY' } }];\n"+ },+ "name": "Run close checks",+ "type": "n8n-nodes-base.code",+ "typeVersion": 2,+ "position": [+ 1040,+ 80+ ]+ },+ {+ "parameters": {+ "method": "POST",+ "url": "={{ $('Config').first().json.base }}/llm/complete",+ "options": {},+ "sendBody": true,+ "specifyBody": "json",+ "jsonBody": "={{ JSON.stringify({ task: \"close_commentary\", input: { period: $json.period, revenue: $json.revenue, revenue_prior: $json.revenue_prior, costs: $json.costs, costs_prior: $json.costs_prior, profit: $json.profit, profit_prior: $json.profit_prior, pl: $json.pl, checks: $json.checks } }) }}"+ },+ "name": "AI: draft commentary",+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ 1300,+ 80+ ],+ "retryOnFail": true,+ "maxTries": 3,+ "waitBetweenTries": 2000+ },+ {+ "parameters": {+ "jsCode": "\nconst r = $('Run close checks').first().json;\nconst ai = $json.output || {};\nconst lines = Array.isArray(ai.commentary) ? ai.commentary : (typeof ai === 'string' ? ai.split('\\n') : [\n `Revenue AED ${r.revenue.toLocaleString()} against AED ${r.revenue_prior.toLocaleString()} last month.`,\n `Operating costs AED ${r.costs.toLocaleString()} (prior AED ${r.costs_prior.toLocaleString()}).`,\n `Profit AED ${r.profit.toLocaleString()} (prior AED ${r.profit_prior.toLocaleString()}).`]);\nconst biggest = [...r.pl].filter(x => x.change_pct !== null).sort((a, b) => Math.abs(b.change) - Math.abs(a.change)).slice(0, 3)\n .map(x => `${x.line}: ${x.change >= 0 ? 'up' : 'down'} AED ${Math.abs(x.change).toLocaleString()} (${x.change_pct}%) on last month`);\nreturn [{ json: { period: r.period, status: r.status, fails: r.fails, warns: r.warns, checks: r.checks, pl: r.pl,\n commentary: [...lines, 'Largest movements:', ...biggest, 'Every figure above is traceable to the trial balance export attached to this run.'] } }];\n"+ },+ "name": "Assemble pack",+ "type": "n8n-nodes-base.code",+ "typeVersion": 2,+ "position": [+ 1560,+ 80+ ]+ },+ {+ "parameters": {+ "method": "POST",+ "url": "={{ $('Config').first().json.base }}/reports/pack",+ "options": {},+ "sendBody": true,+ "specifyBody": "json",+ "jsonBody": "={{ JSON.stringify($json) }}"+ },+ "name": "Render management pack (xlsx)",+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ 1820,+ 80+ ],+ "retryOnFail": true,+ "maxTries": 3,+ "waitBetweenTries": 2000+ },+ {+ "parameters": {+ "conditions": {+ "options": {+ "caseSensitive": true,+ "leftValue": "",+ "typeValidation": "loose"+ },+ "conditions": [+ {+ "id": "c",+ "leftValue": "={{ $('Assemble pack').first().json.fails }}",+ "rightValue": 0,+ "operator": {+ "type": "number",+ "operation": "gt"+ }+ }+ ],+ "combinator": "and"+ },+ "options": {}+ },+ "name": "Any check failed?",+ "type": "n8n-nodes-base.if",+ "typeVersion": 2,+ "position": [+ 2080,+ 80+ ]+ },+ {+ "parameters": {+ "method": "POST",+ "url": "={{ $('Config').first().json.base }}/alerts",+ "options": {},+ "sendBody": true,+ "specifyBody": "json",+ "jsonBody": "={{ JSON.stringify({ channel: $(\"Config\").first().json.finance_channel, text: \"Close \" + $(\"Assemble pack\").first().json.period + \" BLOCKED: \" + $(\"Assemble pack\").first().json.checks.filter(c => c.result === \"FAIL\").map(c => c.check + \" (\" + c.detail + \")\").join(\"; \") + \". Draft pack: \" + $json.url }) }}"+ },+ "name": "Slack: close blocked, owners tagged",+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ 2340,+ -20+ ],+ "retryOnFail": true,+ "maxTries": 3,+ "waitBetweenTries": 2000+ },+ {+ "parameters": {+ "method": "POST",+ "url": "={{ $('Config').first().json.base }}/alerts",+ "options": {},+ "sendBody": true,+ "specifyBody": "json",+ "jsonBody": "={{ JSON.stringify({ channel: $(\"Config\").first().json.finance_channel, text: \"Close \" + $(\"Assemble pack\").first().json.period + \" \" + $(\"Assemble pack\").first().json.status + \". Pack: \" + $json.url + \". Notes: \" + $(\"Assemble pack\").first().json.checks.filter(c => c.result === \"WARN\").map(c => c.check).join(\", \") }) }}"+ },+ "name": "Slack: pack ready",+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ 2340,+ 100+ ],+ "retryOnFail": true,+ "maxTries": 3,+ "waitBetweenTries": 2000+ },+ {+ "parameters": {+ "method": "POST",+ "url": "={{ $('Config').first().json.base }}/messages/send",+ "options": {},+ "sendBody": true,+ "specifyBody": "json",+ "jsonBody": "={{ JSON.stringify({ channel: \"email\", to: $(\"Config\").first().json.owner_email, body: \"Management pack \" + $(\"Assemble pack\").first().json.period + \" attached. \" + $(\"Assemble pack\").first().json.commentary.join(\" \"), attachment: $(\"Render management pack (xlsx)\").first().json.url }) }}"+ },+ "name": "Email pack to owner",+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ 2600,+ 100+ ],+ "retryOnFail": true,+ "maxTries": 3,+ "waitBetweenTries": 2000+ },+ {+ "parameters": {+ "jsCode": "\nconst a = $('Assemble pack').first().json; const pack = $('Render management pack (xlsx)').first().json;\nreturn [{ json: { period: a.period, status: a.status, checks: a.checks.map(c => c.check + ': ' + c.result), pack_url: pack.url, pack_sheets: pack.sheets } }];\n"+ },+ "name": "Run summary",+ "type": "n8n-nodes-base.code",+ "typeVersion": 2,+ "position": [+ 2860,+ 40+ ]+ },+ {+ "parameters": {+ "respondWith": "json",+ "responseBody": "={{ JSON.stringify($json) }}",+ "options": {+ "responseCode": 200+ }+ },+ "name": "Respond 200 (close run)",+ "type": "n8n-nodes-base.respondToWebhook",+ "typeVersion": 1.1,+ "position": [+ 3120,+ 40+ ]+ },+ {+ "parameters": {},+ "name": "Error trigger",+ "type": "n8n-nodes-base.errorTrigger",+ "typeVersion": 1,+ "position": [+ 0,+ 420+ ]+ },+ {+ "parameters": {+ "assignments": {+ "assignments": [+ {+ "id": "a0",+ "name": "base",+ "value": "https://api.your-company.example",+ "type": "string"+ }+ ]+ },+ "includeOtherFields": true,+ "options": {}+ },+ "name": "Config (errors)",+ "type": "n8n-nodes-base.set",+ "typeVersion": 3.4,+ "position": [+ 260,+ 420+ ]+ },+ {+ "parameters": {+ "method": "POST",+ "url": "={{ $('Config (errors)').first().json.base }}/alerts",+ "options": {},+ "sendBody": true,+ "specifyBody": "json",+ "jsonBody": "={{ JSON.stringify({ channel: \"#ops-alerts\", text: \"Close workflow failed: \" + ($json.execution?.error?.message || \"unknown\") }) }}"+ },+ "name": "Alert ops (Slack)",+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ 520,+ 420+ ],+ "retryOnFail": true,+ "maxTries": 3,+ "waitBetweenTries": 2000+ },+ {+ "parameters": {+ "content": "## Setup in three steps\n\n1. Open **Config** and set `base` and the ledger, AR and AP endpoints, or swap the HTTP Request nodes for your accounting system's nodes.\n2. Point the commentary step at your model endpoint (`base`/llm/complete) or swap it for the OpenAI or Anthropic node.\n3. Set the schedule to your close day and activate.\n\nRun it once on last month's data and compare the pack with the one you produced by hand.",+ "height": 300,+ "width": 560,+ "color": 7+ },+ "name": "Setup steps",+ "type": "n8n-nodes-base.stickyNote",+ "typeVersion": 1,+ "position": [+ -600,+ 940+ ]+ }+ ],+ "connections": {+ "Schedule: 2nd working day 08:00": {+ "main": [+ [+ {+ "node": "Config",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Webhook: run close now": {+ "main": [+ [+ {+ "node": "Config",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Config": {+ "main": [+ [+ {+ "node": "Accounting: trial balance",+ "type": "main",+ "index": 0+ },+ {+ "node": "Accounting: prior period",+ "type": "main",+ "index": 0+ },+ {+ "node": "Accounting: close checks",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Accounting: trial balance": {+ "main": [+ [+ {+ "node": "Merge sources",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Accounting: prior period": {+ "main": [+ [+ {+ "node": "Merge sources",+ "type": "main",+ "index": 1+ }+ ]+ ]+ },+ "Accounting: close checks": {+ "main": [+ [+ {+ "node": "Merge sources",+ "type": "main",+ "index": 2+ }+ ]+ ]+ },+ "Merge sources": {+ "main": [+ [+ {+ "node": "Run close checks",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Run close checks": {+ "main": [+ [+ {+ "node": "AI: draft commentary",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "AI: draft commentary": {+ "main": [+ [+ {+ "node": "Assemble pack",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Assemble pack": {+ "main": [+ [+ {+ "node": "Render management pack (xlsx)",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Render management pack (xlsx)": {+ "main": [+ [+ {+ "node": "Any check failed?",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Any check failed?": {+ "main": [+ [+ {+ "node": "Slack: close blocked, owners tagged",+ "type": "main",+ "index": 0+ }+ ],+ [+ {+ "node": "Slack: pack ready",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Slack: close blocked, owners tagged": {+ "main": [+ [+ {+ "node": "Run summary",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Slack: pack ready": {+ "main": [+ [+ {+ "node": "Email pack to owner",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Email pack to owner": {+ "main": [+ [+ {+ "node": "Run summary",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Run summary": {+ "main": [+ [+ {+ "node": "Respond 200 (close run)",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Error trigger": {+ "main": [+ [+ {+ "node": "Config (errors)",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Config (errors)": {+ "main": [+ [+ {+ "node": "Alert ops (Slack)",+ "type": "main",+ "index": 0+ }+ ]+ ]+ }+ },+ "settings": {+ "executionOrder": "v1"+ },+ "pinData": {}+}\ No newline at end of file