{
  "name": "Scheduled Daily Image Generation",
  "nodes": [
    {
      "parameters": {
        "content": "## Scheduled Daily Images\n\nAutomatically generate an image every day at 9 AM with random prompts.\n\n### Setup Steps:\n\n1. **Install n8n-nodes-sogni**\n   - Settings \u2192 Community Nodes \u2192 Install \u2192 `n8n-nodes-sogni`\n\n2. **Add Sogni Credentials**\n   - Create account at https://app.sogni.ai\n   - Add credentials in n8n: Sogni AI API\n\n3. **Activate Workflow**\n   - Toggle workflow to Active for scheduled runs\n\n### Customization:\n\n- **Schedule**: Change cron in trigger (default: 9 AM daily)\n- **Prompts**: Edit array in \"Prepare Daily Data\" node\n- **Token Check**: Adjust threshold in \"Has Tokens?\" node\n- **Output**: Add nodes to save/send the image",
        "height": 440,
        "width": 340,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -140,
        80
      ],
      "id": "sticky-setup-instructions",
      "name": "Setup Instructions"
    },
    {
      "parameters": {
        "content": "### Random Prompts\n\n- zen garden\n- vibrant sunset\n- cozy coffee shop\n- starry night sky\n- blooming flower garden\n\nAdd more prompts in the\n\"Prepare Daily Data\" node!",
        "height": 200,
        "width": 200,
        "color": 3
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        400,
        80
      ],
      "id": "sticky-prompts-reference",
      "name": "Prompts Reference"
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 9 * * *"
            }
          ]
        }
      },
      "id": "schedule-trigger",
      "name": "Every Day at 9 AM",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1,
      "position": [
        250,
        300
      ],
      "notes": "Runs daily at 9 AM (cron: 0 9 * * *)"
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "date",
              "value": "={{ $now.format('YYYY-MM-DD') }}"
            },
            {
              "name": "prompt",
              "value": "={{ \"Daily inspiration: \" + [\"a peaceful zen garden\", \"a vibrant sunset\", \"a cozy coffee shop\", \"a starry night sky\", \"a blooming flower garden\"][Math.floor(Math.random() * 5)] }}"
            }
          ]
        },
        "options": {}
      },
      "id": "prepare-data",
      "name": "Prepare Daily Data",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3,
      "position": [
        450,
        300
      ],
      "notes": "Sets date and picks random prompt from array"
    },
    {
      "parameters": {
        "resource": "account",
        "operation": "getBalance"
      },
      "id": "check-balance",
      "name": "Check Token Balance",
      "type": "n8n-nodes-sogni.sogni",
      "typeVersion": 1,
      "position": [
        650,
        300
      ],
      "notes": "Gets current Spark/SOGNI token balance"
    },
    {
      "parameters": {
        "conditions": {
          "number": [
            {
              "value1": "={{ $json.spark }}",
              "operation": "larger",
              "value2": 0
            }
          ]
        }
      },
      "id": "check-if-tokens",
      "name": "Has Tokens?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        850,
        300
      ],
      "notes": "Routes based on whether Spark tokens are available"
    },
    {
      "parameters": {
        "resource": "image",
        "operation": "generate",
        "modelId": "flux1-schnell-fp8",
        "positivePrompt": "={{ $('Prepare Daily Data').item.json.prompt }}, beautiful, high quality, detailed",
        "network": "fast",
        "additionalFields": {
          "steps": 4,
          "guidance": 3.5,
          "numberOfMedia": 1,
          "tokenType": "spark"
        }
      },
      "id": "generate-daily-image",
      "name": "Generate Daily Image",
      "type": "n8n-nodes-sogni.sogni",
      "typeVersion": 1,
      "position": [
        1050,
        200
      ],
      "notes": "Generates image with the random daily prompt"
    },
    {
      "parameters": {
        "content": "## Daily Image Generated\n\n**Date**: {{ $('Prepare Daily Data').item.json.date }}\n\n**Prompt**: {{ $('Prepare Daily Data').item.json.prompt }}\n\n**Image URL**: {{ $json.imageUrls[0] }}\n\n**Project ID**: {{ $json.projectId }}",
        "html": "<h2>Daily Image Generated</h2>\n<p><strong>Date</strong>: {{ $('Prepare Daily Data').item.json.date }}</p>\n<p><strong>Prompt</strong>: {{ $('Prepare Daily Data').item.json.prompt }}</p>\n<p><strong>Image URL</strong>: {{ $json.imageUrls[0] }}</p>\n<p><strong>Project ID</strong>: {{ $json.projectId }}</p>",
        "options": {}
      },
      "id": "format-notification",
      "name": "Format Notification",
      "type": "n8n-nodes-base.markdown",
      "typeVersion": 1,
      "position": [
        1250,
        200
      ],
      "notes": "Formats output with image details"
    },
    {
      "parameters": {
        "content": "## Insufficient Tokens\n\nCannot generate daily image. Please add more Spark tokens to your Sogni account.",
        "html": "<p><strong>Insufficient Tokens</strong></p>\n<p>Cannot generate daily image. Please add more Spark tokens to your Sogni account.</p>",
        "options": {}
      },
      "id": "no-tokens-message",
      "name": "No Tokens Message",
      "type": "n8n-nodes-base.markdown",
      "typeVersion": 1,
      "position": [
        1050,
        400
      ],
      "notes": "Error message when no tokens available"
    }
  ],
  "connections": {
    "Every Day at 9 AM": {
      "main": [
        [
          {
            "node": "Prepare Daily Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Daily Data": {
      "main": [
        [
          {
            "node": "Check Token Balance",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Token Balance": {
      "main": [
        [
          {
            "node": "Has Tokens?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has Tokens?": {
      "main": [
        [
          {
            "node": "Generate Daily Image",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Tokens Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Daily Image": {
      "main": [
        [
          {
            "node": "Format Notification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [],
  "triggerCount": 0,
  "meta": {
    "templateCredsSetupCompleted": false
  }
}