{
  "id": "SD0hIkl5bfdihz5C",
  "name": "Automated Blog Post Generation",
  "nodes": [
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyHour"
            }
          ]
        },
        "documentId": {
          "__rl": true,
          "value": "https://docs.google.com/spreadsheets/d/YOUR_SPREADSHEET_ID/edit#gid=0",
          "mode": "url"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_SPREADSHEET_ID/edit#gid=0"
        },
        "event": "rowAdd"
      },
      "id": "298f036a-8c5a-400b-b066-3ec99ff4bd8c",
      "name": "Google Sheets Trigger",
      "type": "n8n-nodes-base.googleSheetsTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "credentials": {
        "googleSheetsTriggerOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "GET",
        "url": "={{'https://serpapi.com/search.json?engine=google&q=' + $node['Google Sheets Trigger'].json['Keyword'] + '&api_key=YOUR_SERPAPI_API_KEY'}}",
        "responseFormat": "json"
      },
      "id": "c98d1cae-a91d-4f81-abaf-9686ba0ac13f",
      "name": "SerpAPI Competitors",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        200,
        -100
      ]
    },
    {
      "parameters": {
        "functionCode": "const results = $node[\"SerpAPI Competitors\"].json[\"organic_results\"];\nlet summary = \"\";\nif (results && Array.isArray(results)) {\n  const topResults = results.slice(0, 3);\n  summary = topResults.map((res, idx) => {\n    const title = res.title || 'No title';\n    const snippet = res.snippet || (res.snippet_highlighted_words ? res.snippet_highlighted_words.join(' ') : '');\n    const link = res.link || res.url || '';\n    return `${idx+1}. ${title}${snippet ? ' - ' + snippet : ''}${link ? ' (' + link + ')' : ''}`;\n  }).join(\"\\n\");\n}\nreturn [{ \"competitor_summary\": summary }];"
      },
      "id": "d7e528d5-ea28-40c8-b809-69d6b424b861",
      "name": "Process Competitors",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        400,
        -100
      ]
    },
    {
      "parameters": {
        "command": "python3 brand_tone_analysis.py"
      },
      "id": "2a19c535-8720-453e-8b65-4c547577ba84",
      "name": "Brand Tone Analysis",
      "type": "n8n-nodes-base.executeCommand",
      "typeVersion": 1,
      "position": [
        200,
        100
      ]
    },
    {
      "parameters": {
        "mode": "mergeByIndex",
        "join": "inner"
      },
      "id": "39ab62c4-db69-4f51-a4ed-974939d7b0dd",
      "name": "Merge Insights",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 1,
      "position": [
        600,
        0
      ]
    },
    {
      "parameters": {
        "prompt": "={{'Focus keyword: ' + $node['Google Sheets Trigger'].json['Keyword'] + \"\\n\" +($node['Google Sheets Trigger'].json['Prompt'] ? 'Additional context: ' + $node['Google Sheets Trigger'].json['Prompt'] + \"\\n\" : '') +($node['Brand Tone Analysis'].json['stdout'] ? 'Brand tone guidelines: ' + $node['Brand Tone Analysis'].json['stdout'] + \"\\n\" : '') +($node['Process Competitors'].json['competitor_summary'] ? 'Top search results:\\n' + $node['Process Competitors'].json['competitor_summary'] + \"\\n\\n\" : '') +'Using the above information, generate a detailed blog post outline and a full draft of a blog article about the focus keyword. ' +'The article should be well-structured, informative, and engaging. ' +'Follow SEO best practices (ensure the focus keyword is included naturally in headings and content) and adhere to the brand\\'s tone of voice. ' +'First provide a section-by-section outline, then write the complete draft content following the outline.'}}",
        "model": "gpt-4",
        "temperature": 0.7,
        "maxTokens": 3000
      },
      "id": "9f85da8a-61e0-4164-ab97-385430535fe4",
      "name": "Content Draft (GPT-4)",
      "type": "n8n-nodes-base.openAi",
      "typeVersion": 1,
      "position": [
        800,
        0
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "prompt": "={{'Please review and refine the following draft for structure, clarity, and depth while preserving the content. ' +'Make sure the text is well-organized, the language is clear and professional, and the information is thorough. ' +'Return the improved draft content only:\\n\\n' + $node['Content Draft (GPT-4)'].json['text']}}",
        "model": "gpt-4",
        "temperature": 0.5,
        "maxTokens": 2500
      },
      "id": "e1f93d2f-296a-4e5d-b352-5474c587d1e2",
      "name": "AI Review & Refinement",
      "type": "n8n-nodes-base.openAi",
      "typeVersion": 1,
      "position": [
        1000,
        0
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "prompt": "={{'Further improve the content below for reader engagement and readability. ' +'Make the tone friendly and accessible while maintaining professionalism. ' +'Ensure the text flows well and is easy to understand. Provide the revised content only:\\n\\n' + $node['AI Review & Refinement'].json['text']}}",
        "model": "gpt-4",
        "temperature": 0.7,
        "maxTokens": 2000
      },
      "id": "398faab1-3e32-4508-aac5-bf5a93252aab",
      "name": "Engagement & Readability",
      "type": "n8n-nodes-base.openAi",
      "typeVersion": 1,
      "position": [
        1200,
        0
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.yoast.com/analyze",
        "bodyParameters": {
          "parameters": [
            {
              "name": "text",
              "value": "={{$json[\"content\"]}}",
              "type": "string"
            },
            {
              "name": "focus_keyword",
              "value": "={{$node['Google Sheets Trigger'].json['Keyword']}}",
              "type": "string"
            }
          ]
        },
        "options": {
          "bodyContentType": "form-urlencoded"
        }
      },
      "id": "8553382b-10bb-4f3d-aa11-eb16cdc1ef1e",
      "name": "Yoast Analysis",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        1400,
        -100
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://internal-linking-api.example.com/suggest",
        "bodyParameters": {
          "parameters": [
            {
              "name": "content",
              "value": "={{$node['Engagement & Readability'].json['text']}}",
              "type": "string"
            },
            {
              "name": "limit",
              "value": 5,
              "type": "number"
            }
          ]
        },
        "options": {}
      },
      "id": "2b6f15c7-999a-4662-88f5-fe22f3211bdc",
      "name": "Internal Linking",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        1400,
        100
      ]
    },
    {
      "parameters": {
        "functionCode": "const content = $node[\"Engagement & Readability\"].json[\"text\"] || '';\nlet finalContent = content;\nconst linksData = $node[\"Internal Linking\"].json;\nlet links = [];\nif (linksData && Array.isArray(linksData.links)) {\n  links = linksData.links;\n} else if (Array.isArray(linksData)) {\n  links = linksData;\n} else {\n  // if the API returns directly an array or other structure, try to extract\n  if (linksData.links) { links = linksData.links; }\n  else if (linksData.recommendations) { links = linksData.recommendations; }\n}\nif (links.length > 0) {\n  finalContent += \"\\n\\nRelated articles:\\n\";\n  for (const link of links) {\n    if (typeof link === 'string') {\n      finalContent += `- ${link}\\n`;\n    } else if (link.url) {\n      const anchor = link.anchor || link.title || link.url;\n      finalContent += `- [${anchor}](${link.url})\\n`;\n    }\n  }\n}\nreturn [{ content: finalContent }];"
      },
      "id": "b4041cd7-6e24-4a0b-9618-0c9eb767b5a2",
      "name": "Internal Links Integrated",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        1600,
        100
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.plagiarismchecker.com/check",
        "bodyParameters": {
          "parameters": [
            {
              "name": "text",
              "value": "={{$json[\"content\"]}}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "1188de56-bc33-4ffe-a532-11db0de4e4eb",
      "name": "Plagiarism Check",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        1800,
        -100
      ]
    },
    {
      "parameters": {
        "operation": "createPost",
        "postType": "post",
        "title": "={{$node['Google Sheets Trigger'].json['Keyword']}}",
        "content": "={{$node['Internal Links Integrated'].json['content']}}",
        "additionalFields": {
          "status": "draft"
        }
      },
      "id": "b3227d93-3eaf-44c1-a797-3c87e2d46b77",
      "name": "WordPress Draft",
      "type": "n8n-nodes-base.wordPress",
      "typeVersion": 1,
      "position": [
        1800,
        100
      ],
      "credentials": {
        "wordPressApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Google Sheets Trigger": {
      "main": [
        [
          {
            "node": "SerpAPI Competitors",
            "type": "main",
            "index": 0
          },
          {
            "node": "Brand Tone Analysis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SerpAPI Competitors": {
      "main": [
        [
          {
            "node": "Process Competitors",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Competitors": {
      "main": [
        [
          {
            "node": "Merge Insights",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Brand Tone Analysis": {
      "main": [
        [
          {
            "node": "Merge Insights",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge Insights": {
      "main": [
        [
          {
            "node": "Content Draft (GPT-4)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Content Draft (GPT-4)": {
      "main": [
        [
          {
            "node": "AI Review & Refinement",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Review & Refinement": {
      "main": [
        [
          {
            "node": "Engagement & Readability",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Engagement & Readability": {
      "main": [
        [
          {
            "node": "Internal Linking",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Internal Linking": {
      "main": [
        [
          {
            "node": "Internal Links Integrated",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Internal Links Integrated": {
      "main": [
        [
          {
            "node": "Yoast Analysis",
            "type": "main",
            "index": 0
          },
          {
            "node": "Plagiarism Check",
            "type": "main",
            "index": 0
          },
          {
            "node": "WordPress Draft",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "createdAt": "2025-02-27T14:04:44.546Z",
  "updatedAt": "2025-02-27T14:04:44.546Z"
}