{
  "name": "WF02: pSEO\u8a18\u4e8b\u6295\u7a3f",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 10 * * *"
            }
          ]
        }
      },
      "id": "schedule-trigger",
      "name": "\u6bce\u65e510\u6642\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "1WwyRbzS7XfVqcaH6Ipe2JFqMtD-X1c5NKXJViaZAtvM",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "articles",
          "mode": "name"
        },
        "filtersUI": {
          "values": [
            {
              "lookupColumn": "status",
              "lookupValue": "pending"
            }
          ]
        },
        "options": {
          "returnFirstMatch": false
        }
      },
      "id": "sheets-read",
      "name": "Google Sheets: \u672a\u6295\u7a3f\u8a18\u4e8b\u30ad\u30e5\u30fc\u53d6\u5f97",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        460,
        300
      ]
    },
    {
      "parameters": {
        "batchSize": 1,
        "options": {}
      },
      "id": "split-in-batches",
      "name": "1\u8a18\u4e8b\u305a\u3064\u51e6\u7406",
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        680,
        300
      ]
    },
    {
      "parameters": {
        "mode": "expression",
        "output": "={{ $json.article_type }}",
        "rules": {
          "rules": [
            {
              "value": "review"
            },
            {
              "value": "comparison"
            },
            {
              "value": "howto"
            }
          ]
        }
      },
      "id": "route-by-type",
      "name": "\u8a18\u4e8b\u30bf\u30a4\u30d7\u5224\u5b9a",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3,
      "position": [
        900,
        300
      ]
    },
    {
      "parameters": {
        "resource": "chat",
        "operation": "complete",
        "modelId": {
          "__rl": true,
          "value": "gemini-2.5-flash",
          "mode": "id"
        },
        "messages": {
          "values": [
            {
              "content": "=\u3042\u306a\u305f\u306fVTuber\u5c02\u9580\u306eSEO\u30e9\u30a4\u30bf\u30fc\u3067\u3059\u3002\u4ee5\u4e0b\u306e\u60c5\u5831\u3092\u5143\u306b\u3001SEO\u306b\u6700\u9069\u5316\u3055\u308c\u305f\u7d39\u4ecb\u30fb\u30ec\u30d3\u30e5\u30fc\u8a18\u4e8b\u3092\u65e5\u672c\u8a9e\u3067\u66f8\u3044\u3066\u304f\u3060\u3055\u3044\u3002\n\n\u5bfe\u8c61VTuber: {{ $json.target_name }}\n\u30bf\u30fc\u30b2\u30c3\u30c8\u30ad\u30fc\u30ef\u30fc\u30c9: {{ $json.target_keywords }}\n\u30b9\u30e9\u30c3\u30b0: {{ $json.slug }}\n\n\u8a18\u4e8b\u306e\u69cb\u6210\uff082000\u301c3000\u6587\u5b57\uff09:\n## {{ $json.target_name }}\u3068\u306f\uff1f\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u30fb\u6d3b\u52d5\u5c65\u6b74\n\uff08\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u6982\u8981\u30fb\u30c7\u30d3\u30e5\u30fc\u307e\u3067\u306e\u7d4c\u7def\uff09\n\n## {{ $json.target_name }}\u306e\u914d\u4fe1\u30b9\u30bf\u30a4\u30eb\u30fb\u9b45\u529b\n\uff08\u7279\u5fb4\u7684\u306a\u30b3\u30f3\u30c6\u30f3\u30c4\u30fb\u8996\u8074\u8005\u3068\u306e\u95a2\u4fc2\u6027\uff09\n\n## \u4ee3\u8868\u7684\u306a\u914d\u4fe1\u30fb\u898b\u3069\u3053\u308d\n\uff08\u4eba\u6c17\u30b3\u30f3\u30c6\u30f3\u30c4\u30fb\u4f01\u753b\u306e\u7d39\u4ecb\uff09\n\n## {{ $json.target_name }}\u306b\u95a2\u9023\u3059\u308b\u30b0\u30c3\u30ba\u30fb\u516c\u5f0f\u60c5\u5831\n\uff08\u30b0\u30c3\u30ba\u30fb\u30d5\u30a1\u30f3\u30af\u30e9\u30d6\u60c5\u5831\uff09\n\n## \u307e\u3068\u3081\u30fb\u8996\u8074\u304a\u3059\u3059\u3081\u30dd\u30a4\u30f3\u30c8\n\uff08\u3069\u3093\u306a\u4eba\u306b\u304a\u3059\u3059\u3081\u304b\uff09\n\n\u4ee5\u4e0b\u306eJSON\u5f62\u5f0f\u3067\u8fd4\u3057\u3066\u304f\u3060\u3055\u3044:\n{\n  \"title\": \"SEO\u30bf\u30a4\u30c8\u30eb\uff0860\u6587\u5b57\u4ee5\u5185\uff09\",\n  \"meta_description\": \"\u30e1\u30bf\u30c7\u30a3\u30b9\u30af\u30ea\u30d7\u30b7\u30e7\u30f3\uff08120\u6587\u5b57\u4ee5\u5185\uff09\",\n  \"content\": \"\u672c\u6587\uff08HTML\u5f62\u5f0f\u3001\u898b\u51fa\u3057\u306fh2/h3\u30bf\u30b0\u4f7f\u7528\uff09\",\n  \"excerpt\": \"\u629c\u7c8b\uff08140\u6587\u5b57\u4ee5\u5185\uff09\"\n}",
              "role": "user"
            }
          ]
        },
        "options": {
          "temperature": 0.7,
          "maxOutputTokens": 4096
        }
      },
      "id": "gemini-review",
      "name": "Gemini: review\u8a18\u4e8b\u751f\u6210",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        1120,
        160
      ]
    },
    {
      "parameters": {
        "resource": "chat",
        "operation": "complete",
        "modelId": {
          "__rl": true,
          "value": "gemini-2.5-flash",
          "mode": "id"
        },
        "messages": {
          "values": [
            {
              "content": "=\u3042\u306a\u305f\u306fVTuber\u5c02\u9580\u306eSEO\u30e9\u30a4\u30bf\u30fc\u3067\u3059\u3002\u4ee5\u4e0b\u306e\u60c5\u5831\u3092\u5143\u306b\u30012\u4eba\u306eVTuber\u3092\u6bd4\u8f03\u3059\u308b\u8a18\u4e8b\u3092\u65e5\u672c\u8a9e\u3067\u66f8\u3044\u3066\u304f\u3060\u3055\u3044\u3002\n\n\u6bd4\u8f03\u5bfe\u8c61A: {{ $json.target_name }}\n\u6bd4\u8f03\u5bfe\u8c61B: {{ $json.compare_name }}\n\u30bf\u30fc\u30b2\u30c3\u30c8\u30ad\u30fc\u30ef\u30fc\u30c9: {{ $json.target_keywords }}\n\n\u8a18\u4e8b\u306e\u69cb\u6210\uff081500\u301c2500\u6587\u5b57\uff09:\n## {{ $json.target_name }}\u3068{{ $json.compare_name }}\u306e\u9055\u3044\u306f\uff1f\n\uff08\u6982\u8981\u30fb\u6bd4\u8f03\u8868\uff09\n\n## {{ $json.target_name }}\u306e\u7279\u5fb4\n## {{ $json.compare_name }}\u306e\u7279\u5fb4\n## \u3069\u3061\u3089\u3092\u898b\u308b\u3079\u304d\uff1f\u30bf\u30a4\u30d7\u5225\u304a\u3059\u3059\u3081\n## \u307e\u3068\u3081\n\n\u4ee5\u4e0b\u306eJSON\u5f62\u5f0f\u3067\u8fd4\u3057\u3066\u304f\u3060\u3055\u3044:\n{\n  \"title\": \"SEO\u30bf\u30a4\u30c8\u30eb\uff0860\u6587\u5b57\u4ee5\u5185\uff09\",\n  \"meta_description\": \"\u30e1\u30bf\u30c7\u30a3\u30b9\u30af\u30ea\u30d7\u30b7\u30e7\u30f3\uff08120\u6587\u5b57\u4ee5\u5185\uff09\",\n  \"content\": \"\u672c\u6587\uff08HTML\u5f62\u5f0f\uff09\",\n  \"excerpt\": \"\u629c\u7c8b\uff08140\u6587\u5b57\u4ee5\u5185\uff09\"\n}",
              "role": "user"
            }
          ]
        },
        "options": {
          "temperature": 0.7,
          "maxOutputTokens": 4096
        }
      },
      "id": "gemini-comparison",
      "name": "Gemini: comparison\u8a18\u4e8b\u751f\u6210",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        1120,
        320
      ]
    },
    {
      "parameters": {
        "resource": "chat",
        "operation": "complete",
        "modelId": {
          "__rl": true,
          "value": "gemini-2.5-flash",
          "mode": "id"
        },
        "messages": {
          "values": [
            {
              "content": "=\u3042\u306a\u305f\u306fVTuber\u5c02\u9580\u306eSEO\u30e9\u30a4\u30bf\u30fc\u3067\u3059\u3002\u4ee5\u4e0b\u306e\u60c5\u5831\u3092\u5143\u306b\u3001\u7279\u5b9a\u30c6\u30fc\u30de\u306eVTuber\u30ac\u30a4\u30c9\u30fb\u304a\u3059\u3059\u3081\u8a18\u4e8b\u3092\u65e5\u672c\u8a9e\u3067\u66f8\u3044\u3066\u304f\u3060\u3055\u3044\u3002\n\n\u30c6\u30fc\u30de: {{ $json.theme }}\n\u30bf\u30fc\u30b2\u30c3\u30c8\u30ad\u30fc\u30ef\u30fc\u30c9: {{ $json.target_keywords }}\n\u53d6\u308a\u4e0a\u3052\u308bVTuber: {{ $json.featured_vtubers }}\n\n\u8a18\u4e8b\u306e\u69cb\u6210\uff082500\u301c4000\u6587\u5b57\uff09:\n## {{ $json.theme }}\u306eVTuber\u304a\u3059\u3059\u3081\u4e00\u89a7\n\uff08\u9078\u5b9a\u57fa\u6e96\u30fb\u3053\u306e\u8a18\u4e8b\u3067\u7d39\u4ecb\u3059\u308b\u5185\u5bb9\uff09\n\n## \u304a\u3059\u3059\u3081VTuber\u30e9\u30f3\u30ad\u30f3\u30b0\n\uff08\u5404VTuber\u306e\u7d39\u4ecb\u30fb\u7279\u5fb4\u30fb\u767b\u9332\u8005\u6570\u30fb\u4ee3\u8868\u914d\u4fe1\uff09\n\n## {{ $json.theme }}\u7cfbVTuber\u306e\u898b\u65b9\u30fb\u697d\u3057\u307f\u65b9\n\uff08\u521d\u5fc3\u8005\u5411\u3051Tips\uff09\n\n## \u307e\u3068\u3081\n\n\u4ee5\u4e0b\u306eJSON\u5f62\u5f0f\u3067\u8fd4\u3057\u3066\u304f\u3060\u3055\u3044:\n{\n  \"title\": \"SEO\u30bf\u30a4\u30c8\u30eb\uff0860\u6587\u5b57\u4ee5\u5185\uff09\",\n  \"meta_description\": \"\u30e1\u30bf\u30c7\u30a3\u30b9\u30af\u30ea\u30d7\u30b7\u30e7\u30f3\uff08120\u6587\u5b57\u4ee5\u5185\uff09\",\n  \"content\": \"\u672c\u6587\uff08HTML\u5f62\u5f0f\uff09\",\n  \"excerpt\": \"\u629c\u7c8b\uff08140\u6587\u5b57\u4ee5\u5185\uff09\"\n}",
              "role": "user"
            }
          ]
        },
        "options": {
          "temperature": 0.7,
          "maxOutputTokens": 4096
        }
      },
      "id": "gemini-howto",
      "name": "Gemini: howto\u8a18\u4e8b\u751f\u6210",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        1120,
        480
      ]
    },
    {
      "parameters": {
        "jsCode": "// \u5404\u30b8\u30a7\u30cd\u30ec\u30fc\u30bf\u30fc\u304b\u3089\u306e\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u30de\u30fc\u30b8\nconst articleData = $('1\u8a18\u4e8b\u305a\u3064\u51e6\u7406').item.json;\nconst rawContent = $input.item.json.message?.content || \n                   $input.item.json.candidates?.[0]?.content?.parts?.[0]?.text || '';\n\n// JSON\u90e8\u5206\u3092\u62bd\u51fa\nlet parsed = { title: '', meta_description: '', content: '', excerpt: '' };\ntry {\n  const jsonMatch = rawContent.match(/\\{[\\s\\S]*\\}/);\n  if (jsonMatch) {\n    parsed = JSON.parse(jsonMatch[0]);\n  }\n} catch (e) {\n  parsed.content = rawContent;\n  parsed.title = articleData.title || articleData.target_name + '\u306e\u7d39\u4ecb\u8a18\u4e8b';\n}\n\n// WP REST API \u6295\u7a3f\u30c7\u30fc\u30bf\u3092\u69cb\u7bc9\nreturn {\n  title: parsed.title || articleData.title,\n  content: parsed.content,\n  excerpt: parsed.excerpt,\n  meta_description: parsed.meta_description,\n  status: 'publish',\n  slug: articleData.slug,\n  article_type: articleData.article_type,\n  sheets_row: articleData._rowIndex\n};"
      },
      "id": "merge-output",
      "name": "Gemini\u30ec\u30b9\u30dd\u30f3\u30b9\u6574\u5f62",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1340,
        320
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://localhost:10004/wp-json/wp/v2/posts",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBasicAuth",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "title",
              "value": "={{ $json.title }}"
            },
            {
              "name": "content",
              "value": "={{ $json.content }}"
            },
            {
              "name": "excerpt",
              "value": "={{ $json.excerpt }}"
            },
            {
              "name": "status",
              "value": "publish"
            },
            {
              "name": "slug",
              "value": "={{ $json.slug }}"
            }
          ]
        },
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        }
      },
      "id": "wp-post-create",
      "name": "WP REST API: posts\u6295\u7a3f\u4f5c\u6210",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1560,
        320
      ]
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "value": "1WwyRbzS7XfVqcaH6Ipe2JFqMtD-X1c5NKXJViaZAtvM",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "articles",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "autoMapInputData",
          "value": {
            "status": "published",
            "wp_post_id": "={{ $('WP REST API: posts\u6295\u7a3f\u4f5c\u6210').item.json.id }}",
            "published_at": "={{ new Date().toISOString() }}"
          },
          "matchingColumns": [
            "_rowIndex"
          ],
          "schema": []
        }
      },
      "id": "sheets-update-status",
      "name": "Google Sheets: \u6295\u7a3f\u6e08\u307f\u30d5\u30e9\u30b0\u66f4\u65b0",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        1780,
        320
      ]
    }
  ],
  "connections": {
    "\u6bce\u65e510\u6642\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb": {
      "main": [
        [
          {
            "node": "Google Sheets: \u672a\u6295\u7a3f\u8a18\u4e8b\u30ad\u30e5\u30fc\u53d6\u5f97",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets: \u672a\u6295\u7a3f\u8a18\u4e8b\u30ad\u30e5\u30fc\u53d6\u5f97": {
      "main": [
        [
          {
            "node": "1\u8a18\u4e8b\u305a\u3064\u51e6\u7406",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1\u8a18\u4e8b\u305a\u3064\u51e6\u7406": {
      "main": [
        [
          {
            "node": "\u8a18\u4e8b\u30bf\u30a4\u30d7\u5224\u5b9a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u8a18\u4e8b\u30bf\u30a4\u30d7\u5224\u5b9a": {
      "main": [
        [
          {
            "node": "Gemini: review\u8a18\u4e8b\u751f\u6210",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Gemini: comparison\u8a18\u4e8b\u751f\u6210",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Gemini: howto\u8a18\u4e8b\u751f\u6210",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini: review\u8a18\u4e8b\u751f\u6210": {
      "main": [
        [
          {
            "node": "Gemini\u30ec\u30b9\u30dd\u30f3\u30b9\u6574\u5f62",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini: comparison\u8a18\u4e8b\u751f\u6210": {
      "main": [
        [
          {
            "node": "Gemini\u30ec\u30b9\u30dd\u30f3\u30b9\u6574\u5f62",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini: howto\u8a18\u4e8b\u751f\u6210": {
      "main": [
        [
          {
            "node": "Gemini\u30ec\u30b9\u30dd\u30f3\u30b9\u6574\u5f62",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini\u30ec\u30b9\u30dd\u30f3\u30b9\u6574\u5f62": {
      "main": [
        [
          {
            "node": "WP REST API: posts\u6295\u7a3f\u4f5c\u6210",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "WP REST API: posts\u6295\u7a3f\u4f5c\u6210": {
      "main": [
        [
          {
            "node": "Google Sheets: \u6295\u7a3f\u6e08\u307f\u30d5\u30e9\u30b0\u66f4\u65b0",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "saveManualExecutions": true,
    "callerPolicy": "workflowsFromSameOwner",
    "errorWorkflow": ""
  },
  "staticData": null,
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "id": "wf02-article-post",
  "tags": [
    {
      "id": "vtuber",
      "name": "vtuber"
    },
    {
      "id": "pseo",
      "name": "pseo"
    },
    {
      "id": "article",
      "name": "article"
    }
  ],
  "active": false,
  "versionId": "1.0.0",
  "_comment": {
    "\u8aac\u660e": "WF02: pSEO\u8a18\u4e8b\u81ea\u52d5\u751f\u6210\u30fb\u6295\u7a3f\u30ef\u30fc\u30af\u30d5\u30ed\u30fc",
    "\u30d5\u30ed\u30fc": "Google Sheets(articles/status=pending) \u2192 \u8a18\u4e8b\u30bf\u30a4\u30d7\u5224\u5b9a(review/comparison/howto) \u2192 Gemini Flash 2.5\u3067\u8a18\u4e8b\u751f\u6210 \u2192 WP REST API \u3067 posts \u306b\u6295\u7a3f \u2192 Sheets\u306estatus\u3092published\u306b\u66f4\u65b0",
    "\u8a18\u4e8b\u30bf\u30a4\u30d7": {
      "review": "Vtuber\u500b\u4eba\u7d39\u4ecb\u30fb\u30ec\u30d3\u30e5\u30fc\uff082000\u301c3000\u6587\u5b57\uff09",
      "comparison": "2\u4eba\u306eVtuber\u6bd4\u8f03\uff081500\u301c2500\u6587\u5b57\uff09",
      "howto": "\u30c6\u30fc\u30de\u5225Vtuber\u304a\u3059\u3059\u3081\u30ac\u30a4\u30c9\uff082500\u301c4000\u6587\u5b57\uff09"
    },
    "Google Sheets articles\u30b7\u30fc\u30c8\u5fc5\u9808\u5217": [
      "status (pending/published)",
      "article_type (review/comparison/howto)",
      "target_name",
      "target_keywords",
      "slug",
      "compare_name (comparison\u306e\u307f)",
      "theme (howto\u306e\u307f)",
      "featured_vtubers (howto\u306e\u307f)"
    ]
  }
}