{
  "name": "News Analysis and Blog Post Creator",
  "tags": [
    {
      "name": "automation"
    },
    {
      "name": "content"
    },
    {
      "name": "ai"
    }
  ],
  "nodes": [
    {
      "id": "1",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        250,
        300
      ],
      "parameters": {
        "triggerTimes": {
          "item": [
            {
              "mode": "everyX",
              "unit": "hours",
              "value": 3
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "2",
      "name": "HTTP Request - News API",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        450,
        300
      ],
      "parameters": {
        "url": "https://newsapi.org/v2/top-headlines",
        "method": "GET",
        "options": {
          "redirect": {
            "redirect": {
              "followRedirects": true
            }
          }
        },
        "authentication": "predefinedCredentialType",
        "queryParameters": {
          "parameters": [
            {
              "name": "country",
              "value": "us"
            },
            {
              "name": "pageSize",
              "value": "10"
            },
            {
              "name": "category",
              "value": "technology"
            }
          ]
        },
        "nodeCredentialType": "newsApiApi"
      },
      "typeVersion": 1
    },
    {
      "id": "3",
      "name": "Item Lists",
      "type": "n8n-nodes-base.itemLists",
      "position": [
        650,
        300
      ],
      "parameters": {
        "options": {},
        "batchSize": 1,
        "operation": "splitInBatches"
      },
      "typeVersion": 1,
      "inputDataPropertyName": "articles"
    },
    {
      "id": "4",
      "name": "OpenAI - Analyze News",
      "type": "n8n-nodes-base.openAi",
      "position": [
        850,
        300
      ],
      "parameters": {
        "prompt": {
          "messages": [
            {
              "role": "system",
              "content": "You are an expert content creator and analyst. Your task is to analyze a news article and create a blog post about it. The blog post should be informative, engaging, and well-structured with appropriate headings, paragraphs, and a conclusion. Use HTML formatting. Include the source link at the end as a reference."
            },
            {
              "role": "user",
              "content": "=Here is the news article to analyze and convert into a blog post:\n\nTitle: {{$json[\"title\"]}}\n\nAuthor: {{$json[\"author\"]}}\n\nContent: {{$json[\"content\"]}}\n\nDescription: {{$json[\"description\"]}}\n\nURL: {{$json[\"url\"]}}\n\nPublished: {{$json[\"publishedAt\"]}}"
            }
          ]
        },
        "options": {
          "model": "gpt-4o",
          "maxTokens": 2000,
          "temperature": 0.7,
          "additionalParameters": {}
        },
        "resource": "chat"
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "5",
      "name": "Set Blog Post",
      "type": "n8n-nodes-base.set",
      "position": [
        1050,
        300
      ],
      "parameters": {
        "values": {
          "string": [
            {
              "name": "title",
              "value": "={{$json[\"title\"]}}"
            },
            {
              "name": "slug",
              "value": "={{$json[\"title\"].toLowerCase().replace(/ /g, '-').replace(/[^\\w-]+/g, '')}}"
            },
            {
              "name": "content",
              "value": "={{$json[\"choices\"][0][\"message\"][\"content\"]}}"
            },
            {
              "name": "publishDate",
              "value": "={{$now}}"
            },
            {
              "name": "sourceUrl",
              "value": "={{$node[\"Item Lists\"].json[\"url\"]}}"
            }
          ]
        },
        "options": {},
        "keepOnlySet": true
      },
      "typeVersion": 1
    },
    {
      "id": "6",
      "name": "WordPress - Create Post",
      "type": "n8n-nodes-base.wordpress",
      "position": [
        1250,
        300
      ],
      "parameters": {
        "title": "={{$json[\"title\"]}}",
        "status": "publish",
        "content": "={{$json[\"content\"]}}",
        "resource": "post",
        "operation": "create",
        "additional": {
          "metaData": [
            {
              "name": "source_url",
              "value": "={{$json[\"sourceUrl\"]}}"
            }
          ]
        }
      },
      "credentials": {
        "wordpressApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "7",
      "name": "Error Handler",
      "type": "n8n-nodes-base.errorTrigger",
      "position": [
        650,
        500
      ],
      "typeVersion": 1
    },
    {
      "id": "8",
      "name": "Send Error Email",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        850,
        500
      ],
      "parameters": {
        "text": "={{\"An error occurred in the News Blog Workflow:\\n\\n\" + $json[\"error\"][\"message\"] + \"\\n\\nTimestamp: \" + $now}}",
        "subject": "Error in News Blog Workflow",
        "toEmail": "admin@example.com",
        "fromEmail": "user@example.com"
      },
      "credentials": {
        "smtp": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    }
  ],
  "settings": {
    "timezone": "UTC",
    "errorWorkflow": "Error Handler",
    "executionOrder": "v1",
    "saveManualExecutions": true,
    "saveDataErrorExecution": "all",
    "saveDataSuccessExecution": "all"
  },
  "versionId": "1",
  "staticData": {},
  "connections": {
    "Item Lists": {
      "main": [
        [
          {
            "node": "OpenAI - Analyze News",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Error Handler": {
      "main": [
        [
          {
            "node": "Send Error Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Blog Post": {
      "main": [
        [
          {
            "node": "WordPress - Create Post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "HTTP Request - News API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI - Analyze News": {
      "main": [
        [
          {
            "node": "Set Blog Post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request - News API": {
      "main": [
        [
          {
            "node": "Item Lists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "triggerCount": 1
}