How To Create Shopify AI Blog Agent – [N8N Free Template]

Boost your store’s organic traffic and supercharge your SEO with our powerful AI blog generator for Shopify products. For busy e-commerce owners, consistent content creation is one of the biggest hurdles to ranking on Google. Manually writing articles for each product isn’t scalable, leaving valuable SEO opportunities on the table.

That’s why we’ve created the ultimate solution: a free N8N template that automates the entire process. This workflow automatically transforms your product data into unique, SEO-optimized articles and publishes them directly to your Shopify blog. Stop trading time for content and start driving targeted customers to your store effortlessly. In this guide, we’ll give you the free template and show you how to set up this game-changing automation in minutes.

Complete workflow below:

{
  "name": "AI Blog Generator For Shopify",
  "nodes": [
    {
      "parameters": {
        "authentication": "accessToken",
        "resource": "product",
        "operation": "getAll",
        "limit": 3,
        "additionalFields": {}
      },
      "id": "a1a04d29-ff36-4b11-a16f-e3ddb6de3473",
      "name": "Shopify",
      "type": "n8n-nodes-base.shopify",
      "position": [
        -580,
        -60
      ],
      "typeVersion": 1,
      "credentials": {
        "shopifyAccessTokenApi": {
          "id": "Bh6hZSZiNG0NZ0JU",
          "name": "Shopify Access Token account"
        }
      }
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "1gnygfCXJWa1uploTP-iwzdLHBnT_1r10meVsqlvTe8o",
          "mode": "list",
          "cachedResultName": "Shopify Products Data ",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1gnygfCXJWa1uploTP-iwzdLHBnT_1r10meVsqlvTe8o/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1gnygfCXJWa1uploTP-iwzdLHBnT_1r10meVsqlvTe8o/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "ID": "={{ $json.id }}",
            "Title": "={{ $json.title }}",
            "Description": "={{ $json.body_html }}"
          },
          "matchingColumns": [
            "ID"
          ],
          "schema": [
            {
              "id": "ID",
              "displayName": "ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Title",
              "displayName": "Title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Description",
              "displayName": "Description",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        -140,
        -60
      ],
      "id": "203ce8cb-a5f5-4f2b-8752-446d38c8b665",
      "name": "Product Data in Google Sheet",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "P8GbujCvl57Gl2lU",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        80,
        -60
      ],
      "id": "f36fdfae-0250-40a3-8a79-cd169d088d84",
      "name": "Loop Over Items"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=You are an AI agent responsible for automating blog creation for Shopify products\n\nWrite an SEO-friendly blog post that helps promote the following Shopify product. Use the product title and description below to create a compelling, engaging, and informative article that:\n\nNaturally incorporates relevant keywords from the product title and description.\n\nIncludes an attention-grabbing introduction.\n\nHighlights the product features, benefits, and use cases.\n\nBuilds trust with the reader using persuasive and friendly language.\n\nEnds with a clear call-to-action (CTA) encouraging the reader to explore or purchase the product.\n\nOptimize the blog for search engines (on-page SEO: headings, keyword placement, meta description, etc.)\n\n- SEO-Friendly Blog Title\n- Meta Description\n- Formatted Blog Content in clean, structured HTML:\n  - Introduction summary\n  - H2/H3 subheadings\n  - Bullet points (key benefits, nutrients)\n  - Nutrient callouts or tables (if available)\n  - Closing paragraph or CTA\n  - Add internal keywords (tags)\n\n\nProduct Title: {{ $('variables').item.json.title }}\nProduct Description: {{ $('variables').item.json.body_html }}\n\n\n### Provide ONLY the JSON object with the title and description.\n\nThe JSON object must have exactly two keys:\n1.  `blogTitle`: A string containing a compelling, SEO-friendly title for the blog post.\n2.  `blogContent`: A string containing the full blog post formatted in clean, structured HTML. The HTML should include headings (H2, H3), paragraphs, bullet points, and a clear call-to-action.\n\nHere is an example of the required output format:\n{\n  \"blogTitle\": \"Example SEO-Friendly Title\",\n  \"blogContent\": \"<h1>Example Heading</h1><p>This is the full HTML content of the blog post...</p>\"\n}\n\n\n\n\n\n\n\n\n\n",
        "hasOutputParser": true,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.9,
      "position": [
        300,
        -60
      ],
      "id": "34cc8fe4-3e86-4f3e-a27a-3bc350d9c3dd",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('variables').item.json.id }}"
      },
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        448,
        160
      ],
      "id": "999d71ed-4feb-4e10-be85-fcd5ff45a0b1",
      "name": "Simple Memory"
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "// This code will run for each item coming from the AI Agent.\nconst item = $input.item;\nconst aiOutput = item.json.output;\n\n// Use a try-catch block to safely handle potential JSON parsing errors\ntry {\n  // Regular expression to find a JSON object within the AI's output string.\n  const jsonMatch = aiOutput.match(/{.*}/s);\n\n  if (!jsonMatch) {\n    throw new Error(\"No JSON object found in the AI output.\");\n  }\n\n  const jsonString = jsonMatch[0];\n  const parsedData = JSON.parse(jsonString);\n\n  // --- RESILIENT KEY CHECKING ---\n  // This is the important part. It checks for multiple possible key names.\n  const title = parsedData.blogTitle || parsedData.title;\n  const content = parsedData.blogContent || parsedData.description;\n  \n  // If either the title or content could not be found, throw an error.\n  if (!title || !content) {\n    throw new Error(\"The parsed JSON is missing a recognizable title or content field.\");\n  }\n  \n  // Return the data using the consistent keys that the next nodes expect.\n  return {\n    json: {\n      ...item.json, // Carry over original data\n      blogTitle: title,\n      blogContent: content\n    }\n  };\n\n} catch (error) {\n  // If anything goes wrong, log the error and prevent this item from proceeding.\n  console.error(\"Failed to parse AI output:\", error.message, \"Raw Output:\", aiOutput);\n  return {\n    json: {\n      error: \"Failed to parse AI output\",\n      errorMessage: error.message\n    }\n  };\n}"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        676,
        -60
      ],
      "id": "3f6da01f-c442-4e8c-b326-3df9a8c08f9e",
      "name": "Code"
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "1gnygfCXJWa1uploTP-iwzdLHBnT_1r10meVsqlvTe8o",
          "mode": "list",
          "cachedResultName": "Shopify Products Data ",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1gnygfCXJWa1uploTP-iwzdLHBnT_1r10meVsqlvTe8o/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": 867989363,
          "mode": "list",
          "cachedResultName": "Blogs",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1gnygfCXJWa1uploTP-iwzdLHBnT_1r10meVsqlvTe8o/edit#gid=867989363"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Title": "={{ $json.blogTitle }}",
            "Description": "={{ $json.blogContent }}"
          },
          "matchingColumns": [
            "Title"
          ],
          "schema": [
            {
              "id": "Title",
              "displayName": "Title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Description",
              "displayName": "Description",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        896,
        -60
      ],
      "id": "bb6d1925-b7b1-446e-b86f-a574a6a7436a",
      "name": "Google Sheets1",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "P8GbujCvl57Gl2lU",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -800,
        -60
      ],
      "id": "2fa3a524-4d67-4c66-9e8d-bb8a79da214f",
      "name": "When clicking ‘Test workflow’"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://{{ $('variables').item.json.shop }}.myshopify.com/admin/api/2024-01/blogs/{{ $('variables').item.json.blogId }}/articles.json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "shopifyAccessTokenApi",
        "sendBody": true,
        "specifyBody": "=json",
        "bodyParameters": {
          "parameters": [
            {}
          ]
        },
        "jsonBody": "={{\n  {\n    \"article\": {\n      \"title\": $('Code').item.json.blogTitle,\n      \"body_html\": $('Code').item.json.blogContent,\n      \"tags\": \"nutrition, wellness, product, shopify\",\n      \"published\": false // Changed to true to make it visible, or keep as false for a draft\n    }\n  }\n}}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1116,
        65
      ],
      "id": "9ee2a382-7192-4635-bc8a-af407e944f03",
      "name": "Create Blog As Draft",
      "credentials": {
        "shopifyAccessTokenApi": {
          "id": "FDDArugMXjd7Uvcx",
          "name": "Shopify Access Token account 2"
        }
      }
    },
    {
      "parameters": {
        "sendTo": "websensepro@gmail.com",
        "subject": "Blog Posts Are Created ",
        "message": "I am your AI Agent: Good news, I have added all the blog posts as draft after reading all your product data.",
        "options": {}
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        676,
        -360
      ],
      "id": "1231460e-e377-42f9-a375-0ef579debd43",
      "name": "Gmail",
      "webhookId": "ab45017f-7eb5-4096-ae7c-829ec389fc08",
      "credentials": {
        "gmailOAuth2": {
          "id": "qZE7ELVggGYBiV5W",
          "name": "Gmail account"
        }
      }
    },
    {
      "parameters": {
        "amount": 1
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        378,
        -360
      ],
      "id": "a4c30916-ddcf-4895-a0c7-352edc14d253",
      "name": "Wait",
      "webhookId": "b785db31-5c8a-4c70-8bd7-a1467c79d18a",
      "executeOnce": true
    },
    {
      "parameters": {
        "model": "deepseek/deepseek-r1:free",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "typeVersion": 1,
      "position": [
        180,
        140
      ],
      "id": "b94b3c84-1bed-463a-8085-65e4e9b1adf4",
      "name": "OpenRouter Chat Model",
      "credentials": {
        "openRouterApi": {
          "id": "xkKhxDikT8xrFJS0",
          "name": "OpenRouter account"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "93cb8cc0-cdcd-44da-8187-9df85b770293",
              "name": "title",
              "type": "string",
              "value": "={{ $json.title }}"
            },
            {
              "id": "95990abc-b64d-4cb4-8d4e-88145395a3fc",
              "name": "id",
              "type": "number",
              "value": "=  {{ $json.id }}"
            },
            {
              "id": "d833cfa1-9abf-4a9d-86ed-a713acbc1974",
              "name": "body_html",
              "type": "string",
              "value": "={{ $json.body_html }}"
            },
            {
              "id": "65890399-7618-40c9-8cf6-f9fa49085893",
              "name": "shop",
              "value": "developmentwebsensepro",
              "type": "string"
            },
            {
              "id": "eab7febd-523d-4cda-9956-ebf3fc4efb31",
              "name": "blogId",
              "value": "94126407876",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "6e17d796-919e-4f4d-b3e8-c944760d5c13",
      "name": "variables",
      "type": "n8n-nodes-base.set",
      "position": [
        -360,
        -60
      ],
      "typeVersion": 3.4
    },
    {
      "parameters": {
        "content": "## Set \n- Set your shopify store name \n- Set you blog Id\n",
        "height": 420
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -420,
        -320
      ],
      "typeVersion": 1,
      "id": "aee6676e-33a6-48bc-a605-799fb0f5b395",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "content": "## Free AI Agent by WebSensePro\n\n**Complete Free AI agent to read Shopify products and create new blogs based on product Title and Description**\n\n[Contact for creating custom automations](https://websensepro.com/contact-us)\n\n[Subscribe Our Youtube For Free Tutorials](https://www.youtube.com/c/websensepro?sub_confirmation=1)",
        "height": 260,
        "width": 380,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -880,
        -600
      ],
      "typeVersion": 1,
      "id": "8db51f16-cd0d-4d06-ad2c-59291fea3011",
      "name": "Sticky Note1"
    }
  ],
  "pinData": {},
  "connections": {
    "Shopify": {
      "main": [
        [
          {
            "node": "variables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Product Data in Google Sheet": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "Google Sheets1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets1": {
      "main": [
        [
          {
            "node": "Create Blog As Draft",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "Shopify",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Blog As Draft": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Gmail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "variables": {
      "main": [
        [
          {
            "node": "Product Data in Google Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "07880b91-de1f-49da-8eaa-0968cbe1d609",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "7d6a5bcda733904ebcb54fc0e889f6735550f40f670703e17874c0872e05a9cb"
  },
  "id": "Ov7xcQ1WFJLj4Vnf",
  "tags": []
}
5/5 - (6 votes)

About

Leave a Comment

Your email address will not be published. Required fields are marked *