{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "060d1587-2460-4658-b2fa-429639e6da83",
      "name": "Weekly Monday 9AM Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        320,
        64
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks",
              "triggerAtDay": [
                1
              ],
              "triggerAtHour": 9
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "93a5b983-221c-49eb-afc9-d5bf323cc225",
      "name": "Workflow Configuration",
      "type": "n8n-nodes-base.set",
      "position": [
        544,
        64
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "id-1",
              "name": "searchKeyword",
              "type": "string",
              "value": "2025\u5e74 AI\u30c4\u30fc\u30eb"
            },
            {
              "id": "id-2",
              "name": "apifyActorId",
              "type": "string",
              "value": "apify/google-search-scraper"
            },
            {
              "id": "id-3",
              "name": "notionDatabaseId",
              "type": "string",
              "value": "<__PLACEHOLDER_VALUE__Notion Database ID__>"
            },
            {
              "id": "id-4",
              "name": "slackChannel",
              "type": "string",
              "value": "<__PLACEHOLDER_VALUE__Slack Channel ID or Name__>"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "9a32f684-f69e-4e71-a6e1-8a540267aa30",
      "name": "AI Editorial Meeting - Generate 3 Article Ideas",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        992,
        64
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o",
          "cachedResultName": "GPT-4O"
        },
        "options": {},
        "responses": {
          "values": [
            {
              "content": "=\u3042\u306a\u305f\u306fWeb\u30e1\u30c7\u30a3\u30a2\u306e\u7de8\u96c6\u9577\u3067\u3059\u3002\n\u4ee5\u4e0b\u306eGoogle\u691c\u7d22\u7d50\u679c\u306e\u60c5\u5831\u3092\u5143\u306b\u30013\u3064\u306e\u7570\u306a\u308b\u5207\u308a\u53e3\u3067\u30d6\u30ed\u30b0\u8a18\u4e8b\u306e\u4f01\u753b\u3092\u7acb\u3066\u3066\u304f\u3060\u3055\u3044\u3002\n\n\u3010\u691c\u7d22\u7d50\u679c\u30c7\u30fc\u30bf\u3011\n{{ JSON.stringify($input.all()) }}\n\n\u3010\u6761\u4ef6\u3011\n\u5fc5\u305a\u4ee5\u4e0b\u306eJSON\u5f62\u5f0f\u306e\u914d\u5217\u306e\u307f\u3092\u51fa\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u4f59\u8a08\u306a\u4f1a\u8a71\u3084\u6328\u62f6\u306f\u4e00\u5207\u4e0d\u8981\u3067\u3059\u3002\n\n[\n  {\n    \"angle\": \"\u521d\u5fc3\u8005\u5411\u3051\",\n    \"title\": \"\u8a18\u4e8b\u30bf\u30a4\u30c8\u30eb\",\n    \"outline\": \"\u8a18\u4e8b\u306e\u69cb\u6210\u6848\",\n    \"image_prompt\": \"Image generation prompt in English\"\n  },\n  {\n    \"angle\": \"\u8f9b\u53e3\u30ec\u30d3\u30e5\u30fc\",\n    \"title\": \"\u8a18\u4e8b\u30bf\u30a4\u30c8\u30eb\",\n    \"outline\": \"\u8a18\u4e8b\u306e\u69cb\u6210\u6848\",\n    \"image_prompt\": \"Image generation prompt in English\"\n  },\n  {\n    \"angle\": \"\u30d3\u30b8\u30cd\u30b9\u6d3b\u7528\",\n    \"title\": \"\u8a18\u4e8b\u30bf\u30a4\u30c8\u30eb\",\n    \"outline\": \"\u8a18\u4e8b\u306e\u69cb\u6210\u6848\",\n    \"image_prompt\": \"Image generation prompt in English\"\n  }\n]"
            }
          ]
        },
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "58c39f28-8e89-4fa2-b971-b42e4bea5438",
      "name": "Parse Article Ideas JSON",
      "type": "n8n-nodes-base.code",
      "position": [
        1344,
        64
      ],
      "parameters": {
        "jsCode": "const items = $input.all();\nif (items.length === 0) return [];\nconst item = items[0].json;\n\n// \u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u306e\u69cb\u9020\u306b\u5408\u308f\u305b\u3066\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\nlet content = \"\";\n\n// \u30d1\u30bf\u30fc\u30f3A: \u4eca\u56de\u306e\u3042\u306a\u305f\u306e\u74b0\u5883\u306e\u69cb\u9020\nif (item.output && item.output[0] && item.output[0].content && item.output[0].content[0]) {\n   content = item.output[0].content[0].text;\n} \n// \u30d1\u30bf\u30fc\u30f3B: \u5225\u306e\u30d1\u30bf\u30fc\u30f3\u306e\u69cb\u9020\uff08\u5ff5\u306e\u305f\u3081\uff09\nelse if (item.message && item.message.content) {\n   content = item.message.content;\n}\nelse {\n   // \u898b\u3064\u304b\u3089\u306a\u3044\u5834\u5408\u306f\u5f37\u5236\u7684\u306b\u6587\u5b57\u5217\u5316\u3057\u3066\u63a2\u3059\n   content = JSON.stringify(item);\n}\n\n// [ ] \u3067\u56f2\u307e\u308c\u305fJSON\u90e8\u5206\u3092\u63a2\u3057\u3066\u5207\u308a\u51fa\u3059\nconst startIndex = content.indexOf('[');\nconst endIndex = content.lastIndexOf(']') + 1;\n\nlet ideas = [];\nif (startIndex !== -1 && endIndex !== 0) {\n  const jsonString = content.substring(startIndex, endIndex);\n  try {\n    ideas = JSON.parse(jsonString);\n  } catch (e) {\n    console.log(\"Parse Error\");\n  }\n}\n\nreturn ideas.map(idea => ({ json: idea }));"
      },
      "typeVersion": 2
    },
    {
      "id": "f940701e-d03e-4cc6-9898-615fe7ccaa41",
      "name": "AI Writer - Generate Article Content",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        1568,
        64
      ],
      "parameters": {
        "options": {},
        "messages": {
          "values": [
            {
              "content": "=\u3042\u306a\u305f\u306f\u30d7\u30ed\u306e\u30e9\u30a4\u30bf\u30fc\u3067\u3059\u3002\u4ee5\u4e0b\u306e\u30bf\u30a4\u30c8\u30eb\u3068\u69cb\u6210\u6848\u306b\u57fa\u3065\u304d\u3001\u30d6\u30ed\u30b0\u8a18\u4e8b\u306e\u672c\u6587\u3092\u57f7\u7b46\u3057\u3066\u304f\u3060\u3055\u3044\u3002\nHTML\u30bf\u30b0\u306f\u4f7f\u308f\u305a\u3001Markdown\u5f62\u5f0f\uff08\u898b\u51fa\u3057\u306f ## \u306a\u3069\uff09\u3067\u66f8\u3044\u3066\u304f\u3060\u3055\u3044\u3002\n\n\u3010\u30bf\u30a4\u30c8\u30eb\u3011\n{{ $('Parse Article Ideas JSON').item.json.title }}\n\n\u3010\u69cb\u6210\u6848\u3011\n{{ $('Parse Article Ideas JSON').item.json.outline }}"
            }
          ]
        },
        "resource": "conversation"
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "0cfedf3a-64c2-4a6a-ab56-ad01e0a05321",
      "name": "DALL-E Generate Cover Image",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        1792,
        64
      ],
      "parameters": {
        "prompt": "={{ $('Parse Article Ideas JSON').item.json.image_prompt }}",
        "options": {
          "size": "1024x1024",
          "dalleQuality": "standard",
          "returnImageUrls": true
        },
        "resource": "image"
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "febe370c-ec23-41c9-a156-9620d3567d9b",
      "name": "Save Article to Notion",
      "type": "n8n-nodes-base.notion",
      "position": [
        2016,
        64
      ],
      "parameters": {
        "title": "={{ $('Parse Article Ideas JSON').item.json.title }}",
        "blockUi": {
          "blockValues": [
            {
              "url": "={{ $json.url }}",
              "type": "image"
            },
            {
              "text": {
                "text": [
                  {
                    "text": "={{ $('AI Editorial Meeting - Generate 3 Article Ideas').item.json.output[0].content[0].text }}",
                    "annotationUi": {}
                  }
                ]
              },
              "richText": true
            }
          ]
        },
        "options": {},
        "resource": "databasePage",
        "databaseId": {
          "__rl": true,
          "mode": "list",
          "value": "2b264f81-26ed-8066-8b2b-c37250fae0bf",
          "cachedResultUrl": "https://www.notion.so/2b264f8126ed80668b2bc37250fae0bf",
          "cachedResultName": "n8n sigodeki"
        }
      },
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "a98d8a71-b35b-4d9e-b2d9-ce039f55aa81",
      "name": "Aggregate All Articles",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        2240,
        64
      ],
      "parameters": {
        "include": "specifiedFields",
        "options": {},
        "aggregate": "aggregateAllItemData",
        "fieldsToInclude": "url"
      },
      "typeVersion": 1
    },
    {
      "id": "2abfa925-0ef4-4937-a1ad-b5ad1e1127f1",
      "name": "Send Completion Notification to Slack",
      "type": "n8n-nodes-base.slack",
      "position": [
        2464,
        64
      ],
      "parameters": {
        "text": "=\u2705 *AI\u7de8\u96c6\u90e8\u30ec\u30dd\u30fc\u30c8*\n\n3\u672c\u306e\u8a18\u4e8b\u6848\u3092Notion\u306b\u683c\u7d0d\u3057\u307e\u3057\u305f\uff01\n\n{{ $json.url.map((url, i) => `${i+1}. ${url}`).join('\\n') }}\n\n\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044 \ud83d\udcdd",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "name",
          "value": "=all-n8n-shigodeki"
        },
        "otherOptions": {},
        "authentication": "oAuth2"
      },
      "credentials": {
        "slackOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "e9a0f716-2ced-412b-9226-0e562eed6fee",
      "name": "Run an Actor and get dataset",
      "type": "@apify/n8n-nodes-apify.apify",
      "position": [
        768,
        64
      ],
      "parameters": {
        "actorId": {
          "__rl": true,
          "mode": "list",
          "value": "nFJndFXA5zjCTuudP",
          "cachedResultUrl": "https://console.apify.com/actors/nFJndFXA5zjCTuudP/input",
          "cachedResultName": "Google Search Results Scraper (apify/google-search-scraper)"
        },
        "operation": "Run actor and get dataset",
        "customBody": "={\n  \"queries\": \"{{ $('Workflow Configuration').item.json.searchKeyword }}\",\n  \"maxPagesPerQuery\": 1,\n  \"resultsPerPage\": 5,\n  \"countryCode\": \"jp\",\n  \"languageCode\": \"ja\"\n}"
      },
      "credentials": {
        "apifyApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "51134bd2-393a-47b4-b653-c797a90c16ac",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -400,
        -144
      ],
      "parameters": {
        "width": 640,
        "height": 368,
        "content": "##  How it works\nThis workflow automates the process of creating trend-based blog posts.\n1. **Schedule & Config**: Triggers weekly and defines the search keyword.\n2. **Research**: Scrapes Google/Social trends via Apify and analyzes them with AI.\n3. **Drafting**: Generates a full article and a DALL-E 3 cover image based on the analysis.\n4. **Publishing**: Saves the draft to Notion and notifies the team on Slack.\n\n## Setup steps\n1. **Credentials**: Configure your credentials for **Apify**, **OpenAI**, **Notion**, and **Slack**.\n2. **Configuration**: Open the **'Workflow Configuration'** node and set your target `Keyword`.\n3. **Apify Actor**: Ensure you have the Google Search Scraper actor available in your Apify account.\n4. **Notion**: Select your target Database in the Notion node."
      },
      "typeVersion": 1
    },
    {
      "id": "e1d1e49c-6ab2-44be-bb1a-ca400319d861",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        272,
        -144
      ],
      "parameters": {
        "color": 7,
        "width": 400,
        "height": 368,
        "content": "## 1. Configuration\nSet the schedule and target keywords here."
      },
      "typeVersion": 1
    },
    {
      "id": "8c44a4f7-2553-4ee4-9e4e-d4cbfb52f946",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        704,
        -144
      ],
      "parameters": {
        "color": 7,
        "width": 768,
        "height": 368,
        "content": "## 2. Research & Analysis\nScrapes trend data via Apify and structures the article plan using AI."
      },
      "typeVersion": 1
    },
    {
      "id": "948e68e7-8f68-4e1d-bb3d-75c7d336e6a7",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1504,
        -144
      ],
      "parameters": {
        "color": 7,
        "width": 432,
        "height": 368,
        "content": "## 3. Content Creation\nWrites the article body and generates a cover image."
      },
      "typeVersion": 1
    },
    {
      "id": "9fd4835a-b845-4084-8b63-e08fe5765617",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1968,
        -144
      ],
      "parameters": {
        "color": 7,
        "width": 624,
        "height": 368,
        "content": "## 4. Save & Notify\nSaves the draft to Notion and sends a report to Slack."
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Aggregate All Articles": {
      "main": [
        [
          {
            "node": "Send Completion Notification to Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Article to Notion": {
      "main": [
        [
          {
            "node": "Aggregate All Articles",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Workflow Configuration": {
      "main": [
        [
          {
            "node": "Run an Actor and get dataset",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Article Ideas JSON": {
      "main": [
        [
          {
            "node": "AI Writer - Generate Article Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Weekly Monday 9AM Trigger": {
      "main": [
        [
          {
            "node": "Workflow Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "DALL-E Generate Cover Image": {
      "main": [
        [
          {
            "node": "Save Article to Notion",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run an Actor and get dataset": {
      "main": [
        [
          {
            "node": "AI Editorial Meeting - Generate 3 Article Ideas",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Writer - Generate Article Content": {
      "main": [
        [
          {
            "node": "DALL-E Generate Cover Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Editorial Meeting - Generate 3 Article Ideas": {
      "main": [
        [
          {
            "node": "Parse Article Ideas JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}