{
  "name": "Stale Content Auditor",
  "nodes": [
    {
      "id": "79c3733e-436c-4526-b657-622d9a90a626",
      "name": "Weekly Content Audit",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        100,
        300
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "40 7 * * 1"
            }
          ]
        }
      }
    },
    {
      "id": "61d9243b-384b-4a35-9050-e15ef8a42929",
      "name": "Get Content Library",
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        300,
        300
      ],
      "parameters": {
        "resource": "row",
        "operation": "get",
        "dataTableId": {
          "__rl": true,
          "mode": "id",
          "value": "2gf7i5SufszxuRHG",
          "cachedResultName": "Enablement Content Library"
        },
        "returnAll": true
      },
      "executeOnce": true
    },
    {
      "id": "ead5a48d-7823-4432-bbd5-52a623e46d28",
      "name": "Get Product Facts",
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        500,
        300
      ],
      "parameters": {
        "resource": "row",
        "operation": "get",
        "dataTableId": {
          "__rl": true,
          "mode": "id",
          "value": "UIzbFgJrIa1Y9Rwb",
          "cachedResultName": "Messaging & Product Facts"
        },
        "returnAll": true
      },
      "executeOnce": true
    },
    {
      "id": "54794f5e-67d6-41b8-a115-34c2194d74e5",
      "name": "Get Battlecard Updates",
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        700,
        300
      ],
      "parameters": {
        "resource": "row",
        "operation": "get",
        "dataTableId": {
          "__rl": true,
          "mode": "id",
          "value": "SiahCws4nC00xKL0",
          "cachedResultName": "Battlecard Update Log"
        },
        "returnAll": true
      },
      "executeOnce": true,
      "alwaysOutputData": true
    },
    {
      "id": "211122b6-f5b5-4b8f-84e1-494ed5c1f193",
      "name": "Find Audit Candidates",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        900,
        300
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "// Build audit candidates in code. Every asset is checked against every current product fact and, for battlecards, the latest\n// approved positioning for its competitor. A review date is not proof: an asset reviewed after a change can still carry the old claim.\n// Claude only checks the (asset, fact) pairs code hands it, so it never decides what to look at.\nconst runDate = $today.toFormat('yyyy-MM-dd');\nconst lib = $('Get Content Library').all().map(i => i.json).filter(a => a.assetId && a.bodyText && a.status !== 'retired');\nconst facts = $('Get Product Facts').all().map(i => i.json).filter(f => f.kind === 'fact' && f.changedOn);\nconst bc = $('Get Battlecard Updates').all().map(i => i.json).filter(r => r.competitorName && r.updatedPositioning);\nconst latest = {};\nfor (const r of bc) { const d = String(r.loggedAt || r.createdAt).slice(0, 10); if (!latest[r.competitorName] || d > latest[r.competitorName].changedOn) latest[r.competitorName] = { factId: 'BC-' + r.competitorName, topic: r.competitorName + ' battlecard', current: r.updatedPositioning, previous: r.previousPositioning || '', changedOn: d }; }\nconst assets = [];\nlet pairs = 0;\nfor (const a of lib) {\n  const cands = facts.map(f => ({ factId: f.factId, topic: f.topic, current: f.statement, previous: f.previousStatement, changedOn: f.changedOn }));\n  if (a.competitor && latest[a.competitor]) cands.push(latest[a.competitor]);\n  pairs += cands.length;\n  assets.push({ assetId: a.assetId, title: a.title, lastReviewed: a.lastReviewed, owner: a.owner, body: a.bodyText, candidateFacts: cands });\n}\nreturn [{ json: { runDate, libraryAssets: lib.length, assetsChecked: assets.length, factsChecked: facts.length, pairs, assets } }];\n"
      },
      "executeOnce": true
    },
    {
      "id": "5a30272a-5230-49e7-982d-676d690877fd",
      "name": "Outdated Claim Finder",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3.1,
      "position": [
        300,
        450
      ],
      "parameters": {
        "promptType": "define",
        "text": "={{ JSON.stringify($json.assets, null, 1) }}",
        "hasOutputParser": true,
        "options": {
          "systemMessage": "You audit sales enablement assets for Fortavault, Inc. (a fictional data protection company). For each asset you get its full text and the list of current facts to check it against. Each fact has the current statement, the previous statement and the date it changed.\n\nReport a finding only when the asset text states something that the current fact contradicts: typically it repeats the previous statement (an old number, an old pricing model, an old certification status, an old integration list, old competitor positioning). If the asset already agrees with the current fact, or does not mention the topic at all, report nothing for that fact. Do not use the asset's review date to decide; judge the text only.\n\nFor each finding return assetId, factId and quote. The quote must be copied word for word from the asset text, as short as possible while still containing the outdated claim (one clause or sentence). Never paraphrase, never combine sentences, never quote text from the facts. Use only the factIds given for that asset. Return an empty list if nothing is outdated."
        }
      },
      "executeOnce": true,
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 2000
    },
    {
      "id": "20cb2115-57e1-45f4-be6e-f2eb3bd98b55",
      "name": "Claude Sonnet",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "typeVersion": 1.3,
      "position": [
        100,
        450
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "claude-sonnet-4-6",
          "cachedResultName": "Claude Sonnet 4.6"
        },
        "options": {
          "temperature": 0
        }
      },
      "credentials": {
        "anthropicApi": {
          "id": "3d3ZiTi7BwnkFwqU",
          "name": "Anthropic account"
        }
      }
    },
    {
      "id": "d967d8a1-dd36-4d8f-80d1-e209d1dc966e",
      "name": "Findings Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.3,
      "position": [
        100,
        600
      ],
      "parameters": {
        "schemaType": "fromJson",
        "jsonSchemaExample": "{ \"findings\": [{ \"assetId\": \"FV-00\", \"factId\": \"F0\", \"quote\": \"exact words from the asset\" }] }"
      }
    },
    {
      "id": "a1517110-28e4-4f5f-83c7-25cf2c5d8cac",
      "name": "Verify Findings",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        500,
        450
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "// Verify every finding in code before anyone sees it: the quote must appear word for word in that asset's text,\n// and the fact must be one of the candidates code gave Claude for that asset. Anything else is dropped and counted.\nconst c = $('Find Audit Candidates').first().json;\nconst out = $('Outdated Claim Finder').first().json.output || {};\nconst norm = s => String(s || '').replace(/[‘’]/g, \"'\").replace(/[“”]/g, '\"').replace(/\\s+/g, ' ').trim().toLowerCase();\nconst byId = {}; for (const a of c.assets) byId[a.assetId] = a;\nconst kept = [], dropped = [];\nconst seen = new Set();\nfor (const f of (out.findings || [])) {\n  const a = byId[f.assetId];\n  const fact = a && a.candidateFacts.find(x => x.factId === f.factId);\n  const ok = a && fact && f.quote && norm(a.body).includes(norm(f.quote)) && norm(f.quote).length >= 12;\n  const key = f.assetId + '|' + f.factId;\n  if (!ok || seen.has(key)) { dropped.push({ ...f, reason: !a ? 'unknown asset' : !fact ? 'fact not a candidate for this asset' : seen.has(key) ? 'duplicate' : 'quote not found verbatim' }); continue; }\n  seen.add(key);\n  kept.push({ assetId: a.assetId, assetTitle: a.title, owner: a.owner, lastReviewed: a.lastReviewed, factId: fact.factId, topic: fact.topic, quote: f.quote.trim(), currentFact: fact.current, changedOn: fact.changedOn });\n}\nconst assets = [...new Set(kept.map(k => k.assetId))];\nif (!kept.length) return [];\nconst safe = t => String(t || '').replace(/~/g, '≈');\n// Compact layout to stay under Slack's block limit: each current fact once, then one line per outdated quote.\nconst cited = [...new Map(kept.map(k => [k.factId, k])).values()].sort((a, b) => a.factId.localeCompare(b.factId));\nconst factLines = cited.map(k => '*' + k.factId + '* ' + safe(k.currentFact) + ' _(changed ' + k.changedOn + ')_');\nconst lines = assets.map(id => {\n  const ks = kept.filter(k => k.assetId === id);\n  return '*' + id + '* ' + ks[0].assetTitle + ' _(' + ks[0].owner + ', reviewed ' + ks[0].lastReviewed + ')_\\n' +\n    ks.map(k => '      • ' + k.factId + ': “' + safe(k.quote) + '”' + (k.lastReviewed > k.changedOn ? ' _(reviewed after this changed; missed)_' : '')).join('\\n');\n});\nconst text = ':broom: *Stale Content Audit* (run ' + c.runDate + ')\\n' + c.assetsChecked + ' assets checked against ' + c.factsChecked + ' current product and pricing facts plus the latest approved battlecards.\\n' +\n  '*' + kept.length + ' outdated claim' + (kept.length === 1 ? '' : 's') + ' in ' + assets.length + ' asset' + (assets.length === 1 ? '' : 's') + '*, quoted word for word.\\n\\n*What is true now*\\n' + factLines.join('\\n') + '\\n\\n*Where the assets say otherwise*\\n' + lines.join('\\n') +\n  (dropped.length ? '\\n\\n_' + dropped.length + ' further finding' + (dropped.length === 1 ? '' : 's') + ' dropped: quote not found word for word in the asset._' : '') +\n  '\\n\\nApprove to mark these assets *needs update* and notify their owners. Nothing is edited automatically.';\n// Hard guard: Slack rejects a block over ~3,000 characters, so cut at a line boundary and point to the log.\nlet approvalText = text;\nif (approvalText.length > 2900) { approvalText = approvalText.slice(0, 2800); approvalText = approvalText.slice(0, approvalText.lastIndexOf('\\n')) + '\\n_…list cut to fit Slack; every finding is written to the Content Audit Log._'; }\nreturn [{ json: { runDate: c.runDate, findings: kept, dropped, assets, approvalText, approvalChars: approvalText.length } }];\n"
      }
    },
    {
      "id": "02569574-4401-4e34-9bdc-86aed704d701",
      "name": "Ask Approval in Slack",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.3,
      "position": [
        700,
        450
      ],
      "parameters": {
        "resource": "message",
        "operation": "sendAndWait",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "id",
          "value": "C0BQ3G96HL6",
          "cachedResultName": "general"
        },
        "message": "={{ $json.approvalText }}",
        "responseType": "approval",
        "approvalOptions": {
          "values": {
            "approvalType": "double",
            "approveLabel": "Mark for update",
            "disapproveLabel": "Decline"
          }
        },
        "options": {
          "limitWaitTime": {
            "values": {
              "limitType": "afterTimeInterval",
              "resumeAmount": 48,
              "resumeUnit": "hours"
            }
          },
          "appendAttribution": false
        }
      },
      "credentials": {
        "slackApi": {
          "id": "mv7TIi8kucFPqPg6",
          "name": "Slack account"
        }
      }
    },
    {
      "id": "5f0c75b5-0e2f-4948-a8b3-d948152479df",
      "name": "Apply Decision",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        900,
        450
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "// Decision applied in code: approved assets are marked 'needs update' with the exact claims to fix; every finding is logged either way.\nconst v = $('Verify Findings').first().json;\nconst approved = !!($('Ask Approval in Slack').first().json.data || {}).approved;\nconst now = $now.toISO();\nconst updates = approved ? v.assets.map(id => ({ assetId: id, status: 'needs update',\n  flaggedClaims: v.findings.filter(k => k.assetId === id).map(k => k.factId + ': \"' + k.quote + '\" -> ' + k.currentFact).join(' | ') })) : [];\nconst logs = v.findings.map(k => ({ runDate: v.runDate, assetId: k.assetId, assetTitle: k.assetTitle, factId: k.factId, quote: k.quote, currentFact: k.currentFact,\n  decision: approved ? 'marked needs update' : 'declined', loggedAt: now }));\nconst owners = [...new Set(v.findings.map(k => k.owner))];\nconst text = approved\n  ? ':white_check_mark: *Stale Content Audit approved:* ' + v.assets.length + ' assets marked *needs update* in the content library (' + v.assets.join(', ') + '). Owners to action: ' + owners.join(', ') + '. Each asset row now carries the exact claims to fix.'\n  : ':no_entry_sign: *Stale Content Audit declined:* no assets changed. All ' + v.findings.length + ' findings are logged for the next review.';\nreturn [{ json: { updates, logs, resultText: text } }];\n"
      }
    },
    {
      "id": "10bf8313-7dba-4931-9757-6be3bc9d1ee5",
      "name": "Post Result to Slack",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.7,
      "position": [
        1100,
        450
      ],
      "parameters": {
        "resource": "message",
        "operation": "post",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "id",
          "value": "C0BQ3G96HL6",
          "cachedResultName": "general"
        },
        "text": "={{ $json.resultText }}",
        "otherOptions": {
          "includeLinkToWorkflow": false
        }
      },
      "credentials": {
        "slackApi": {
          "id": "mv7TIi8kucFPqPg6",
          "name": "Slack account"
        }
      }
    },
    {
      "id": "01e95877-e664-41ce-a20d-1d3ecf6fd088",
      "name": "Split Library Updates",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1100,
        600
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "return $('Apply Decision').first().json.updates.map(json => ({ json }));"
      }
    },
    {
      "id": "db8e9e67-7a90-4e30-8668-9b7a5ad1fe52",
      "name": "Mark Assets Needs Update",
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        1300,
        600
      ],
      "parameters": {
        "resource": "row",
        "operation": "upsert",
        "dataTableId": {
          "__rl": true,
          "mode": "id",
          "value": "2gf7i5SufszxuRHG",
          "cachedResultName": "Enablement Content Library"
        },
        "matchType": "allConditions",
        "filters": {
          "conditions": [
            {
              "keyName": "assetId",
              "condition": "eq",
              "keyValue": "={{ $json.assetId }}"
            }
          ]
        },
        "columns": {
          "mappingMode": "autoMapInputData",
          "value": {}
        }
      }
    },
    {
      "id": "0d3a9629-4f25-43ef-a5a9-d0be0f4a8151",
      "name": "Split Audit Log Rows",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1100,
        750
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "return $('Apply Decision').first().json.logs.map(json => ({ json }));"
      }
    },
    {
      "id": "f572e129-32c2-4a0c-aee0-5981b45009ec",
      "name": "Log Audit Findings",
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        1300,
        750
      ],
      "parameters": {
        "resource": "row",
        "operation": "insert",
        "dataTableId": {
          "__rl": true,
          "mode": "id",
          "value": "fF01JOb6C57sCavR",
          "cachedResultName": "Content Audit Log"
        },
        "columns": {
          "mappingMode": "autoMapInputData",
          "value": {}
        }
      }
    }
  ],
  "connections": {
    "Weekly Content Audit": {
      "main": [
        [
          {
            "node": "Get Content Library",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Content Library": {
      "main": [
        [
          {
            "node": "Get Product Facts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Product Facts": {
      "main": [
        [
          {
            "node": "Get Battlecard Updates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Battlecard Updates": {
      "main": [
        [
          {
            "node": "Find Audit Candidates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find Audit Candidates": {
      "main": [
        [
          {
            "node": "Outdated Claim Finder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Outdated Claim Finder": {
      "main": [
        [
          {
            "node": "Verify Findings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Claude Sonnet": {
      "ai_languageModel": [
        [
          {
            "node": "Outdated Claim Finder",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Findings Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Outdated Claim Finder",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Verify Findings": {
      "main": [
        [
          {
            "node": "Ask Approval in Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ask Approval in Slack": {
      "main": [
        [
          {
            "node": "Apply Decision",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Apply Decision": {
      "main": [
        [
          {
            "node": "Post Result to Slack",
            "type": "main",
            "index": 0
          },
          {
            "node": "Split Library Updates",
            "type": "main",
            "index": 0
          },
          {
            "node": "Split Audit Log Rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Library Updates": {
      "main": [
        [
          {
            "node": "Mark Assets Needs Update",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Audit Log Rows": {
      "main": [
        [
          {
            "node": "Log Audit Findings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}