{
  "nodes": [
    {
      "id": "6efd2649-b781-4c81-800d-07e3be903acf",
      "name": "Workflow Configuration",
      "type": "n8n-nodes-base.set",
      "position": [
        2048,
        272
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "id-1",
              "name": "keyword",
              "type": "string",
              "value": "={{ $json.parsedData.keyword.trim().replace(/\\\\n/g, '') }}"
            },
            {
              "id": "id-2",
              "name": "country",
              "type": "string",
              "value": "jp"
            },
            {
              "id": "id-3",
              "name": "language",
              "type": "string",
              "value": "ja"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "92f9d875-e505-4a5f-9371-6516f757aae1",
      "name": "Google Trends API",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2272,
        272
      ],
      "parameters": {
        "url": "https://serpapi.com/search",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "engine",
              "value": "google_trends"
            },
            {
              "name": "q",
              "value": "={{ $node[\"Workflow Configuration\"].json.keyword }}"
            },
            {
              "name": "data_type",
              "value": "TIMESERIES"
            },
            {
              "name": "geo",
              "value": "JP"
            },
            {
              "name": "api_key"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "5bbc5b58-14ba-42f8-8839-d4232ad0c27f",
      "name": "Aggregate Research Data",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        2496,
        272
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "6d85659c-5d82-4823-aa44-2c14da8e9859",
      "name": "Format Final Report",
      "type": "n8n-nodes-base.set",
      "position": [
        3072,
        272
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "id-1",
              "name": "report",
              "type": "string",
              "value": "={{ $json.output }}"
            },
            {
              "id": "id-2",
              "name": "keyword",
              "type": "string",
              "value": "={{ $('Workflow Configuration').first().json.keyword }}"
            },
            {
              "id": "id-3",
              "name": "timestamp",
              "type": "string",
              "value": "={{ $now.toISO() }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "d263605e-5ac2-4e6a-a991-1f0dc82d2fba",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        576,
        368
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 9
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "30a21404-c212-4947-9bb7-9908c71cd08e",
      "name": "RSS Read",
      "type": "n8n-nodes-base.rssFeedRead",
      "position": [
        800,
        368
      ],
      "parameters": {
        "url": "https://news.google.com/rss/search?q=%E3%81%B5%E3%82%8B%E3%81%95%E3%81%A8%E7%B4%8D%E7%A8%8E&hl=ja&gl=JP&ceid=JP:ja",
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "f6131baa-abaa-4176-967d-5ecef079a012",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1248,
        368
      ],
      "parameters": {
        "text": "={{ $('\u30cb\u30e5\u30fc\u30b9\u6574\u5f62').first().json.news_list }}",
        "options": {
          "systemMessage": "\u3042\u306a\u305f\u306f\u512a\u79c0\u306a\u30ea\u30b5\u30fc\u30c1\u30a2\u30ca\u30ea\u30b9\u30c8\u3067\u3059\u3002\n\u4ee5\u4e0b\u306e\u30cb\u30e5\u30fc\u30b9\u8a18\u4e8b\u30ea\u30b9\u30c8\u3092\u5206\u6790\u3057\u3001\u6307\u5b9a\u3055\u308c\u305fJSON\u5f62\u5f0f\u3067\u7d50\u679c\u3092\u51fa\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n\n# \u6307\u793a\n1. \u8a18\u4e8b\u7fa4\u5168\u4f53\u304b\u3089\u3001\u6700\u8fd1\u306e\u300c\u3075\u308b\u3055\u3068\u7d0d\u7a0e\u300d\u306b\u95a2\u3059\u308b\u6700\u3082\u91cd\u8981\u306a\u30c8\u30ec\u30f3\u30c9\u3084\u8a71\u984c\u30923\u3064\u306b\u8981\u7d04\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n2. \u8981\u7d04\u306e\u4e2d\u304b\u3089\u3001\u6700\u3082\u5e02\u5834\u8abf\u67fb\u306b\u9069\u3057\u3066\u3044\u308b\u3068\u601d\u308f\u308c\u308b\u5358\u4e00\u306e\u691c\u7d22\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u62bd\u51fa\u3057\u3066\u304f\u3060\u3055\u3044\u3002**\u3082\u3057\u9069\u5207\u306a\u30ad\u30fc\u30ef\u30fc\u30c9\u304c\u62bd\u51fa\u3067\u304d\u306a\u3044\u5834\u5408\u306f\u3001\u4ee3\u308f\u308a\u306b\u300c\u3075\u308b\u3055\u3068\u7d0d\u7a0e\u300d\u3068\u3044\u3046\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u4f7f\u7528\u3057\u3066\u304f\u3060\u3055\u3044\u3002**\n3. \u4ee5\u4e0b\u306eJSON\u5f62\u5f0f\u306b\u53b3\u5bc6\u306b\u5f93\u3063\u3066\u3001\u7d50\u679c\u306e\u307f\u3092\u51fa\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n\n# \u51fa\u529b\u5f62\u5f0f\n{\n  \"summary\": \"\u3053\u3053\u306b3\u3064\u306e\u30c8\u30ec\u30f3\u30c9\u8981\u7d04\u3092\u7b87\u6761\u66f8\u304d\u3067\u8a18\u8ff0\",\n  \"keyword\": \"\u3053\u3053\u306b\u62bd\u51fa\u3057\u305f\u5358\u4e00\u306e\u691c\u7d22\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u8a18\u8ff0\"\n}\n# \u51fa\u529b\u5f62\u5f0f \u306b\u53b3\u5bc6\u306b\u5f93\u3063\u3066\u304f\u3060\u3055\u3044"
        },
        "promptType": "define"
      },
      "typeVersion": 3
    },
    {
      "id": "fbe58b3d-9328-4fed-97f6-8aac734b2b1b",
      "name": "OpenRouter Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        1320,
        592
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "e2975c7c-6e3b-41bc-8022-85a79d0ae7a7",
      "name": "\u30cb\u30e5\u30fc\u30b9\u6574\u5f62",
      "type": "n8n-nodes-base.set",
      "position": [
        1024,
        368
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "8f01d309-8111-45d5-9156-323b1230f0e2",
              "name": "news_list",
              "type": "string",
              "value": "={{ $items().slice(0, 5).map(item => `\u30bf\u30a4\u30c8\u30eb\uff1a${item.json.title}\\n\u6982\u8981\uff1a${item.json.contentSnippet}`).join('\\n\\n---\\n\\n') }}"
            }
          ]
        }
      },
      "executeOnce": true,
      "typeVersion": 3.4
    },
    {
      "id": "eec9bc89-826f-407b-8739-a1d0183c0547",
      "name": "Code in JavaScript",
      "type": "n8n-nodes-base.code",
      "position": [
        1600,
        368
      ],
      "parameters": {
        "jsCode": "const items = $input.all();\n\nfor (const item of items) {\n  try {\n    // AI\u306e\u51fa\u529b\u3092JSON\u3068\u3057\u3066\u89e3\u6790\u3059\u308b\n    const aiOutput = JSON.parse(item.json.text);\n    \n    // \u5143\u306e\u30c7\u30fc\u30bf\u306b\u3001\u89e3\u6790\u3057\u305f\u30c7\u30fc\u30bf\u3092\u8ffd\u52a0\u3059\u308b\n    item.json.parsedData = aiOutput;\n    \n  } catch (error) {\n    // \u89e3\u6790\u306b\u5931\u6557\u3057\u305f\u5834\u5408\u306e\u30a8\u30e9\u30fc\u51e6\u7406\n    item.json.error = 'Failed to parse JSON';\n    item.json.parsedData = {}; // \u7a7a\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u8a2d\u5b9a\n  }\n  \n  // \u2605\u2605\u2605 \u3053\u3053\u304b\u3089\u304c\u8ffd\u52a0\u30fb\u4fee\u6b63\u90e8\u5206 \u2605\u2605\u2605\n  let keyword = item.json.parsedData.keyword || ''; // keyword\u3092\u53d6\u5f97\u3057\u3001\u7121\u3051\u308c\u3070\u7a7a\u6587\u5b57\n  \n  // \u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u524d\u5f8c\u306e\u7a7a\u767d\u30fb\u6539\u884c\u3092\u524a\u9664\n  keyword = keyword.trim().replace(/\\n/g, '');\n  \n  // \u30ad\u30fc\u30ef\u30fc\u30c9\u304c\u7a7a\u3060\u3063\u305f\u5834\u5408\u3001\u4ee3\u66ff\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u8a2d\u5b9a\u3059\u308b\n  if (keyword === '') {\n    keyword = '\u3075\u308b\u3055\u3068\u7d0d\u7a0e'; // \u3053\u3053\u3067\u5f37\u5236\u7684\u306b\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u3092\u8a2d\u5b9a\n  }\n  \n  // \u51e6\u7406\u5f8c\u306e\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u5143\u306e\u30c7\u30fc\u30bf\u306b\u53cd\u6620\n  item.json.parsedData.keyword = keyword;\n  // \u2605\u2605\u2605 \u8ffd\u52a0\u30fb\u4fee\u6b63\u90e8\u5206\u3053\u3053\u307e\u3067 \u2605\u2605\u2605\n}\n\nreturn items;"
      },
      "typeVersion": 2
    },
    {
      "id": "e8234df2-17f0-4b10-a2a7-e459e1083e97",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        1824,
        368
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "6b4bfc6a-7665-4fb6-bce5-93e704927535",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ ($json.parsedData?.keyword ?? '').trim() }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "e3ef31c0-89f3-43c5-86f9-981ae1716048",
      "name": "No Operation, do nothing",
      "type": "n8n-nodes-base.noOp",
      "position": [
        2048,
        464
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "6d785ec5-af11-4c9c-b1a6-707ea00911dc",
      "name": "Send a message",
      "type": "n8n-nodes-base.slack",
      "position": [
        3296,
        272
      ],
      "parameters": {
        "text": "={{ $json.slack_text }}",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "C09V7LVKTGD",
          "cachedResultName": "\u3075\u308b\u3055\u3068\u7d0d\u7a0e"
        },
        "otherOptions": {},
        "authentication": "oAuth2"
      },
      "typeVersion": 2.3
    },
    {
      "id": "414684e8-f068-4827-86b0-797514029ab9",
      "name": "Report AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        2720,
        272
      ],
      "parameters": {
        "text": "=",
        "options": {
          "systemMessage": "\u3042\u306a\u305f\u306f\u512a\u79c0\u306a\u30ea\u30b5\u30fc\u30c1\u30a2\u30ca\u30ea\u30b9\u30c8\u3067\u3059\u3002\n\u5165\u529b\u3068\u3057\u3066\u63d0\u4f9b\u3055\u308c\u305fGoogle Trends\u306e\u30c7\u30fc\u30bf\uff08\u30ad\u30fc\u30ef\u30fc\u30c9\u3068\u6642\u7cfb\u5217\u30c7\u30fc\u30bf\uff09\u3092\u5206\u6790\u3057\u3001\u4ee5\u4e0b\u306e\u5f62\u5f0f\u3067\u7c21\u6f54\u306a\u30ec\u30dd\u30fc\u30c8\u3092\u4f5c\u6210\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n\n# \u3075\u308b\u3055\u3068\u7d0d\u7a0e\u30c8\u30ec\u30f3\u30c9\u5206\u6790\uff1a{{ $json.keyword }}\n\n## \u62bd\u51fa\u30ad\u30fc\u30ef\u30fc\u30c9\n{{ $json.keyword }}\n\n## \u691c\u7d22\u30dc\u30ea\u30e5\u30fc\u30e0\u306e\u52d5\u5411\n\uff08\u63d0\u4f9b\u3055\u308c\u305f\u30c7\u30fc\u30bf\u306b\u57fa\u3065\u304d\u3001\u904e\u53bb\u306e\u691c\u7d22\u30dc\u30ea\u30e5\u30fc\u30e0\u306e\u50be\u5411\u3001\u5897\u6e1b\u306e\u7406\u7531\u306a\u3069\u3092200\u5b57\u7a0b\u5ea6\u3067\u7c21\u6f54\u306b\u8981\u7d04\u3057\u3066\u304f\u3060\u3055\u3044\u3002\uff09\n\n## \u30c7\u30fc\u30bf\u30bd\u30fc\u30b9\nGoogle Trends\uff08\u904e\u53bb12\u30f6\u6708\uff09\n\n\u7d50\u679c\u306eMarkdown\u30c6\u30ad\u30b9\u30c8\u306e\u307f\u3092\u51fa\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002"
        },
        "promptType": "define"
      },
      "typeVersion": 3
    },
    {
      "id": "95392515-173f-45a1-80f4-7a951a21fb85",
      "name": "OpenRouter Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        2792,
        496
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "8cf1a87a-c26e-4893-95a7-5fa6bb159557",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        176
      ],
      "parameters": {
        "width": 512,
        "height": 432,
        "content": "## How it works\nw acts as a specialized market analyst for Japan's \"Furusato Nozei\" (Hometown Tax) system. It automates the process of monitoring related news, validating keyword popularity via search trends, and delivering a concise, strategic report to Slack.\n\nBy combining RSS feeds, AI agents, and real-time search data, this template helps marketers and municipal researchers stay on top of the highly competitive Hometown Tax market without manual searching.\n\n## \ud83d\udee0\ufe0f Requirements\nTo use this workflow, you will need:\n- **n8n** (Version 1.0 or later recommended).\n- **OpenRouter API Key** (or you can swap the model nodes for OpenAI/Anthropic).\n- **SerpApi Key** (Required to fetch Google Trends data programmatically).\n- **Slack Account** (with permissions to post to a channel)."
      },
      "typeVersion": 1
    },
    {
      "id": "95eb64b5-40e5-4259-aedf-8b19956ef31a",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2016,
        64
      ],
      "parameters": {
        "color": 7,
        "width": 182,
        "height": 256,
        "content": "**Regional Settings:**\n   - The workflow is pre-set for Japan (`jp` / `ja`). If you need to change this, check the `Workflow Configuration` and `Google Trends API` nodes.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "a0847bb1-172d-46a6-a0d9-f0f696b38c30",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1248,
        640
      ],
      "parameters": {
        "color": 7,
        "width": 256,
        "content": "\n\n\n\n\n\n**Configure Credentials:**\n   - Add your OpenRouter API key to the Chat Model nodes."
      },
      "typeVersion": 1
    },
    {
      "id": "6cbf02d3-8351-4378-b8a8-7e4d85aad732",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        560,
        208
      ],
      "parameters": {
        "color": 7,
        "width": 166,
        "height": 208,
        "content": "**Schedule:**\n   - Enable the `Schedule Trigger` node to run at your preferred time (default is 9:00 AM JST)."
      },
      "typeVersion": 1
    },
    {
      "id": "bd1f4d47-05d8-4593-b608-eab70f5030e1",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        768,
        208
      ],
      "parameters": {
        "color": 7,
        "width": 176,
        "height": 192,
        "content": "**Check the RSS Feed:**\n   - The `RSS Read` node is pre-configured for \"Furusato Nozei\" (\u3075\u308b\u3055\u3068\u7d0d\u7a0e). You can leave this as is."
      },
      "typeVersion": 1
    },
    {
      "id": "2a56c3f6-847e-45f5-8199-08e89ebb3866",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2240,
        112
      ],
      "parameters": {
        "color": 7,
        "width": 150,
        "height": 208,
        "content": "**Configure Credentials:**\n   - Add your SerpApi key to the `Google Trends API` node."
      },
      "typeVersion": 1
    },
    {
      "id": "dea9c122-e76a-4b3a-8d4f-519bf54c217c",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3248,
        160
      ],
      "parameters": {
        "color": 7,
        "width": 176,
        "content": "**Configure Credentials:**\n   - Connect your Slack account in the `Send a message` node."
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Workflow Configuration",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "RSS Read": {
      "main": [
        [
          {
            "node": "\u30cb\u30e5\u30fc\u30b9\u6574\u5f62",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Report AI Agent": {
      "main": [
        [
          {
            "node": "Format Final Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "RSS Read",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Trends API": {
      "main": [
        [
          {
            "node": "Aggregate Research Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u30cb\u30e5\u30fc\u30b9\u6574\u5f62": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Final Report": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Report AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Workflow Configuration": {
      "main": [
        [
          {
            "node": "Google Trends API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate Research Data": {
      "main": [
        [
          {
            "node": "Report AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}