{
  "id": "aQBW1ywS2VIGyLp2",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Global Industrial Intelligence Monitoring Workflow",
  "tags": [],
  "nodes": [
    {
      "id": "dbb5d42b-fba3-43d9-8f45-832222c47872",
      "name": "Score Risk",
      "type": "n8n-nodes-base.code",
      "position": [
        2880,
        560
      ],
      "parameters": {
        "jsCode": "const type = $json.crisis_type || \"other\";\nconst severity = $json.severity || 2;\n\nlet score = severity * 20;\n\nif (type === \"war\") score += 20;\nif (type === \"disaster\") score += 15;\nif (type === \"energy\") score += 10;\nif (type === \"inflation\") score += 5;\n\nif (score > 100) score = 100;\n\nreturn [\n  {\n    json: {\n      ...$json,\n      risk_score: score\n    }\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "f5fe213a-22c1-41d5-84f8-ff63bc64c324",
      "name": "Get Topic News",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2128,
        560
      ],
      "parameters": {
        "url": "=https://newsapi.org/v2/everything?q={{$json.topic_query}}&searchIn={{$json.search_in}}&sortBy={{$json.sort_by}}&from={{$json.from_date}}&language={{$json.language}}&pageSize={{$json.top_n}}",
        "options": {},
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "httpMultipleHeadersAuth"
      },
      "credentials": {
        "actionNetworkApi": {
          "name": "<your credential>"
        },
        "httpMultipleHeadersAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.4
    },
    {
      "id": "f3eacb29-437f-4683-932d-c5bb128ad0c3",
      "name": "Rank Top N",
      "type": "n8n-nodes-base.code",
      "position": [
        3136,
        560
      ],
      "parameters": {
        "jsCode": "const n = Number($item(0).$node[\"Load User Configuration\"].json[\"top_n\"] || 10);\n\nconst sorted = items.sort((a, b) => {\n  return (b.json.risk_score || 0) - (a.json.risk_score || 0);\n});\n\nreturn sorted.slice(0, n);"
      },
      "typeVersion": 2
    },
    {
      "id": "26838a93-ee83-4601-ab72-9056a21ec646",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        880,
        384
      ],
      "parameters": {
        "width": 582,
        "height": 576,
        "content": "## Global Industrial Intelligence Workflow\n\nThis workflow collects and analyzes global industrial news and risk-related information to support business and engineering decision-making.\n\nIt automatically retrieves news data from external sources, processes articles, classifies risk categories using rule-based analysis logic, and calculates risk scores.\n\nThe workflow ranks important signals, stores the results in Google Sheets, and sends alerts to Discord for monitoring and reporting purposes.\n\nThis template demonstrates how n8n can be used to build scalable global monitoring and intelligence automation systems.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "b6c9cce1-8d81-4ca1-ad02-8464627348de",
      "name": "Global Signal Scheduler",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        1536,
        560
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 9
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "749b39f2-77a0-43d6-89ba-0795fedb0877",
      "name": "Load User Configuration",
      "type": "n8n-nodes-base.code",
      "position": [
        1936,
        560
      ],
      "parameters": {
        "jsCode": "const days = Number($json.from_days_ago || 7);\nconst d = new Date();\nd.setDate(d.getDate() - days);\n\nreturn [{\n  json: {\n    ...$json,\n    from_date: d.toISOString().slice(0, 10)\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "84f8ec88-1fb4-4770-93ae-b8c96c7c7d57",
      "name": "Expand Articles",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        2416,
        560
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "articles"
      },
      "typeVersion": 1
    },
    {
      "id": "c4af7c89-1c12-42fb-8d16-9028b09c97ca",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1472,
        464
      ],
      "parameters": {
        "color": 7,
        "width": 784,
        "height": 256,
        "content": "## Data Input\nFetches global news data from NewsAPI and loads workflow configuration settings from Google Sheets."
      },
      "typeVersion": 1
    },
    {
      "id": "6a962bd9-1b1d-4535-a8bb-22943739315c",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2288,
        464
      ],
      "parameters": {
        "color": 7,
        "width": 336,
        "height": 256,
        "content": "## Data Processing\nTransforms raw news data into structured individual articles for analysis."
      },
      "typeVersion": 1
    },
    {
      "id": "0cdcff04-7480-40f5-8e60-c9f6a43bdc8f",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2640,
        464
      ],
      "parameters": {
        "color": 7,
        "width": 384,
        "height": 256,
        "content": "## AI Analysis\n\nClassifies global news content and evaluates risk scores using rule-based analysis logic.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "86c3252d-6902-4177-8080-383abee9b9fa",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2560,
        768
      ],
      "parameters": {
        "color": 7,
        "width": 768,
        "height": 400,
        "content": "## Output & Delivery\nStores results in Google Sheets and sends notifications via Discord."
      },
      "typeVersion": 1
    },
    {
      "id": "b31f6f92-4adb-4426-84a4-59dd9a2bedc4",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3040,
        464
      ],
      "parameters": {
        "color": 7,
        "width": 320,
        "height": 256,
        "content": "## Decision Engine\nRanks news items based on importance and selects the top signals."
      },
      "typeVersion": 1
    },
    {
      "id": "e1d0abad-56f1-4573-be3f-1b6a4b0a5b3d",
      "name": "Load Workflow Settings",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1728,
        560
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "=settings"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "=Example Global Risk Dashboard"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "c95ada05-db74-4720-a3a8-d6cbcf2ef5ad",
      "name": "Save Ranked Signals to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2608,
        928
      ],
      "parameters": {
        "columns": {
          "value": {
            "url": "={{ $json.url }}",
            "title": "={{ $json.title }}",
            "risk_score": "={{ $json.risk_score }}",
            "summary_ja": "={{ $json.summary_ja }}",
            "crisis_type": "={{ $json.crisis_type }}"
          },
          "schema": [
            {
              "id": "title",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "summary_ja",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "summary_ja",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "crisis_type",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "crisis_type",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "risk_score",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "risk_score",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "url",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "country "
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "==risk_summary"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "=Example Global Risk Dashboard"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "2ae97c67-778a-447f-850d-41081922d5b2",
      "name": "Generate Discord Alert",
      "type": "n8n-nodes-base.code",
      "position": [
        2864,
        928
      ],
      "parameters": {
        "jsCode": "const items = $items();\n\nlet text = \"\ud83c\udf0d Global Risk Intelligence Report\\n\\n\";\n\nitems.forEach((item, i) => {\n  text += `${i + 1}. ${item.json.title}\\n`;\n  text += `Risk Score: ${item.json.risk_score}\\n`;\n  text += `Category: ${item.json.crisis_type}\\n`;\n  text += `${item.json.url}\\n\\n`;\n});\n\nreturn [\n  {\n    json: {\n      content: text\n    }\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "7d7461db-8f90-4d0a-8ea2-6f326d4684f8",
      "name": "Send Discord Alert",
      "type": "n8n-nodes-base.discord",
      "position": [
        3104,
        928
      ],
      "parameters": {
        "content": "=={{$json.content}}",
        "guildId": {
          "__rl": true,
          "mode": "id",
          "value": "=Example Discord Server"
        },
        "options": {},
        "resource": "message",
        "channelId": {
          "__rl": true,
          "mode": "id",
          "value": "=1490873801863463092"
        }
      },
      "credentials": {
        "discordBotApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "ec0a74b4-f3e2-4dc0-bca6-4defd1637fb9",
      "name": "Classify Risk Signals",
      "type": "n8n-nodes-base.code",
      "position": [
        2720,
        560
      ],
      "parameters": {
        "jsCode": "const title = $json.title || \"\";\nconst description = $json.description || \"\";\n\nconst summary_ja = title.slice(0, 80);\n\nlet crisis_type = \"other\";\nlet severity = 2;\nlet confidence = 0.5;\n\nconst text = (title + \" \" + description).toLowerCase();\n\nif (text.includes(\"war\") || text.includes(\"attack\")) {\n  crisis_type = \"war\";\n  severity = 5;\n  confidence = 0.9;\n} else if (text.includes(\"inflation\") || text.includes(\"price\")) {\n  crisis_type = \"inflation\";\n  severity = 3;\n  confidence = 0.7;\n} else if (text.includes(\"energy\") || text.includes(\"oil\")) {\n  crisis_type = \"energy\";\n  severity = 3;\n  confidence = 0.7;\n} else if (text.includes(\"earthquake\") || text.includes(\"flood\")) {\n  crisis_type = \"disaster\";\n  severity = 4;\n  confidence = 0.8;\n}\n\nreturn [\n  {\n    json: {\n      ...$json,\n      summary_ja,\n      crisis_type,\n      severity,\n      confidence\n    }\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "0b89b8af-5e1f-4289-b5b0-57d0c1dbbe79",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1184,
        640
      ],
      "parameters": {
        "height": 304,
        "content": "## Setup Guide\n1. Create a NewsAPI account\n2. Configure HTTP Header credentials\n3. Connect Google Sheets credentials\n4. Connect Discord Bot credentials\n5. Create your own Google Sheet\n6. Run the workflow manually once\n7. Enable the scheduler"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "availableInMCP": false,
    "executionOrder": "v1"
  },
  "versionId": "559a2ade-8b7c-4dc6-b1fd-ae118dba005f",
  "connections": {
    "Rank Top N": {
      "main": [
        [
          {
            "node": "Save Ranked Signals to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Score Risk": {
      "main": [
        [
          {
            "node": "Rank Top N",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Topic News": {
      "main": [
        [
          {
            "node": "Expand Articles",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Expand Articles": {
      "main": [
        [
          {
            "node": "Classify Risk Signals",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Classify Risk Signals": {
      "main": [
        [
          {
            "node": "Score Risk",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Discord Alert": {
      "main": [
        [
          {
            "node": "Send Discord Alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Load Workflow Settings": {
      "main": [
        [
          {
            "node": "Load User Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Global Signal Scheduler": {
      "main": [
        [
          {
            "node": "Load Workflow Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Load User Configuration": {
      "main": [
        [
          {
            "node": "Get Topic News",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Ranked Signals to Google Sheets": {
      "main": [
        [
          {
            "node": "Generate Discord Alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}