{
  "name": "Slack approval gate before a task is created",
  "nodes": [
    {
      "parameters": {
        "content": "## Slack approval gate before a task is created\n\nPortfolio demo only. This workflow is an original example for demonstration. It is not client work and it does not represent a deployment for any customer.\n\nRun **Run demo** to execute the offline rules engine. The live branch is used only when the incoming item sets `demo` to false and the placeholder credentials have been replaced.",
        "height": 220,
        "width": 520,
        "color": 4
      },
      "id": "af0a53b5-b764-4e3e-86db-3a6b28553552",
      "name": "Overview",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -40,
        -40
      ]
    },
    {
      "parameters": {},
      "id": "da05b4af-d806-4da8-b1e3-7dc8c3d1f10f",
      "name": "Run demo",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        40,
        280
      ],
      "notes": "CLI and the n8n editor start here. An empty manual run loads the bundled sample.",
      "notesInFlow": true
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "slack-approval-gate",
        "authentication": "none",
        "responseMode": "lastNode",
        "responseData": "firstEntryJson",
        "options": {}
      },
      "id": "f933b448-67eb-4d0f-ad55-e87f5c6eab74",
      "name": "Inbound webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        40,
        460
      ],
      "notes": "POST JSON to this path. Include demo:false only after credentials are connected.",
      "notesInFlow": true,
      "webhookId": "4b2a7234-5eb3-4eb1-8b75-38dd4191e6d7"
    },
    {
      "parameters": {
        "trigger": [
          "message"
        ],
        "watchWorkspace": false,
        "channelId": {
          "__rl": true,
          "mode": "id",
          "value": "YOUR_SLACK_CHANNEL_ID"
        }
      },
      "id": "b818d962-075b-4d85-9888-7f531aeac189",
      "name": "Slack trigger",
      "type": "n8n-nodes-base.slackTrigger",
      "typeVersion": 1,
      "position": [
        40,
        640
      ],
      "credentials": {
        "slackApi": {
          "id": "PLACEHOLDER_SLACKAPI",
          "name": "Slack bot"
        }
      },
      "notes": "Watches a channel for messages that should become tasks. Demo uses the sample message.",
      "notesInFlow": true
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "const sample = {\n  \"demo\": true,\n  \"text\": \"@priya Please publish the onboarding checklist\\nDue 2026-12-03. The empty state is still wrong.\",\n  \"channel\": \"#ops\",\n  \"source\": \"slack\"\n};\nconst incoming = $input.first()?.json ?? {};\nconst provided = Object.keys(incoming).filter((key) => incoming[key] !== undefined && incoming[key] !== null && incoming[key] !== '');\nconst base = provided.length ? { ...sample, ...incoming } : { ...sample };\nconst flag = incoming.demo;\nbase.demo = !(flag === false || flag === 'false' || flag === 0 || flag === '0');\nreturn [{ json: base }];\n"
      },
      "id": "1181ef2c-1afb-4520-9d2a-6694de0f91c4",
      "name": "Normalize input",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        340,
        360
      ],
      "notes": "Merges the request over the bundled sample. demo stays true unless the caller explicitly turns it off.",
      "notesInFlow": true
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "const item = $input.first().json;\nconst produced = (() => {\n\nconst text = String(item.text || item.message || '').trim();\nconst owner = (text.match(/@([a-z0-9._-]+)/i) || [])[1] || item.owner || 'unassigned';\nconst due = (text.match(/due\\s+(\\d{4}-\\d{2}-\\d{2})/i) || [])[1] || item.due || '';\nconst urgent = /urgent|asap|today|blocker|sev-?1/i.test(text);\nconst title = text.split('\\n')[0].slice(0, 100) || 'Untitled task';\nconst record = {\n  title,\n  body: text,\n  owner,\n  due,\n  priority: urgent ? 'high' : 'normal',\n  source: item.source || 'slack',\n  channel: item.channel || '',\n};\nreturn {\n  summary: 'Task for ' + owner + (due ? ' due ' + due : '') + ': ' + title,\n  route: urgent ? 'urgent' : 'normal',\n  record,\n  slackText: 'Created a ClickUp task for ' + owner + ': ' + title,\n  actions: [{ app: 'ClickUp', operation: 'create task', payload: record }],\n};\n\n})();\nif (!produced || typeof produced.summary !== 'string' || !produced.summary.trim()) {\n  throw new Error('Apply rules must return a summary string');\n}\nreturn [{\n  json: {\n    ...item,\n    ...produced,\n    demo: item.demo !== false,\n  },\n}];\n"
      },
      "id": "c3bb3dc8-45de-48c1-ad7d-8349c8605bd0",
      "name": "Apply rules",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        620,
        360
      ],
      "notes": "Deterministic stand-in for the model or enrichment API. Replace or precede this with a live model node when you turn demo mode off.",
      "notesInFlow": true
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "1ca36826-20a1-4c3a-b5e9-0363b1934512",
              "leftValue": "={{ $json.demo }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "591293cf-808e-4c41-8261-7b087acd352e",
      "name": "Demo mode?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        900,
        360
      ],
      "notes": "True: package the offline result. False: run the credentialed apps.",
      "notesInFlow": true
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "const item = $input.first().json;\nreturn [{\n  json: {\n    demo: true,\n    status: 'demo_ready',\n    workflow: 'slack-approval-gate',\n    summary: item.summary,\n    route: item.route ?? null,\n    record: item.record ?? {},\n    actions: item.actions ?? [],\n    slackText: item.slackText ?? item.summary,\n    notes: 'Demo mode did not call external apps. Send {\"demo\": false} after placeholder credentials are replaced.',\n  },\n}];\n"
      },
      "id": "aca33e1f-bef8-4298-9455-4e24e8afbf92",
      "name": "Package demo result",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1180,
        180
      ]
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "resource": "message",
        "operation": "post",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "name",
          "value": "#approvals"
        },
        "text": "={{ $json.slackText || $json.summary }}",
        "otherOptions": {}
      },
      "id": "26d3fd2b-1acb-4a80-b121-0948d88cc61f",
      "name": "Post #approvals",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.3,
      "position": [
        1180,
        760
      ],
      "credentials": {
        "slackOAuth2Api": {
          "id": "PLACEHOLDER_SLACKOAUTH2API",
          "name": "Slack account"
        }
      }
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "resource": "task",
        "operation": "create",
        "team": "YOUR_TEAM_ID",
        "space": "YOUR_SPACE_ID",
        "folderless": true,
        "list": "YOUR_LIST_ID",
        "name": "={{ $json.record.title || $json.summary }}",
        "additionalFields": {
          "content": "={{ $json.record.body || $json.summary }}"
        }
      },
      "id": "a4a3d412-333c-495a-8433-a09083b65780",
      "name": "Create ClickUp task",
      "type": "n8n-nodes-base.clickUp",
      "typeVersion": 1.1,
      "position": [
        1460,
        760
      ],
      "credentials": {
        "clickUpOAuth2Api": {
          "id": "PLACEHOLDER_CLICKUPOAUTH2API",
          "name": "ClickUp account"
        }
      }
    },
    {
      "parameters": {
        "content": "## Live path\n\nReplace every `PLACEHOLDER_*` credential, then POST the sample with `\"demo\": false`.\n\nThe nodes on this branch use the `record` and `actions` fields produced by Apply rules.",
        "height": 180,
        "width": 420,
        "color": 6
      },
      "id": "20ac6284-e7cf-4ec4-ab7b-1caee97d1eed",
      "name": "Live path",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1120,
        520
      ]
    }
  ],
  "connections": {
    "Run demo": {
      "main": [
        [
          {
            "node": "Normalize input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Inbound webhook": {
      "main": [
        [
          {
            "node": "Normalize input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Slack trigger": {
      "main": [
        [
          {
            "node": "Normalize input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize input": {
      "main": [
        [
          {
            "node": "Apply rules",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Apply rules": {
      "main": [
        [
          {
            "node": "Demo mode?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Demo mode?": {
      "main": [
        [
          {
            "node": "Package demo result",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Post #approvals",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post #approvals": {
      "main": [
        [
          {
            "node": "Create ClickUp task",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "meta": {
    "templateCredsSetupCompleted": false,
    "description": "A request is parsed into a task and the summary is posted back to Slack. The ClickUp node waits on the live branch so a human can reject the demo result before anything is created."
  },
  "active": false
}
