{
  "name": "Wordpress-content-generator",
  "nodes": [
    {
      "parameters": {
        "method": "POST",
        "url": "http://siteadi.com/wp-json/wp/v2/media",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBasicAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Disposition",
              "value": "attachment; filename=\"gorsel.png\""
            }
          ]
        },
        "sendBody": true,
        "contentType": "binaryData",
        "inputDataFieldName": "data",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1680,
        420
      ],
      "id": "7dbcd6d2-1632-4a7f-a360-dcd5403520ab",
      "name": "HTTP Request",
      "credentials": {
        "httpBasicAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "agent": "conversationalAgent",
        "promptType": "define",
        "text": "=I want you to write a highly SEO-optimized WordPress blog post about {{ $json.chatInput }}. \nThe content should be written in a conversational and engaging tone, as if you're talking directly to the reader. \nIt should be educational and easy to understand, while still offering expert-level insights.\n\nStructure the post into 4 to 7 paragraphs.\nParagparphs should be html format it should include <ul>, <li>, <b>, <i> etc. html tags in paragparphs to explain well. \nUse icons, lists, sub titles etc. to expain well!. \nAnd each paragraph should be 10 to 15 sentences long. Between paragraphs, include optional image placeholders if a visual explanation would help\u2014just describe the image with a short sentence like:\n[Image: A diagram showing how X works].\n\nUse natural and relevant keywords for SEO throughout the article, but keep it smooth and natural\u2014no keyword stuffing. Make sure the content flows well, with each paragraph covering a distinct subtopic or idea.\n\noutput should be like blow\n\n{\n\t\"type\": \"object\",\n\t\"properties\": {\n    \"paragraphs\": {\n      \"type\": \"array\",\n      \"items\": {\n        \"type\": \"object\",\n        \"properties\": {\n          \"text\": {\n            \"type\": \"string\"\n          },\n          \"imageText\": {\n            \"type\": \"string\",\n          }\n        },\n        \"required\": [\"text\"]\n      }\n\t}\n}\n}\nif you dont create imageText for a paragraph write empty string. \n",
        "hasOutputParser": true,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.7,
      "position": [
        200,
        0
      ],
      "id": "56f4321e-1af7-412b-8c7a-f409b576cb05",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "typeVersion": 1.1,
      "position": [
        0,
        0
      ],
      "id": "f202f654-25c5-4323-988c-d7e2d21d4741",
      "name": "When chat message received"
    },
    {
      "parameters": {
        "modelName": "models/gemini-2.0-flash-thinking-exp",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        200,
        220
      ],
      "id": "2654898d-9947-4a9a-b442-755a68d2b024",
      "name": "Google Gemini Chat Model",
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n\t\"type\": \"object\",\n\t\"properties\": {\n    \"paragraphs\": {\n      \"type\": \"array\",\n      \"items\": {\n        \"type\": \"object\",\n        \"properties\": {\n          \"text\": {\n            \"type\": \"string\"\n          },\n          \"imageText\": {\n            \"type\": \"string\"\n          }\n        }\n      }\n\t}\n}\n}"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.2,
      "position": [
        380,
        220
      ],
      "id": "17d003d4-6e39-4b95-89ed-f84f58352218",
      "name": "Structured Output Parser"
    },
    {
      "parameters": {
        "fieldToSplitOut": "output.paragraphs",
        "options": {}
      },
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        560,
        0
      ],
      "id": "1737b1ca-6084-4c38-84ed-d8a907edd3f3",
      "name": "Split Out"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        780,
        0
      ],
      "id": "6d5587ad-30ea-4d0a-b825-a3b1fb0ca7c6",
      "name": "Loop Over Items"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-exp-image-generation:generateContent?key=YOUR_API_KEY",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n    \"contents\": [{\n      \"parts\": [\n        {\"text\": \"Hi, can you create a 3d rendered image of {{ $json.imageText }} it should be very relastic and modern\"}]\n    }],\n    \"generationConfig\":{\"responseModalities\":[\"Text\",\"Image\"]}\n  }",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1440,
        160
      ],
      "id": "8bbe40f1-0ed0-4a0a-8e53-7358e87499c2",
      "name": "HTTP Request1"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "4bf92cf6-c797-4504-bbd6-099d28245306",
              "leftValue": "={{ $json.imageText }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1120,
        40
      ],
      "id": "1b6903e8-4cbd-4a4e-8b2e-3707d0aadda1",
      "name": "If"
    },
    {
      "parameters": {
        "operation": "toBinary",
        "sourceProperty": "candidates[0].content.parts[0].inlineData.data",
        "options": {}
      },
      "type": "n8n-nodes-base.convertToFile",
      "typeVersion": 1.1,
      "position": [
        1660,
        200
      ],
      "id": "7e2ab959-8259-4ddb-ab9c-76b7300e3550",
      "name": "Convert to File"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "741838bf-6368-47f5-ae8e-f9bf80d61f40",
              "name": "=text",
              "value": "={{ $('Loop Over Items').item.json.text }}\n<p class=\"attachment\"><a href=''><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"auto\" src=\"{{ $json.media_details.sizes.medium_large.source_url }}\" class=\"attachment-medium size-medium\" alt=\"{{ $json.slug }}\" /></a></p>",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1180,
        400
      ],
      "id": "c5198f80-67e1-43e7-95db-5244536bffbc",
      "name": "Edit Fields1"
    },
    {
      "parameters": {
        "aggregate": "aggregateAllItemData",
        "options": {}
      },
      "type": "n8n-nodes-base.aggregate",
      "typeVersion": 1,
      "position": [
        1120,
        -120
      ],
      "id": "9559c0a9-89fc-4c51-a13b-a522017a4a5f",
      "name": "Aggregate"
    },
    {
      "parameters": {
        "jsCode": "let combinedText = \"\";\n\nfor (const item of $input.first().json.data) {\n  if (item.text) {\n    combinedText += item.text.trim() + \"<br>\";\n  }\n}\n\n// Tek bir de\u011fer d\u00f6nd\u00fcr\nreturn {\n  combinedText: combinedText\n};"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1360,
        -120
      ],
      "id": "2c58bc63-0c5e-406d-837b-2f2b42b38d82",
      "name": "Code"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "031b7c9d-ccde-4123-bcd0-9b8cd79a6c7a",
              "name": "content",
              "value": "=<article><h3>{{ $('When chat message received').item.json.chatInput.trim() }}</h3>{{ $json.combinedText.trim() }}</article>",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1580,
        -120
      ],
      "id": "8b24ff18-3039-4f10-863f-d185a313fc8d",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "title": "={{ $('When chat message received').item.json.chatInput }}",
        "additionalFields": {
          "content": "={{ $json.content }}",
          "status": "publish",
          "tags": [
            6,
            4,
            5
          ]
        }
      },
      "type": "n8n-nodes-base.wordpress",
      "typeVersion": 1,
      "position": [
        1800,
        -120
      ],
      "id": "a521222d-1683-4d5a-b715-9e152357ed4d",
      "name": "Wordpress",
      "credentials": {
        "wordpressApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://192.168.1.121:8000/wp-json/wp/v2/posts",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBasicAuth",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "title",
              "value": "={{ $('When chat message received').item.json.chatInput }}"
            },
            {
              "name": "content",
              "value": "={{ $json.content }}"
            },
            {
              "name": "status",
              "value": "publish"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1800,
        -540
      ],
      "id": "24143db6-8837-40bf-81df-e8b284d87a0b",
      "name": "HTTP Request2",
      "credentials": {
        "httpBasicAuth": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request1": {
      "main": [
        [
          {
            "node": "Convert to File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Edit Fields1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "HTTP Request1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields1": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Wordpress",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "4f040ce6-6210-4c82-9260-e0b7a33d5bd4",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "cv9Q8O1ZIZfz46kd",
  "tags": []
}