{
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "5d37cc73-0a60-4da7-b0df-a330b4b638a1",
        "responseMode": "responseNode",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        -160,
        -252
      ],
      "id": "fa15b370-b80b-4033-8dd9-83b4779795e5",
      "name": "Webhook"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.body.text }}",
        "options": {
          "systemMessage": "You are an AI Claim Extraction Agent.\n\nYour task is to extract only verifiable factual claims from the provided text.\n\nFocus ONLY on:\n- statistics\n- percentages\n- dates\n- company facts\n- technical claims\n- financial numbers\n- measurable statements\n\nIgnore:\n- opinions\n- marketing language\n- generic descriptions\n- motivational statements\n- non-verifiable text\n\nReturn ONLY valid JSON in this format:\n\n{\n  \"claims\": [\n    {\n      \"claim\": \"...\"\n    }\n  ]\n}\n\nDo not include explanations.\nDo not include markdown.\nDo not include extra text."
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3.1,
      "position": [
        64,
        -252
      ],
      "id": "0567988b-56e4-4234-a36e-16bc2d7d3644",
      "name": "AI Agent1"
    },
    {
      "parameters": {
        "model": "openai/gpt-oss-120b",
        "options": {
          "temperature": 0
        }
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGroq",
      "typeVersion": 1,
      "position": [
        136,
        -28
      ],
      "id": "8b7e0711-d4a4-4d04-a6d0-c97a4b1c1b39",
      "name": "Groq Chat Model1"
    },
    {
      "parameters": {
        "jsCode": "const parsed = JSON.parse($json.output);\n\nreturn parsed.claims.map(claim => ({\n  json: {\n    claim: claim.claim\n  }\n}));"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        416,
        -252
      ],
      "id": "a04b552b-68e1-4912-bd96-4b66d2078e1e",
      "name": "Code in JavaScript"
    },
    {
      "parameters": {
        "query": "={{ $json.claim }}",
        "options": {
          "max_results": 2
        }
      },
      "type": "@tavily/n8n-nodes-tavily.tavily",
      "typeVersion": 1,
      "position": [
        864,
        -252
      ],
      "id": "a6b10145-f534-468f-9e91-9c32e1fc9ab9",
      "name": "Search"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.claim }}\n{{ $json.evidence }}",
        "options": {
          "systemMessage": "You are an AI Fact-Checking Agent.\n\nYour task is to verify claims using ONLY the provided evidence.\n\nVerification Rules:\n- Compare the claim carefully with the evidence\n- Do not use outside knowledge\n- Use ONLY the provided sources\n- Prefer reputable sources over social media posts\n- If evidence is weak or incomplete, lower confidence\n\nClassification Rules:\n- VERIFIED \u2192 evidence directly supports the claim\n- INACCURATE \u2192 partially correct, misleading, outdated, or numerically incorrect\n- FALSE \u2192 contradicted by evidence or unsupported\n\nConfidence Rules:\n- 90\u2013100 \u2192 strong direct evidence from reliable sources\n- 70\u201389 \u2192 mostly supported but minor uncertainty\n- 40\u201369 \u2192 weak or incomplete evidence\n- 0\u201339 \u2192 unsupported or unreliable evidence\n\nAdditional Rules:\n- Keep explanations concise\n- Mention the most relevant source/domain in the explanation\n- If the claim is incorrect, provide the corrected fact\n- Return ONLY raw valid JSON\n- Do not include markdown\n- Do not include code blocks\n- Do not say \"Here is the response\"\n- Do not include extra text before or after JSON\n\nResponse format:\n{\n  \"claim\": \"\",\n  \"status\": \"\",\n  \"confidence\": 0,\n  \"correct_fact\": \"\",\n  \"source_url\": \"\",\n  \"explanation\": \"\"\n}"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3.1,
      "position": [
        1312,
        -180
      ],
      "id": "190339e2-b622-425e-9922-11a05c1282b2",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "model": "meta-llama/llama-4-scout-17b-16e-instruct",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGroq",
      "typeVersion": 1,
      "position": [
        1384,
        44
      ],
      "id": "eeca88a4-a5f0-40b9-bc80-5625edc606e9",
      "name": "Groq Chat Model"
    },
    {
      "parameters": {
        "jsCode": "const results = [];\n\nfor (const item of $input.all()) {\n  let output = item.json.output;\n\n  const match = output.match(/\\{[\\s\\S]*\\}/);\n\n  if (!match) {\n    results.push({\n      error: \"No valid JSON found\",\n      raw_output: output\n    });\n    continue;\n  }\n\n  try {\n    const parsed = JSON.parse(match[0]);\n    results.push(parsed);\n  } catch (err) {\n    results.push({\n      error: err.message,\n      raw_output: output\n    });\n  }\n}\n\nreturn results.map(r => ({\n  json: r\n}));"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        864,
        -496
      ],
      "id": "5dff2990-6bbd-4b1d-bd51-1ed0cf03504a",
      "name": "Code in JavaScript2"
    },
    {
      "parameters": {
        "jsCode": "const results = $input.all().map(item => item.json);\n\nconst summary = {\n  total_claims: results.length,\n  verified: results.filter(r => r.status === \"VERIFIED\").length,\n  inaccurate: results.filter(r => r.status === \"INACCURATE\").length,\n  false: results.filter(r => r.status === \"FALSE\").length\n};\n\nreturn [\n  {\n    json: {\n      success: true,\n      summary,\n      results\n    }\n  }\n];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1088,
        -496
      ],
      "id": "da06160c-4725-4033-b548-b54b979dd7b8",
      "name": "Code in JavaScript3",
      "executeOnce": false,
      "alwaysOutputData": false
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ $json }}",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.5,
      "position": [
        1376,
        -496
      ],
      "id": "ca75fa9a-cfea-4940-b2f9-2f635cd3ccd9",
      "name": "Respond to Webhook",
      "alwaysOutputData": false,
      "executeOnce": false
    },
    {
      "parameters": {
        "jsCode": "const evidence = $json.results\n  ?.map((r) => {\n\n    const domain = r.url\n      .replace(/^https?:\\/\\//, \"\")\n      .replace(/^www\\./, \"\")\n      .split(\"/\")[0];\n\n    const cleanedContent = r.content\n      .replace(/[#*_`>-]/g, \"\")\n      .replace(/\\s+/g, \" \")\n      .trim()\n      .slice(0, 300);\n\n    return `\nSource: ${domain}\n\nEvidence:\n${cleanedContent}\n\nURL:\n${r.url}\n`;\n  })\n  .join(\"\\n\\n\");\n\nreturn [\n  {\n    json: {\n      claim: $json.query,\n      evidence\n    }\n  }\n];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1088,
        -252
      ],
      "id": "4f23a4b8-85d8-4097-94b0-9cea2ea23d1a",
      "name": "Code in JavaScript1"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        640,
        -252
      ],
      "id": "0a7f18a3-0e37-42e6-8a06-94d3a57c8192",
      "name": "Loop Over Items"
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "AI Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent1": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Groq Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search": {
      "main": [
        [
          {
            "node": "Code in JavaScript1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Groq Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript2": {
      "main": [
        [
          {
            "node": "Code in JavaScript3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript3": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript1": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Code in JavaScript2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Search",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "meta": {
    "templateCredsSetupCompleted": true
  }
}