{
  "name": "04 · CRM & Sales / Pipeline Staleness Alerter",
  "active": false,
  "nodes": [
    {
      "id": "9f6a999f-cf2f-4e52-ae9b-3d668200260b",
      "name": "📘 Guide",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -640,
        -120
      ],
      "parameters": {
        "content": "## 04 · CRM & Sales · Pipeline Staleness Alerter\n\n### What this does\nHourly CRM pull of open deals; alerts owners when stage age exceeds SLA.\n\n### Setup checklist\n1. CRM list deals API\n2. Slack/email destination\n3. SLA days per stage in Set\n\n### How to test locally\nRun schedule manually with mocked deals in Code.\n\n### Tips\n- Keep credentials in n8n Credentials (never hardcode secrets).\n- Use **Test URL** on the Webhook while developing.\n- Activate only after credentials + destinations are configured.\n",
        "width": 560,
        "height": 560,
        "color": 3
      }
    },
    {
      "id": "50600046-ca88-472b-a69a-7377e69051cd",
      "name": "⚙️ Config",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -640,
        480
      ],
      "parameters": {
        "content": "## Config map\n\n- **Webhook path:** `crm-pipeline-sla`\n- **Replace** all `https://httpbin.org/...` calls with real integrations.\n- **Credentials:** create in n8n → Credentials, then select on HTTP nodes.\n- **Activate** workflow only after a successful Test execution.\n\n### Local files\nShared host folder is mounted at `/files` inside n8n.",
        "width": 560,
        "height": 320,
        "color": 2
      }
    },
    {
      "id": "36832600-3b97-40bf-8aa9-17e5a1b53190",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        200
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 60
            }
          ]
        }
      }
    },
    {
      "id": "9de6c8b7-ea63-48c2-abd9-bbe26e6c172c",
      "name": "Pull Records",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        280,
        200
      ],
      "parameters": {
        "method": "GET",
        "url": "https://httpbin.org/get",
        "options": {}
      }
    },
    {
      "id": "396eca9f-0059-4d4b-802e-b3a083ad3d83",
      "name": "Triage & Score",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        560,
        200
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "const now = Date.now();\nconst sample = [\n  { id: 'A1', ageHours: 52, severity: 'high', owner: 'ada' },\n  { id: 'B2', ageHours: 5, severity: 'low', owner: 'lin' },\n  { id: 'C3', ageHours: 30, severity: 'medium', owner: 'sam' },\n];\nconst flagged = sample\n  .map(r => ({ ...r, breach: r.ageHours > 24 || r.severity === 'high', score: r.ageHours + (r.severity==='high'?50:0) }))\n  .filter(r => r.breach)\n  .sort((a,b) => b.score - a.score);\nreturn flagged.length\n  ? flagged.map(f => ({ json: { workflow: 'Pipeline Staleness Alerter', ...f, checkedAt: new Date(now).toISOString() } }))\n  : [{ json: { workflow: 'Pipeline Staleness Alerter', ok: true, flagged: 0 } }];"
      }
    },
    {
      "id": "a5f2ed92-b964-40c7-92fb-53da95bff089",
      "name": "Needs Alert?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        840,
        200
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "a19a956e-2bfb-4c8e-9e43-fd3c0d28d4ee",
              "leftValue": "={{ $json.breach === true }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      }
    },
    {
      "id": "b50f837e-d2dd-4fcb-8f38-c2063a0982cd",
      "name": "Send Alert",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1120,
        80
      ],
      "parameters": {
        "method": "POST",
        "url": "https://httpbin.org/post",
        "options": {},
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify($json) }}"
      }
    },
    {
      "id": "73a32bf0-abfd-4cc0-a51e-4430d9d89a50",
      "name": "All Clear",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1120,
        320
      ],
      "parameters": {
        "mode": "manual",
        "duplicateItem": false,
        "assignments": {
          "assignments": [
            {
              "id": "1",
              "name": "status",
              "value": "healthy",
              "type": "string"
            }
          ]
        },
        "options": {}
      }
    }
  ],
  "connections": {
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Pull Records",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pull Records": {
      "main": [
        [
          {
            "node": "Triage & Score",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Triage & Score": {
      "main": [
        [
          {
            "node": "Needs Alert?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Needs Alert?": {
      "main": [
        [
          {
            "node": "Send Alert",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "All Clear",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "callerPolicy": "workflowsFromSameOwner"
  },
  "tags": [],
  "meta": {
    "templateCredsSetupCompleted": true,
    "description": "Hourly CRM pull of open deals; alerts owners when stage age exceeds SLA."
  },
  "pinData": {}
}