{
  "name": "AI Content Pipeline — Notion Ideas to Review-Ready Drafts",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "days",
              "triggerAtHour": 7,
              "triggerAtMinute": 0
            }
          ]
        }
      },
      "id": "c1d2e3f4-1111-4c2d-8e3f-0a1b2c3d4e5f",
      "name": "Schedule: Every Morning",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [-240, 300]
    },
    {
      "parameters": {
        "resource": "databasePage",
        "operation": "getAll",
        "databaseId": {
          "__rl": true,
          "value": "YOUR_NOTION_DATABASE_ID",
          "mode": "id"
        },
        "limit": 1,
        "filterType": "manual",
        "filters": {
          "conditions": [
            {
              "key": "Status|status",
              "condition": "equals",
              "statusValue": "Ready"
            }
          ]
        },
        "options": {}
      },
      "id": "d2e3f4a5-2222-4d3e-9f4a-1b2c3d4e5f6a",
      "name": "Notion: Get Ready Ideas",
      "type": "n8n-nodes-base.notion",
      "typeVersion": 2.2,
      "position": [0, 300],
      "credentials": {
        "notionApi": {
          "id": "YOUR_NOTION_CREDENTIAL",
          "name": "YOUR_NOTION_CREDENTIAL"
        }
      }
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4o-mini",
          "mode": "list",
          "cachedResultName": "gpt-4o-mini"
        },
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "You are a senior content strategist for a B2B SaaS blog. Given a post idea, produce a detailed outline.\n\nRules:\n- 5-7 H2 sections, each with 2-4 bullet points of what to cover.\n- Include a working title (max 60 chars) and a target keyword.\n- Audience: operations and marketing managers evaluating automation tools. Practical, no fluff.\n\nRespond ONLY with valid JSON, no markdown fences, exactly this shape:\n{\"working_title\": string, \"target_keyword\": string, \"sections\": [{\"heading\": string, \"points\": [string]}]}"
            },
            {
              "role": "user",
              "content": "=Create an outline for this content idea:\nTitle: {{ $json.properties?.Name?.title?.[0]?.plainText ?? $json.name }}\nAngle/notes: {{ $json.properties?.Notes?.rich_text?.[0]?.plainText ?? 'none' }}"
            }
          ]
        },
        "jsonOutput": true,
        "options": {
          "temperature": 0.5
        }
      },
      "id": "e3f4a5b6-3333-4e4f-8a5b-2c3d4e5f6a7b",
      "name": "OpenAI: Outline",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [240, 300],
      "credentials": {
        "openAiApi": {
          "id": "YOUR_OPENAI_CREDENTIAL",
          "name": "YOUR_OPENAI_CREDENTIAL"
        }
      }
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4o",
          "mode": "list",
          "cachedResultName": "gpt-4o"
        },
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "You are a senior B2B content writer. Write a complete first draft following the outline you are given.\n\nRules:\n- 900-1200 words, markdown format with ## headings matching the outline.\n- Short paragraphs (max 3 sentences), concrete examples, no filler phrases like 'in today's fast-paced world'.\n- Write in second person where natural. End with a short conclusion and one clear call to action.\n- Output plain markdown only, no JSON, no preamble, no commentary."
            },
            {
              "role": "user",
              "content": "=Write the full draft from this outline:\n{{ JSON.stringify($json.message?.content ?? $json) }}"
            }
          ]
        },
        "options": {
          "temperature": 0.7,
          "maxTokens": 2500
        }
      },
      "id": "f4a5b6c7-4444-4f5a-9b6c-3d4e5f6a7b8c",
      "name": "OpenAI: Write Draft",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [480, 300],
      "credentials": {
        "openAiApi": {
          "id": "YOUR_OPENAI_CREDENTIAL",
          "name": "YOUR_OPENAI_CREDENTIAL"
        }
      }
    },
    {
      "parameters": {
        "resource": "block",
        "operation": "append",
        "blockId": {
          "__rl": true,
          "value": "={{ $('Notion: Get Ready Ideas').item.json.id }}",
          "mode": "id"
        },
        "blockUi": {
          "blockValues": [
            {
              "type": "paragraph",
              "textContent": "={{ $json.message?.content ?? $json.text }}"
            }
          ]
        }
      },
      "id": "a5b6c7d8-5555-4a6b-8c7d-4e5f6a7b8c9d",
      "name": "Notion: Append Draft",
      "type": "n8n-nodes-base.notion",
      "typeVersion": 2.2,
      "position": [720, 300],
      "credentials": {
        "notionApi": {
          "id": "YOUR_NOTION_CREDENTIAL",
          "name": "YOUR_NOTION_CREDENTIAL"
        }
      }
    },
    {
      "parameters": {
        "resource": "databasePage",
        "operation": "update",
        "pageId": {
          "__rl": true,
          "value": "={{ $('Notion: Get Ready Ideas').item.json.id }}",
          "mode": "id"
        },
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "Status|status",
              "statusValue": "Review"
            }
          ]
        },
        "options": {}
      },
      "id": "b6c7d8e9-6666-4b7c-9d8e-5f6a7b8c9d0e",
      "name": "Notion: Set Status Review",
      "type": "n8n-nodes-base.notion",
      "typeVersion": 2.2,
      "position": [960, 300],
      "credentials": {
        "notionApi": {
          "id": "YOUR_NOTION_CREDENTIAL",
          "name": "YOUR_NOTION_CREDENTIAL"
        }
      }
    }
  ],
  "connections": {
    "Schedule: Every Morning": {
      "main": [
        [
          {
            "node": "Notion: Get Ready Ideas",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notion: Get Ready Ideas": {
      "main": [
        [
          {
            "node": "OpenAI: Outline",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI: Outline": {
      "main": [
        [
          {
            "node": "OpenAI: Write Draft",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI: Write Draft": {
      "main": [
        [
          {
            "node": "Notion: Append Draft",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notion: Append Draft": {
      "main": [
        [
          {
            "node": "Notion: Set Status Review",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}
