{
  "name": "Project: WordPress Image Upload",
  "nodes": [
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        0
      ],
      "id": "d2857fa8-ba8f-44e9-9037-7e5d60074a9d",
      "name": "Telegram Trigger",
      "webhookId": "2661715b-ab16-4c80-bfed-234d83796bdd",
      "credentials": {
        "telegramApi": {
          "id": "DA4UGj08LgRnRgDf",
          "name": "Catalin Telegram Bot"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.message.text }}",
        "options": {
          "systemMessage": "=Take the user's message and distill it into 1-5 words. Output the words separated by + signs, and nothing else.\nThe output will be used in a web query so be very precise with formatting. Only words separated by + signs, nothing else"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2.2,
      "position": [
        208,
        0
      ],
      "id": "2f1f8d85-f275-4b21-a902-d8eac9dc7a67",
      "name": "Search query agent"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        368,
        256
      ],
      "id": "910eb0ba-a22a-4dfa-aeab-e2a4cc72e831",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "id": "xHWDVrLvQFklSodD",
          "name": "OpenAi account"
        }
      }
    },
    {
      "parameters": {
        "url": "https://www.googleapis.com/customsearch/v1",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "key",
              "value": "AIzaSyBGoRW7PKeTgouh93rnuuRpuRyN20wFdkE"
            },
            {
              "name": "cx",
              "value": "55b8201464ff24ae8"
            },
            {
              "name": "q",
              "value": "={{ $json.output }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        560,
        0
      ],
      "id": "eded077a-6ac2-49f8-a38f-e164485779f6",
      "name": "HTTP Request"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.items }}",
        "hasOutputParser": true,
        "options": {
          "systemMessage": "=You are a master blog writer. \nThe user input is a web search of news articles related to the user's query.\n\nTake an article and write a blog post about it. Make it interesting and engaging.\nCreate an interesting and engaging title.\n\nOutput the title and content according to the output JSON, don't output anything extra."
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2.2,
      "position": [
        768,
        0
      ],
      "id": "433629a6-9329-4e59-a61d-b20907d41fa8",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "jsonSchemaExample": "{\n\t\"title\": \"Blog title\",\n\t\"content\": \"Blog content\"\n}"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.3,
      "position": [
        912,
        256
      ],
      "id": "58d707e9-cbc6-4c05-bda0-2f4f931a2c61",
      "name": "Structured Output Parser"
    },
    {
      "parameters": {
        "title": "={{ $json.output.title }}",
        "additionalFields": {
          "content": "={{ $json.output.content }}",
          "status": "publish"
        }
      },
      "type": "n8n-nodes-base.wordpress",
      "typeVersion": 1,
      "position": [
        1120,
        0
      ],
      "id": "76d0bba6-ff2d-4480-bfb1-cee63418a34d",
      "name": "Create a post",
      "credentials": {
        "wordpressApi": {
          "id": "B4GBAfCfdxoP9VLX",
          "name": "Wordpress account 2"
        }
      }
    },
    {
      "parameters": {
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "text": "=Article Generated\n\n{{ $json.title.raw }}\n\n{{ $json.guid.rendered }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1328,
        0
      ],
      "id": "58acf474-747f-4eaa-8281-2f406bcc92c2",
      "name": "Send a text message",
      "webhookId": "3c5a7a89-246c-4597-b2ba-0f2b985d0513",
      "credentials": {
        "telegramApi": {
          "id": "DA4UGj08LgRnRgDf",
          "name": "Catalin Telegram Bot"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $('AI Agent').item.json.output.content }}",
        "options": {
          "systemMessage": "=Your job is to generate a prompt so that the next agent can generate an image. You will receive a blog article from the user. Convert that into a prompt for image generation that represents closely what the article is talking about. Make the image realistic and evocative."
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2.2,
      "position": [
        64,
        448
      ],
      "id": "a8bfc4e6-a2c1-41d9-8443-d3019957d165",
      "name": "AI Agent1"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.stability.ai/v2beta/stable-image/generate/core",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "accept",
              "value": "image/*"
            },
            {
              "name": "Content-Type",
              "value": "multipart/form-data"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "prompt",
              "value": "={{ $json.output }}"
            },
            {
              "name": "output_format",
              "value": "png"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        416,
        448
      ],
      "id": "8bf2f5b1-0c36-4999-bef1-5211e71908f6",
      "name": "HTTP Request1",
      "credentials": {
        "httpBearerAuth": {
          "id": "4BR14ACA7WGlIHXD",
          "name": "Stability.ai 2"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://lightgoldenrodyellow-pig-207963.hostingersite.com/wp-json/wp/v2/media",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "wordpressApi",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Disposition",
              "value": "attachment; filename=\"image.png\""
            },
            {
              "name": "Content-Type",
              "value": "image/png"
            }
          ]
        },
        "sendBody": true,
        "contentType": "binaryData",
        "inputDataFieldName": "data",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        624,
        448
      ],
      "id": "bca99006-19e6-4297-b4da-38df91008941",
      "name": "Upload Image to Wordpress",
      "credentials": {
        "wordpressApi": {
          "id": "B4GBAfCfdxoP9VLX",
          "name": "Wordpress account 2"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://lightgoldenrodyellow-pig-207963.hostingersite.com/wp-json/wp/v2/posts/{{ $('Create a post').item.json.id }}",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "wordpressApi",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "featured_media",
              "value": "={{ $json.id }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        832,
        448
      ],
      "id": "32648c88-079b-4233-aeab-2af1b24c6b0f",
      "name": "Update Article",
      "credentials": {
        "wordpressApi": {
          "id": "B4GBAfCfdxoP9VLX",
          "name": "Wordpress account 2"
        }
      }
    },
    {
      "parameters": {
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "text": "Done! Image updated, post completed",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1040,
        448
      ],
      "id": "32e4dd0a-9803-4070-9a31-40a7e51fa483",
      "name": "Send a text message1",
      "webhookId": "c67296ff-eed6-4792-9fc0-e5a7832af685",
      "credentials": {
        "telegramApi": {
          "id": "DA4UGj08LgRnRgDf",
          "name": "Catalin Telegram Bot"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Search query agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Search query agent",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "AI Agent1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Search query agent": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Create a post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create a post": {
      "main": [
        [
          {
            "node": "Send a text message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a text message": {
      "main": [
        [
          {
            "node": "AI Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent1": {
      "main": [
        [
          {
            "node": "HTTP Request1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request1": {
      "main": [
        [
          {
            "node": "Upload Image to Wordpress",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload Image to Wordpress": {
      "main": [
        [
          {
            "node": "Update Article",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Article": {
      "main": [
        [
          {
            "node": "Send a text message1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "eb2964df-59e3-47a4-97f0-56c0b41fbbb1",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "281c34c03b9c41f054c536eeb966e9e503918cf7f00e3bc32a5ff9cca85ca255"
  },
  "id": "1hU3J7gik5Wnngug",
  "tags": []
}