{
  "name": "Daily Digital Products Automation - PDFCrowd",
  "nodes": [
    {
      "parameters": {},
      "name": "Trigger Manually",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "const niches = [\"Fitness\", \"Cooking\", \"Finance\", \"Education\", \"Mindfulness\", \"Productivity\", \"Travel\", \"Parenting\", \"DIY\", \"Pets\", \"Fashion\", \"Gaming\", \"Health\", \"Marketing\", \"Technology\", \"Art\", \"Photography\", \"Language Learning\", \"Self-Improvement\", \"Motivation\"];\nreturn niches.map(niche => ({ json: { niche } }));"
      },
      "name": "Generate Niches",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        500,
        300
      ]
    },
    {
      "parameters": {
        "batchSize": 1
      },
      "name": "Split In Batches",
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 1,
      "position": [
        750,
        300
      ]
    },
    {
      "parameters": {
        "url": "https://api.openai.com/v1/chat/completions",
        "method": "POST",
        "jsonParameters": true,
        "bodyParametersJson": "{\n  \"model\": \"gpt-3.5-turbo\",\n  \"messages\": [\n    {\"role\": \"system\", \"content\": \"You are a helpful assistant that generates digital product ideas.\"},\n    {\"role\": \"user\", \"content\": \"Generate a digital product in the niche {{$json.niche}}. Include title, short description, and price in USD. Return in JSON format like {\\\"title\\\":\\\"...\\\",\\\"description\\\":\\\"...\\\",\\\"price_usd\\\":...}.\"}\n  ]\n}"
      },
      "name": "OpenAI Generate Product",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        1000,
        300
      ],
      "credentials": {
        "httpBasicAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "url": "https://api.pdfcrowd.com/convert/",
        "method": "POST",
        "options": {},
        "bodyParametersJson": "{\n  \"src\": \"<h1>{{$json.title}}</h1><p>{{$json.description}}</p>\",\n  \"use_print\": \"false\",\n  \"pdf_name\": \"{{$json.title}}.pdf\"\n}",
        "responseFormat": "file",
        "binaryPropertyName": "data",
        "authentication": "basicAuth",
        "basicAuthUser": "YOUR_PDFCROWD_USERNAME",
        "basicAuthPassword": "YOUR_PDFCROWD_APIKEY"
      },
      "name": "Generate PDF via PDFCrowd",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        1250,
        300
      ]
    },
    {
      "parameters": {
        "url": "https://api.openai.com/v1/images/generations",
        "method": "POST",
        "jsonParameters": true,
        "bodyParametersJson": "{\n  \"prompt\": \"Cover image for {{$json.title}}, niche: {{$json.niche}}, professional digital product style\",\n  \"size\": \"512x512\",\n  \"n\":1\n}"
      },
      "name": "OpenAI Cover Image",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        1500,
        300
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "url": "https://api.gumroad.com/v2/products",
        "method": "POST",
        "jsonParameters": false,
        "bodyParametersJson": "{\n  \"product[name]\": \"{{$json.title}}\",\n  \"product[description]\": \"{{$json.description}}\",\n  \"product[price]\": \"{{$json.price_usd}}\",\n  \"files[]\": \"{{$binary.data}}\",\n  \"cover\": \"{{$binary.cover}}\"\n}"
      },
      "name": "Gumroad Upload",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        1750,
        300
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "append",
        "sheetId": "YOUR_GOOGLE_SHEET_ID",
        "range": "Sheet1",
        "columns": [
          {
            "column": "A",
            "value": "={{$json.niche}}"
          },
          {
            "column": "B",
            "value": "={{$json.title}}"
          },
          {
            "column": "C",
            "value": "={{$json.price_usd}}"
          },
          {
            "column": "D",
            "value": "={{$json.product_permalink}}"
          },
          {
            "column": "E",
            "value": ""
          },
          {
            "column": "F",
            "value": "={{$now.toISOString()}}"
          }
        ]
      },
      "name": "Google Sheets Log",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 1,
      "position": [
        2000,
        300
      ],
      "credentials": {
        "googleSheetsOAuth2Api": "<your credential>"
      }
    }
  ],
  "connections": {
    "Trigger Manually": {
      "main": [
        [
          {
            "node": "Generate Niches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Niches": {
      "main": [
        [
          {
            "node": "Split In Batches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split In Batches": {
      "main": [
        [
          {
            "node": "OpenAI Generate Product",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Generate Product": {
      "main": [
        [
          {
            "node": "Generate PDF via PDFCrowd",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate PDF via PDFCrowd": {
      "main": [
        [
          {
            "node": "OpenAI Cover Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Cover Image": {
      "main": [
        [
          {
            "node": "Gumroad Upload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gumroad Upload": {
      "main": [
        [
          {
            "node": "Google Sheets Log",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}