{
  "name": "Auto-Instagram-post",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 13,
              "triggerAtMinute": 10
            }
          ]
        }
      },
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.3,
      "position": [
        208,
        0
      ],
      "id": "2287160e-776d-42ea-8f76-98c3bfb15bfd",
      "name": "Schedule Trigger"
    },
    {
      "parameters": {
        "resource": "image",
        "modelId": {
          "__rl": true,
          "value": "models/gemini-2.5-flash-image",
          "mode": "list",
          "cachedResultName": "models/gemini-2.5-flash-image (Nano Banana)"
        },
        "prompt": "={{ Object.values(JSON.parse($node[\"Generate-Prompt-and-Caption\"].json.text))[0] }}",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "typeVersion": 1.1,
      "position": [
        1008,
        0
      ],
      "id": "e0776d1b-e888-46ea-8799-846854b1ad73",
      "name": "Generate an image",
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {},
      "type": "n8n-nodes-uploadtourl.uploadToUrl",
      "typeVersion": 1,
      "position": [
        1264,
        0
      ],
      "id": "c4f13b1d-e038-40d8-9921-50c28c7a5542",
      "name": "Upload a File",
      "credentials": {
        "uploadToUrlApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "node": "17841477181716596",
        "imageUrl": "={{ $json.url }}",
        "caption": "={{ Object.values(JSON.parse($node[\"Generate-Prompt-and-Caption\"].json.text))[1] }}",
        "additionalFields": {}
      },
      "type": "@mookielianhd/n8n-nodes-instagram.instagram",
      "typeVersion": 1,
      "position": [
        1504,
        0
      ],
      "id": "e5762c2b-ec6f-43b4-a60e-9b753d02a55f",
      "name": "Publish",
      "credentials": {
        "instagramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "value": "1db8d4y_pxKDWg7YIpC4qaHEzu9WmhvHJuagK8ou_UNo",
          "mode": "list",
          "cachedResultName": "Instagram Posting",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1db8d4y_pxKDWg7YIpC4qaHEzu9WmhvHJuagK8ou_UNo/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1db8d4y_pxKDWg7YIpC4qaHEzu9WmhvHJuagK8ou_UNo/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "row_number": "={{ $('Get-Ideas').item.json.row_number }}",
            "Caption": "={{ Object.values(JSON.parse($node[\"Generate-Prompt-and-Caption\"].json.text))[1] }}",
            "Prompt": "={{ Object.values(JSON.parse($node[\"Generate-Prompt-and-Caption\"].json.text))[0] }}",
            "Image_URL": "={{ $('Upload a File').item.json.url }}",
            "Status": "Posted"
          },
          "matchingColumns": [
            "row_number"
          ],
          "schema": [
            {
              "id": "Idea/Niche",
              "displayName": "Idea/Niche",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Prompt",
              "displayName": "Prompt",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Caption",
              "displayName": "Caption",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Image_URL",
              "displayName": "Image_URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "displayName": "Status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "displayName": "row_number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "canBeUsedToMatch": true,
              "readOnly": true,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        1728,
        0
      ],
      "id": "2062a43c-d9e2-470b-8598-dacbf446a229",
      "name": "Update row in sheet",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "1db8d4y_pxKDWg7YIpC4qaHEzu9WmhvHJuagK8ou_UNo",
          "mode": "list",
          "cachedResultName": "Instagram Posting",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1db8d4y_pxKDWg7YIpC4qaHEzu9WmhvHJuagK8ou_UNo/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1db8d4y_pxKDWg7YIpC4qaHEzu9WmhvHJuagK8ou_UNo/edit#gid=0"
        },
        "filtersUI": {
          "values": [
            {
              "lookupColumn": "Status",
              "lookupValue": "Ready"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        448,
        0
      ],
      "id": "05f9851e-a36c-439a-b8e1-1178049658e5",
      "name": "Get-Ideas",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "**Workflow Overview**\n**This n8n workflow automatically runs daily at **1:10 PM IST**, picks an idea from a Google Sheet, generates an AI image prompt + Instagram caption, creates the image using Gemini, uploads it, posts it to Instagram, and updates the sheet with the result.**",
        "width": 448,
        "color": "#E6E6E6"
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        -368
      ],
      "typeVersion": 1,
      "id": "8b25a3fe-37a7-4b26-bdc3-19ba06dd96ed",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=You are a Content Generator. Based on the niche provided, return a flat JSON object.\n\nIdea/Niche: {{ $json['Idea/Niche'] }}\n\nEnsure the prompt is visually distinct for this specific topic and the caption uses relevant emojis and hashtags. Return only the JSON.\n\nDIRECTIONS:\n1. Analyze the 'Idea/Niche' to determine the appropriate aesthetic (e.g., Luxury, Gritty, Minimalist, or Vibrant).\n2. Generate an 'Image Prompt' optimized for high-end AI generators. Include specific camera settings (e.g., 35mm lens), lighting (e.g., volumetric lighting), and textures relevant to that specific niche.\n3. Generate a 'Caption' that matches the tone of the niche (e.g., professional for business, poetic for travel, energetic for fitness).",
        "messages": {
          "messageValues": []
        },
        "batching": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.9,
      "position": [
        672,
        0
      ],
      "id": "05785c5e-4408-48d6-8ffb-12393dae31d7",
      "name": "Generate-Prompt-and-Caption"
    },
    {
      "parameters": {
        "content": "## Step 1: Schedule Trigger\n\nFires the entire workflow automatically every day at **1:10 PM IST (13:10)**. No manual trigger is needed.\n",
        "height": 336,
        "width": 224,
        "color": 6
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        144,
        -176
      ],
      "typeVersion": 1,
      "id": "beb6c797-f4a0-45ab-a511-9511a2dd353b",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "content": "\n## Step 2: Get-Ideas\n\n### What it does\nReads rows from the **\"Instagram Posting\"** Google Sheet where the `Status` column equals `\"Ready\"`.\n\n\n### Sheet Columns Read\n- `Idea/Niche` \u2014 The niche topic entered manually by the user (e.g., *Minimalist Home*)\n- `row_number` \u2014 Used later to update the correct row after posting\n\n",
        "height": 528,
        "color": 3
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        384,
        -368
      ],
      "typeVersion": 1,
      "id": "3d7b0421-46ba-4f82-93a4-040fdea5f62d",
      "name": "Sticky Note2"
    },
    {
      "parameters": {
        "content": "## Step 3: Generate-Prompt-and-Caption\n### What it does\nProvides the **GPT-4.1 Nano** language model as the brain for the `Generate-Prompt-and-Caption` Basic LLM node.\nIt Takes the `Idea/Niche` from the Google Sheet and generates two things: **An image prompt** , **An Instagram caption**\n\n",
        "height": 464,
        "width": 288,
        "color": 2
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        640,
        -304
      ],
      "typeVersion": 1,
      "id": "04427449-a3bf-4ec2-a7b3-ad1bf1977a14",
      "name": "Sticky Note3"
    },
    {
      "parameters": {
        "content": "## Step 4: Generate an image\n\n### What it does\nTakes the **Image Prompt** generated by the LLM and uses **Google Gemini 2.5 Flash Image** model to generate the actual image.\n\n",
        "height": 400
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        944,
        -240
      ],
      "typeVersion": 1,
      "id": "1e3e29c4-1525-49c8-9c6d-3bfce2e59a00",
      "name": "Sticky Note4"
    },
    {
      "parameters": {
        "content": "## Step 5: Upload to URL\n\n### What it does\nUploads the **generated image binary** to a public CDN via the `uploadtourl` service, and returns a **public URL** for the image. This URL is needed for both Instagram publishing and saving to the sheet.\n\n",
        "height": 432,
        "color": 3
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1200,
        -272
      ],
      "typeVersion": 1,
      "id": "c3e5356f-47c4-4c5f-bfdc-02fb85087132",
      "name": "Sticky Note5"
    },
    {
      "parameters": {
        "content": "## Step 7: Update row in sheet\n\n### What it does\nUpdates the original row in the **Google Sheet** with all the auto-generated data after a successful post, marking the workflow cycle as complete.\n\n",
        "height": 400,
        "width": 224,
        "color": 6
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1680,
        -240
      ],
      "typeVersion": 1,
      "id": "6a7a0fd8-af33-40be-b0c0-7abc8421995d",
      "name": "Sticky Note6"
    },
    {
      "parameters": {
        "content": "## Step 6: Publish\n\n### What it does\nPosts the generated image to **Instagram** as a feed post with the AI-generated caption.\n\n",
        "height": 352,
        "width": 208,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1456,
        -192
      ],
      "typeVersion": 1,
      "id": "8943dcb5-2e22-4d66-9d78-11bf6c600236",
      "name": "Sticky Note7"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-4.1-nano",
          "mode": "list",
          "cachedResultName": "gpt-4.1-nano"
        },
        "builtInTools": {},
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.3,
      "position": [
        640,
        176
      ],
      "id": "7118efda-d59f-479b-8278-18f1568e06da",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Get-Ideas",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate an image": {
      "main": [
        [
          {
            "node": "Upload a File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload a File": {
      "main": [
        [
          {
            "node": "Publish",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Publish": {
      "main": [
        [
          {
            "node": "Update row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get-Ideas": {
      "main": [
        [
          {
            "node": "Generate-Prompt-and-Caption",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate-Prompt-and-Caption": {
      "main": [
        [
          {
            "node": "Generate an image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Generate-Prompt-and-Caption",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate"
  },
  "versionId": "b7b18580-c992-4fc7-b878-d7035ace2237",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "YSNgbFkI26v0HR3w",
  "tags": []
}