{
  "id": "y1egbyNJFdM3P7an",
  "name": "Final blog from url copy + pic",
  "tags": [],
  "nodes": [
    {
      "id": "b0f21640-48a5-4db5-9556-9773106d7280",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1696,
        0
      ],
      "parameters": {
        "color": 5,
        "width": 510,
        "height": 376,
        "content": "## Draft on WordPress"
      },
      "typeVersion": 1
    },
    {
      "id": "c00794aa-937c-4791-968a-2ee3ba862d24",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1008,
        0
      ],
      "parameters": {
        "color": 3,
        "width": 630,
        "height": 373,
        "content": "   ## Featured image"
      },
      "typeVersion": 1
    },
    {
      "id": "ade37493-65bd-4fc8-881c-83d0c50ccc0e",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        16,
        0
      ],
      "parameters": {
        "color": 6,
        "width": 920,
        "height": 371,
        "content": "## Collect Topic"
      },
      "typeVersion": 1
    },
    {
      "id": "b1b9b621-71a0-4b32-8410-1d34196388b9",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2240,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 524,
        "height": 391,
        "content": "## User feedback"
      },
      "typeVersion": 1
    },
    {
      "id": "b080becd-3f52-42c7-bb71-07906ac05d5e",
      "name": "Create post title and structure",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        656,
        144
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o",
          "cachedResultName": "GPT-4O"
        },
        "options": {
          "maxTokens": 1000
        },
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "=You are an expert copy editor. Keep every fact, detail, and paragraph. Change only 10\u201315% of the words to create a lightly rewritten version for SEO freshness. Never summarize or shorten the content. Keep all headings and structure intact. Output strict JSON as requested.\nAt the end of the article, append this call-to-action paragraph (do not paraphrase it):\n\n<p><strong>Injured in a car accident?</strong> Contact <a href=\"https://www.youURL.com/\">.............</a> for a <strong>free consultation</strong> today. Our experienced car accident lawyers are ready to help you get the justice and compensation you deserve.</p>\n"
            },
            {
              "content": "=You are a content editor specializing in SEO-friendly news rewrites.\n\nYour Task:\nRewrite the article text provided in the INPUT, adhering strictly to these rules:\n1.  **Preserve the entire meaning, facts, names, and numbers.**\n2.  **Only rephrase 10-15% of the words** by replacing words or short phrases with high-quality synonyms. Do NOT summarize or change the structure.\n3.  Ensure the language is natural, professional, and not obviously AI-generated.\n4.  Return clean HTML (no markdown), using H2/H3 tags for headings and paragraphs for body text.\n\n--- INPUT ---\n{{$node[\"Extract Article Title & Body\"].json.mainArticleText}}\n--- END INPUT ---\n\nReturn a JSON object EXACTLY like:\n{\n  \"title\": \"Rewritten article title\",\n  \"body\": \"Generate the full article using only <h2> tags for section titles and <p> tags for paragraphs. The first section must be titled <h2>Incident Overview</h2>. Do not use the words 'Intro', 'Introduction', or 'Subheading' as literal text. Use a structure like this: <h2>Incident Overview</h2><p>...</p><h2>Police and Fire Response</h2><p>...</p>\",\n  \"imagePrompt\": \"A very concise, cinematic description (maximum 15 words) of the core visual subject of the news event.\"\n}"
            }
          ]
        },
        "jsonOutput": true
      },
      "typeVersion": 1.8
    },
    {
      "id": "18809100-6e25-4333-b812-1aa5fc77c2eb",
      "name": "Form1",
      "type": "n8n-nodes-base.form",
      "position": [
        2976,
        144
      ],
      "parameters": {
        "options": {},
        "operation": "completion",
        "completionTitle": "Created Successfully!",
        "completionMessage": "=The article {{ $json.title.rendered }} was correctly created as a draft on WordPress!"
      },
      "typeVersion": 1
    },
    {
      "id": "d7358ce4-2d95-4df8-8ef4-d41c15293c84",
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        272,
        144
      ],
      "parameters": {
        "url": "={{ $json[\"Article URL\"] }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "95746f03-e0f0-4b69-9382-483291d955e7",
      "name": "pixabayQuery",
      "type": "n8n-nodes-base.set",
      "position": [
        1056,
        144
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "4d90da8d-0cfe-47a3-84d1-b68aa0566003",
              "name": "pixabayQuery",
              "type": "string",
              "value": "={{$node[\"Create post title and structure\"].json.message.content.title\n  .split(' ')\n  .slice(0,3)\n  .join(' ')}} accident\n"
            }
          ]
        }
      },
      "typeVersion": 3.4,
      "alwaysOutputData": true
    },
    {
      "id": "c1f19dff-889e-4160-9593-8fb852c6e78c",
      "name": "Pixabay HTTP",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1200,
        144
      ],
      "parameters": {
        "url": "https://pixabay.com/api/",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        },
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "key",
              "value": "Your API"
            },
            {
              "name": "q",
              "value": "={{\n(() => {\n  // Title from your writer node\n  const t =\n    $node[\"Create post title and structure\"].json?.message?.content?.title || \"\";\n\n  // Keep only allowed, crash-related tokens\n  const allow = new Set([\n    \"car\",\"vehicle\",\"truck\",\"semi\",\"collision\",\"crash\",\"wreck\",\"pileup\",\n    \"freeway\",\"highway\",\"traffic\",\"police\",\"chp\",\"ontario\",\"california\"\n  ]);\n\n  const tokens = t\n    .toLowerCase()\n    .replace(/[^a-z0-9 ]+/g, \" \")\n    .split(/\\s+/)\n    .filter(w => allow.has(w));\n\n  // Fallback if nothing matched\n  const q = (tokens.length ? tokens.join(\"+\") : \"car+crash+freeway+accident\");\n  return q;\n})()\n}}\n"
            },
            {
              "name": "image_type",
              "value": "=photo"
            },
            {
              "name": "safesearch",
              "value": "true"
            },
            {
              "name": "orientation",
              "value": "horizontal"
            },
            {
              "name": "lang",
              "value": "en"
            },
            {
              "name": "per_page",
              "value": "10"
            },
            {
              "name": "order",
              "value": "popular"
            },
            {
              "name": "category",
              "value": "transportation"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "8490d11d-ec34-42dc-ac74-2eae0fc3c48f",
      "name": "Download image",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1344,
        144
      ],
      "parameters": {
        "url": "={{\n(() => {\n  const hits = $node[\"Pixabay HTTP\"].json?.hits || [];\n  if (!hits.length) {\n    // Fallback image so the flow still succeeds when no results\n    return \"https://images.pexels.com/photos/427679/pexels-photo-427679.jpeg\";\n  }\n  const h = hits[0];\n  return h.largeImageURL || h.webformatURL || h.previewURL;\n})()\n}}\n",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "a3e4e49a-daa5-4b97-9795-b272bd6ce8aa",
      "name": "Upload media",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1488,
        144
      ],
      "parameters": {
        "url": "https://yourURL.com/wp-json/wp/v2/media",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "binaryData",
        "sendHeaders": true,
        "authentication": "predefinedCredentialType",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Disposition",
              "value": "attachment; filename=\"featured.jpg\""
            },
            {
              "name": "Content-Type",
              "value": "image/jpeg"
            }
          ]
        },
        "inputDataFieldName": "=data",
        "nodeCredentialType": "wordpressApi"
      },
      "typeVersion": 4.2
    },
    {
      "id": "c826a03e-6062-4e7f-9250-6a43c27a2e2e",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        1904,
        144
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition"
      },
      "typeVersion": 3.2
    },
    {
      "id": "8aa74bb6-fe1f-4d9d-810a-6f2932ad75f5",
      "name": "Attach media",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2064,
        144
      ],
      "parameters": {
        "url": "=https://yourURL.com/wp-json/wp/v2/media/{{$node[\"Upload media\"].json[\"id\"]}}\n",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "form-urlencoded",
        "authentication": "predefinedCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "post",
              "value": "={{$node[\"Create WordPress Draft Post\"].json[\"id\"]}}"
            }
          ]
        },
        "nodeCredentialType": "wordpressApi"
      },
      "typeVersion": 4.2
    },
    {
      "id": "76491cbf-4763-4841-ac59-97ad83dfd91b",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        2288,
        144
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "f09d3580-e3ca-4c5c-8d53-c6b51e2767ec",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        192,
        304
      ],
      "parameters": {
        "color": 5,
        "width": 576,
        "height": 224,
        "content": "## Topic Input\n## AI Content Generation\n\nSends the topic to an LLM to generate the article's title, body (in Markdown), and meta description, and then structures the output for WordPress."
      },
      "typeVersion": 1
    },
    {
      "id": "c7773259-63d0-42d1-99b6-ff48652be9a3",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1136,
        304
      ],
      "parameters": {
        "color": 5,
        "width": 384,
        "height": 224,
        "content": "## Featured Image Handling\n\nSearches for a license-free image, downloads the binary, and uploads the image file directly to WordPress's media library."
      },
      "typeVersion": 1
    },
    {
      "id": "b38b8eeb-89e5-41d1-aa84-128c4c36e38a",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1808,
        304
      ],
      "parameters": {
        "color": 5,
        "width": 320,
        "height": 224,
        "content": "## WordPress Draft Creation\n\nCreates the post draft, merges the image ID, and attaches the featured image to the new post using the WordPress API."
      },
      "typeVersion": 1
    },
    {
      "id": "4aefefd3-0960-4d92-b498-2d76adf006cc",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2320,
        304
      ],
      "parameters": {
        "color": 5,
        "width": 368,
        "height": 224,
        "content": "## Reviewer Notification\n\nNotifies the designated reviewer (e.g., via email or Slack) that a new draft is ready. Includes a brief pause for WordPress indexing."
      },
      "typeVersion": 1
    },
    {
      "id": "325b24fa-b0a4-4826-9336-238a61d7b4b6",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        64,
        -336
      ],
      "parameters": {
        "width": 592,
        "height": 272,
        "content": "## How it works\nThis workflow automates the creation of a draft article for a blog. It begins when a user submits a blog topic (e.g., via a form or manual input). The topic is sent to an AI model (like LLM/OpenAI) to generate the full article title, structure, body, and meta description.\n\nNext, the workflow searches **Pexels/Pixabay** for a relevant, license-free featured image, downloads it, and uploads it to **WordPress**.\n\nFinally, it creates a draft post on WordPress, populating the title, body, meta description, and attaching the featured image. A notification (email/Slack) is then sent to the content team, ensuring the draft is ready for review.\n\n## Setup steps\n1.  **AI Service:** Configure the \"LLM/Article Extractor\" node (e.g., OpenAI, Anthropic) with your API key.\n2.  **Image Service:** Configure the \"Pixabay/Pexels\" nodes with your API key.\n3.  **WordPress:** Connect the \"Post on WordPress\" and \"Attach media\" nodes using your WordPress credentials (URL and API/username/password).\n4.  **Notification:** Configure the \"Send email/Slack\" node in the **User feedback** section with the necessary credentials to notify the content reviewer."
      },
      "typeVersion": 1
    },
    {
      "id": "30f3e8f1-f0c8-4ebf-a9a7-9cd252396a7d",
      "name": "Collect Blog Topic",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        64,
        144
      ],
      "parameters": {
        "options": {
          "path": "create-wordpress-post"
        },
        "formTitle": "Create a WordPress post with AI",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Article URL",
              "placeholder": "https://example.com/article",
              "requiredField": true
            }
          ]
        },
        "responseMode": "lastNode",
        "formDescription": "=Fill this form with the required information to create a draft post on WordPress"
      },
      "typeVersion": 2.2
    },
    {
      "id": "615f9338-aba3-47a3-b19e-1cba9f9ec7cd",
      "name": "Extract Article Title & Body",
      "type": "n8n-nodes-base.html",
      "position": [
        464,
        144
      ],
      "parameters": {
        "options": {},
        "operation": "extractHtmlContent",
        "extractionValues": {
          "values": [
            {
              "key": "=mainArticleText",
              "cssSelector": "[data-testid=\"prism-article-body\"]"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "6c3c40b0-25b5-425c-aec4-bbabcce7a532",
      "name": "Create WordPress Draft Post",
      "type": "n8n-nodes-base.wordpress",
      "position": [
        1744,
        144
      ],
      "parameters": {
        "title": "={{$node[\"Create post title and structure\"].json.message.content.title}}",
        "additionalFields": {
          "slug": "={{$node[\"Create post title and structure\"].json.message.content.title\n  .toLowerCase()\n  .replace(/[^a-z0-9]+/g,'-')\n  .replace(/^-+|-+$/g,'')}}\n",
          "status": "draft",
          "content": "={{$node[\"Create post title and structure\"].json.message.content.body}}\n",
          "categories": [
            891
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "1ca49735-d382-416e-8335-e9f9724592ff",
      "name": "Fetch Review Status",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2464,
        144
      ],
      "parameters": {
        "url": "=https://YourURL.com/wp-json/wp/v2/posts/{{$node[\"Create WordPress Draft Post\"].json[\"id\"]}}\n",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "form-urlencoded",
        "authentication": "predefinedCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "featured_media",
              "value": "={{$node[\"Upload media\"].json[\"id\"]}}"
            }
          ]
        },
        "nodeCredentialType": "wordpressApi"
      },
      "typeVersion": 4.2
    },
    {
      "id": "4e0527d6-9f42-4f02-a734-538b0d2b822b",
      "name": "Set Reviewer Email",
      "type": "n8n-nodes-base.set",
      "position": [
        2624,
        144
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "820b3a44-437e-419e-a0eb-c3a806d05d0d",
              "name": "featured_media",
              "type": "string",
              "value": "={{$node[\"Upload media\"].json[\"id\"]}}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "ae947093-5bcf-4ab3-bd04-809a05226357",
      "name": "Notify Review Complete",
      "type": "n8n-nodes-base.set",
      "position": [
        2816,
        144
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "9ce35977-d1f4-44cd-9e8a-9c7ac7343cfb",
              "name": "mediaID",
              "type": "string",
              "value": "={{ $node[\"Upload media\"].json[\"id\"] }}"
            },
            {
              "id": "c7b6fdfa-1864-4069-bfb0-5c01617b8001",
              "name": "updateURL",
              "type": "string",
              "value": "=$$\\text{\"[https://yourURL.com/wp-json/wp/v2/posts/](https://yourURL.com/wp-json/wp/v2/posts/)\" + \\$json.id}$$"
            }
          ]
        }
      },
      "typeVersion": 3.4
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "71c9bd0c-f789-4f5d-a6ad-6c73c328efa5",
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "Fetch Review Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Attach media",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Attach media": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Extract Article Title & Body",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pixabay HTTP": {
      "main": [
        [
          {
            "node": "Download image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload media": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          },
          {
            "node": "Create WordPress Draft Post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "pixabayQuery": {
      "main": [
        [
          {
            "node": "Pixabay HTTP",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download image": {
      "main": [
        [
          {
            "node": "Upload media",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Collect Blog Topic": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Reviewer Email": {
      "main": [
        [
          {
            "node": "Notify Review Complete",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Review Status": {
      "main": [
        [
          {
            "node": "Set Reviewer Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notify Review Complete": {
      "main": [
        [
          {
            "node": "Form1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create WordPress Draft Post": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Extract Article Title & Body": {
      "main": [
        [
          {
            "node": "Create post title and structure",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create post title and structure": {
      "main": [
        [
          {
            "node": "pixabayQuery",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}