{
  "id": "EF17uxhwclWd4v2U",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Streamline Content Publishing from Google Sheets to Email & Slack with AI Formatting",
  "tags": [],
  "nodes": [
    {
      "id": "78fa1ab9-a189-44a6-a59d-1c93a060bb6a",
      "name": "Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1056,
        -864
      ],
      "parameters": {
        "width": 464,
        "height": 464,
        "content": "## \ud83d\udcdd AI-Powered Content Publishing System\n\n### How it works\nThis workflow automates the final stage of content creation by taking optimized drafts from Google Sheets, preparing them for publication with proper metadata and HTML formatting, and routing them through an approval process. An AI agent ensures all SEO elements are in place before the content is published to your CMS or sent for review.\n\n### Setup steps\n1. Connect Google Sheets OAuth2 credentials\n2. Connect OpenAI API key for the AI Agent\n3. Configure Gmail credentials for approval workflow\n4. Set up Slack webhook for notifications\n5. Update the spreadsheet ID and sheet name in fetch/update nodes\n6. Test with a sample content ID from your sheet"
      },
      "typeVersion": 1
    },
    {
      "id": "3115036f-7e4b-44d8-b019-0e1852141c35",
      "name": "Trigger Section",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1056,
        -368
      ],
      "parameters": {
        "color": 2,
        "width": 344,
        "height": 448,
        "content": "## \ud83c\udfaf Workflow Entry Point\nChat trigger initiates the publishing process. Prepares all required metadata including content ID, topic, intent, and platform parameters."
      },
      "typeVersion": 1
    },
    {
      "id": "f34c2f53-5318-4d5c-8143-232379d4d226",
      "name": "AI Processing",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -688,
        -368
      ],
      "parameters": {
        "color": 2,
        "width": 752,
        "height": 712,
        "content": "## \ud83e\udd16 AI Publishing Engine\nThe AI agent fetches optimized content from Sheets, formats it with proper HTML structure, generates SEO metadata (title, description, tags), and outputs structured JSON for downstream processing."
      },
      "typeVersion": 1
    },
    {
      "id": "f762a490-6945-4443-a132-ef5adaae80e7",
      "name": "Storage",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        -368
      ],
      "parameters": {
        "color": 2,
        "height": 448,
        "content": "## \ud83d\udcbe Data Storage & Logging\nWrites formatted content and metadata back to Google Sheets for version tracking and audit trail."
      },
      "typeVersion": 1
    },
    {
      "id": "cd86daf5-db24-4b29-9a75-d668969d0ae8",
      "name": "Approval Process",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        80
      ],
      "parameters": {
        "color": 2,
        "width": 720,
        "height": 352,
        "content": "## \u2705 Approval & Notification Flow\nSends content preview via email for approval. If approved, publishes to final destination and sends success notifications via Gmail and Slack."
      },
      "typeVersion": 1
    },
    {
      "id": "94e3c5f1-c16f-448b-96ad-be9f3dd1818c",
      "name": "Security Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        832,
        192
      ],
      "parameters": {
        "color": 3,
        "width": 320,
        "height": 232,
        "content": "## \ud83d\udd10 Credentials Required\n- **Google Sheets**: OAuth2 (automations@techdome.ai)\n- **OpenAI**: API key for GPT-4 mini\n- **Gmail**: OAuth2 for approval emails\n- **Slack**: API token for notifications\n\nReplace all credential IDs with your own before deployment."
      },
      "typeVersion": 1
    },
    {
      "id": "0eafc7ba-e377-487c-a8a8-1ab37c309973",
      "name": "Fetch Optimized Draft from Sheets",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        -256,
        176
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 2120745354,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fsnnXsU1n-iX-MEpLuw3XC6wHD-ek6OlkQe31ousk84/edit#gid=2120745354",
          "cachedResultName": "content_versions"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1fsnnXsU1n-iX-MEpLuw3XC6wHD-ek6OlkQe31ousk84",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fsnnXsU1n-iX-MEpLuw3XC6wHD-ek6OlkQe31ousk84/edit?usp=drivesdk",
          "cachedResultName": "SEO Content Automation"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "bda0fa55-f608-48f7-a958-bb39fffca859",
      "name": "Short-Term Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -416,
        160
      ],
      "parameters": {
        "sessionKey": "publish-session",
        "sessionIdType": "customKey"
      },
      "typeVersion": 1.3
    },
    {
      "id": "0dd22ba4-d37a-4d83-bf8f-b4adfd471329",
      "name": "AI Agent (Publisher)",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -352,
        -96
      ],
      "parameters": {
        "text": "=Topic: {{ $json.topic }}\nIntent: {{ $json.intent }}\nContent ID: {{ $json.content_id }}\nPlatform: {{ $json.parameter.platform || 'Internal CMS' }}\n\nContext (from Sheets or memory): {{ $json.context || $memory || 'No context found' }}\n\nPrepare the article for publishing. Ensure metadata, title, tags, and description are optimized. If the platform is WordPress, format the article in valid HTML. Return only structured JSON in the required format.",
        "options": {
          "systemMessage": "=You are \"Publisher Agent\", an AI responsible for preparing and posting optimized articles.\n\nYour tasks:\n1. Take the optimized draft and prepare it for publishing.\n2. Clean and format for web standards (HTML-ready headings, tags, meta info).\n3. Generate metadata, tags, and keywords.\n4. Always return structured JSON only, in this format:\n{\n  \"publish_data\": {\n    \"content_id\": \"string\",\n    \"version_id\": \"string\",\n    \"title\": \"string\",\n    \"meta_description\": \"string\",\n    \"tags\": [\"string\"],\n    \"html_body\": \"string\",\n    \"status\": \"Published\",\n    \"timestamp\": \"number\"\n  }\n}"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.1
    },
    {
      "id": "1b342934-ebb3-46e0-b6b7-03fee0b258f7",
      "name": "Output Parser (JSON Enforcement)",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -64,
        144
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"publish_data\": {\n    \"content_id\": \"CNT-1701255487715\",\n    \"version_id\": \"VER-004\",\n    \"title\": \"AI SEO Basics: How AI Is Transforming Content Ranking\",\n    \"meta_description\": \"Learn how AI SEO tools are transforming keyword optimization and content performance.\",\n    \"tags\": [\"AI\", \"SEO\", \"Content Marketing\"],\n    \"html_body\": \"<h1>AI SEO Basics</h1><p>AI is reshaping SEO...</p>\",\n    \"status\": \"Published\",\n    \"timestamp\": 1701265000000\n  }\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "99460d35-1aa2-4296-9c57-727580d24d4e",
      "name": "Save Published Content to Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        112,
        -96
      ],
      "parameters": {
        "columns": {
          "value": {
            "html": "={{ $json.output.publish_data.html_body }}",
            "status": "={{ $json.output.publish_data.status }}",
            "keywords": "={{ $json.output.publish_data.tags }}",
            "meta_desc": "={{ $json.output.publish_data.meta_description }}",
            "timestamp": "={{ $json.output.publish_data.timestamp }}",
            "content_id": "={{ $json.output.publish_data.content_id }}",
            "meta_title": "={{ $json.output.publish_data.title }}",
            "version_id": "={{ $json.output.publish_data.version_id }}"
          },
          "schema": [
            {
              "id": "content_id",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "content_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "version_no",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "version_no",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "version_id",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "version_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "topic",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "topic",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "meta_title",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "meta_title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "meta_desc",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "meta_desc",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "outline",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "outline",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "keywords",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "keywords",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "tone",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "tone",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "word_count",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "word_count",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "cta_ideas",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "cta_ideas",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "context_used",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "context_used",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "timestamp",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "timestamp",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "section",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "section",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "html",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "html",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "status",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "content_id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 2120745354,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fsnnXsU1n-iX-MEpLuw3XC6wHD-ek6OlkQe31ousk84/edit#gid=2120745354",
          "cachedResultName": "content_versions"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1fsnnXsU1n-iX-MEpLuw3XC6wHD-ek6OlkQe31ousk84",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fsnnXsU1n-iX-MEpLuw3XC6wHD-ek6OlkQe31ousk84/edit?usp=drivesdk",
          "cachedResultName": "SEO Content Automation"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "356208df-135f-431c-94fa-6059c6adf733",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -512,
        144
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "7da76b2e-1253-4e2c-a256-b050d52e63b8",
      "name": "Prepare Publishing Metadata",
      "type": "n8n-nodes-base.set",
      "position": [
        -624,
        -96
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "d917c6d3-ae35-4140-99c8-ae390866e735",
              "name": "intent",
              "type": "string",
              "value": "=publish"
            },
            {
              "id": "e697ec89-26ed-4fb3-95a9-4a0cc6eed36d",
              "name": "topic",
              "type": "string",
              "value": "=AI Seo Basics"
            },
            {
              "id": "f5a88ad2-7f57-4971-88ea-bad9e1c10992",
              "name": "content_id",
              "type": "string",
              "value": "=C001"
            },
            {
              "id": "06fb1d17-f233-4b22-af27-cd3351c971a0",
              "name": "parameter",
              "type": "object",
              "value": "={{ $json.parameter }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "bbc587a4-14a3-46d3-85e5-e2a2e9473286",
      "name": "Send Content for Approval",
      "type": "n8n-nodes-base.gmail",
      "position": [
        128,
        240
      ],
      "parameters": {
        "sendTo": "[user@example.com]",
        "message": "={{ $json.output.publish_data.html_body }}",
        "options": {},
        "subject": "={{ $json.output.publish_data.title }}",
        "operation": "sendAndWait"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "ddaaffa1-64d5-4e9d-bc13-9dc683172fa1",
      "name": "Check Approval Status",
      "type": "n8n-nodes-base.if",
      "position": [
        368,
        240
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "3c7c4382-eb2a-4fc8-9239-b0b6e212cd9c",
              "operator": {
                "type": "boolean",
                "operation": "equals"
              },
              "leftValue": "={{ $json.data.approved }}",
              "rightValue": true
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "3fc5fc6f-3a64-4892-8c24-a84b75521319",
      "name": "Publish to Recipient",
      "type": "n8n-nodes-base.gmail",
      "position": [
        656,
        128
      ],
      "parameters": {
        "sendTo": "[user@example.com]",
        "message": "={{ $('AI Agent (Publisher)').item.json.output.publish_data.html_body }}",
        "options": {},
        "subject": "={{ $('AI Agent (Publisher)').item.json.output.publish_data.title }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "9a848cc7-b6c6-4c99-a60a-378365af2b41",
      "name": "Send Success Notification to Slack",
      "type": "n8n-nodes-base.slack",
      "position": [
        624,
        288
      ],
      "parameters": {
        "text": "=Your  {{ $('AI Agent (Publisher)').item.json.output.publish_data.title }} has been Successfully Published.",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "C09GNB90TED",
          "cachedResultName": "general-information"
        },
        "otherOptions": {}
      },
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "16cd2672-d20f-4acd-ac27-b799b71171af",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -896,
        -96
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.3
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "05feecbc-27b2-4093-a260-02950e4b5f5f",
  "connections": {
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent (Publisher)",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Short-Term Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent (Publisher)",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent (Publisher)": {
      "main": [
        [
          {
            "node": "Save Published Content to Sheets",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send Content for Approval",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Approval Status": {
      "main": [
        [
          {
            "node": "Publish to Recipient",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send Success Notification to Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Content for Approval": {
      "main": [
        [
          {
            "node": "Check Approval Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "Prepare Publishing Metadata",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Publishing Metadata": {
      "main": [
        [
          {
            "node": "AI Agent (Publisher)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Output Parser (JSON Enforcement)": {
      "ai_outputParser": [
        [
          {
            "node": "AI Agent (Publisher)",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Optimized Draft from Sheets": {
      "ai_tool": [
        [
          {
            "node": "AI Agent (Publisher)",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}