{
  "id": "p7rsqsusuSDyHGHA",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Nano image Gen + social media posting",
  "tags": [
    {
      "id": "e8dSqjTcAMvetylS",
      "name": "marketing",
      "createdAt": "2025-07-31T16:32:13.768Z",
      "updatedAt": "2025-07-31T16:32:13.768Z"
    }
  ],
  "nodes": [
    {
      "id": "f29d992d-3607-4270-8853-e15941e28b25",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        32,
        64
      ],
      "parameters": {
        "path": "12bb14d8-f9dc-4671-b5ed-10a44238f4aa",
        "options": {}
      },
      "typeVersion": 2.1
    },
    {
      "id": "afba7da5-7706-427e-8854-bfe14acbad6f",
      "name": "Airtable Upload",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1568,
        -128
      ],
      "parameters": {
        "url": "=https://content.airtable.com/v0/appFSBG2xgidVIKR1/{{ $('Get Rows').item.json.id }}/Nano%20Image/uploadAttachment",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"contentType\": \"image/png\",\n  \"file\": \"{{ $('Nano Bannana Image Generation').item.json.choices[0].message.images[0].image_url.url }}\",\n  \"filename\": \"generated_image.png\"\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "airtableTokenApi"
      },
      "credentials": {
        "airtableTokenApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "42bca267-93ae-4fe7-bf6c-e9c21dc96b24",
      "name": "Status Complete",
      "type": "n8n-nodes-base.airtable",
      "position": [
        2160,
        48
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "appFSBG2xgidVIKR1",
          "cachedResultUrl": "https://airtable.com/appFSBG2xgidVIKR1",
          "cachedResultName": "Nano Banana Ad Machine"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tblCzppnhEo5uVeTq",
          "cachedResultUrl": "https://airtable.com/appFSBG2xgidVIKR1/tblCzppnhEo5uVeTq",
          "cachedResultName": "NannoB"
        },
        "columns": {
          "value": {
            "ID": "={{ $('Get Rows').item.json.ID }}",
            "Status": "Completed"
          },
          "schema": [
            {
              "id": "id",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "id",
              "defaultMatch": true
            },
            {
              "id": "ID",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": true,
              "required": false,
              "displayName": "ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Picture",
              "type": "array",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Picture",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "options",
              "display": true,
              "options": [
                {
                  "name": "Create",
                  "value": "Create"
                },
                {
                  "name": "Completed",
                  "value": "Completed"
                },
                {
                  "name": "Error",
                  "value": "Error"
                }
              ],
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Core Subject",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Core Subject",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Setting",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Setting",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Composition",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Composition",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Lighting",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Lighting",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Style",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Style",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Atmosphere",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Atmosphere",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Color Palette",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Color Palette",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Text Overlay",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Text Overlay",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Nano Image",
              "type": "array",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Nano Image",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Trigger n8n Workflow",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "Trigger n8n Workflow",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "ID"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update"
      },
      "credentials": {
        "airtableTokenApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "f729f6b2-29df-46f4-a785-1e40dbd7ba91",
      "name": "Status Error",
      "type": "n8n-nodes-base.airtable",
      "position": [
        1536,
        288
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "appFSBG2xgidVIKR1",
          "cachedResultUrl": "https://airtable.com/appFSBG2xgidVIKR1",
          "cachedResultName": "Nano Banana Ad Machine"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tblCzppnhEo5uVeTq",
          "cachedResultUrl": "https://airtable.com/appFSBG2xgidVIKR1/tblCzppnhEo5uVeTq",
          "cachedResultName": "NannoB"
        },
        "columns": {
          "value": {
            "Status": "Error",
            "Nano Image": "={{ $json.error.code }} {{ $json.error.status }}"
          },
          "schema": [
            {
              "id": "id",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": true,
              "required": false,
              "displayName": "id",
              "defaultMatch": true
            },
            {
              "id": "ID",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Picture",
              "type": "array",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Picture",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "options",
              "display": true,
              "options": [
                {
                  "name": "Create",
                  "value": "Create"
                },
                {
                  "name": "Completed",
                  "value": "Completed"
                },
                {
                  "name": "Error",
                  "value": "Error"
                }
              ],
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Core Subject",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Core Subject",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Setting",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Setting",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Composition",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Composition",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Lighting",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Lighting",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Style",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Style",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Atmosphere",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Atmosphere",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Color Palette",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Color Palette",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Text Overlay",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Text Overlay",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Nano Image",
              "type": "array",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Nano Image",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Trigger Workflow",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "Trigger Workflow",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update"
      },
      "credentials": {
        "airtableTokenApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "b94d41cb-9cc6-4fb0-8dd8-0c97f6032198",
      "name": "Analyze image",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        416,
        64
      ],
      "parameters": {
        "text": "You are an expert AI creative analyst. Your purpose is to analyze an input image and deconstruct its visual and thematic elements into a clear, structured report. Your output must be only the plain text report as described below. Do not include any conversational filler or explanatory text.\n\nBased on the user's provided image, generate a report with the following structure and headings:\n\nDescription\nWrite a comprehensive, single-paragraph description of the entire image. Capture the subject, setting, style, and overall feeling of the scene.\n\nStyle Analysis\n\nCore Subject: Identify the main person, object, or focus of the image.\n\nSetting: Describe the background and environment of the subject.\n\nMedium: Specify the artistic medium (e.g., Commercial product photography, 3D render, oil painting, analog film photo).\n\nLighting: Describe the quality and source of the light (e.g., golden hour, studio lighting, neon glow).\n\nMood: Describe the overall feeling or atmosphere (e.g., serene, energetic, futuristic, nostalgic).\n\nComposition: Describe the framing and camera angle (e.g., centered, eye-level, low-angle, top-down).\n\nColor Palette: List the dominant colors and overall color scheme.\n\nText Overlay\nList and describe each distinct piece of text found in the image. If there is no text, simply write \"None.\"\n\nText 1\n\nText: Identify the exact text.\n\nFont: Describe the font style.\n\nEffect: Describe any visual effects on the font. If none, write \"None.\"\n\nColor: Identify the color of the text.\n\nPlacement: Describe where the text is located (e.g., center, bottom-left).\n\n(Repeat the \"Text #\" section for every additional piece of text in the image.)",
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "GPT-4O-MINI"
        },
        "options": {},
        "resource": "image",
        "imageUrls": "={{ $json.Picture[0].url }}",
        "operation": "analyze"
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "ece7ceee-ef5a-403b-a0bd-e5ab77be62cf",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        800,
        240
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "44a27005-e034-4fa0-a071-09b1f8915bab",
      "name": "Create Media Container",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1552,
        48
      ],
      "parameters": {
        "url": "https://graph.facebook.com/v18.0/{instagram-business-account-id}/media",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"image_url\": \"\",\n  \"caption\": \"Your caption text here #hashtag\",\n  \"access_token\": \"META_ACCESS_TOKEN\"\n}",
        "sendBody": true,
        "specifyBody": "json"
      },
      "typeVersion": 4.2
    },
    {
      "id": "0a495e3b-649f-44ae-b10c-874d605db264",
      "name": "Publish Media",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1904,
        48
      ],
      "parameters": {
        "url": "https://graph.facebook.com/v18.0/{instagram-business-account-id}/media_publish",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"creation_id\": \"{{ $('Create Media').item.json.id }}\",\n  \"access_token\": \"YOUR_ACCESS_TOKEN\"\n}",
        "sendBody": true,
        "specifyBody": "json"
      },
      "typeVersion": 4.2
    },
    {
      "id": "de7de152-7cc6-4c7d-ab62-0a0b9dc7fde4",
      "name": "Get Image",
      "type": "n8n-nodes-base.airtable",
      "position": [
        208,
        64
      ],
      "parameters": {
        "id": "={{ $json.query.recordId }}",
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "appwDeP1gnsXXthZ6",
          "cachedResultUrl": "https://airtable.com/appwDeP1gnsXXthZ6",
          "cachedResultName": "Nano Image Gen IG posting"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tblCzppnhEo5uVeTq",
          "cachedResultUrl": "https://airtable.com/appwDeP1gnsXXthZ6/tblCzppnhEo5uVeTq",
          "cachedResultName": "NannoB"
        },
        "options": {}
      },
      "credentials": {
        "airtableTokenApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "a921857e-6b50-4ae9-a4a7-3eb41bd10e59",
      "name": "Get Rows",
      "type": "n8n-nodes-base.airtable",
      "position": [
        624,
        64
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "appwDeP1gnsXXthZ6",
          "cachedResultUrl": "https://airtable.com/appwDeP1gnsXXthZ6",
          "cachedResultName": "Nano Image Gen IG posting"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tblCzppnhEo5uVeTq",
          "cachedResultUrl": "https://airtable.com/appwDeP1gnsXXthZ6/tblCzppnhEo5uVeTq",
          "cachedResultName": "NannoB"
        },
        "options": {
          "fields": [
            "ID",
            "Status",
            "Setting",
            "Composition",
            "Lighting",
            "Style",
            "Atmosphere",
            "Color Palette",
            "Text Overlay",
            "Post Description"
          ]
        },
        "operation": "search",
        "filterByFormula": "{Status} = \"Create\""
      },
      "credentials": {
        "airtableTokenApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "9f2ca879-097e-4a8d-8eaa-d07deec0e00a",
      "name": "Prompt Optimization",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        800,
        64
      ],
      "parameters": {
        "text": "=Prompt guidelines for the edited image:\n\nPost Description: {{ $json['Post Description'] }}\nComposition: {{ $json.Composition }}\nLighting: {{ $json.Lighting }}\nStyle: {{ $json.Style }}\nAtmosphere: {{ $json.Atmosphere }}\nColor Palette: {{ $json['Color Palette'] }}\nText Overlay: {{ $json['Text Overlay'] }}",
        "batching": {},
        "messages": {
          "messageValues": [
            {
              "message": "=Your task is to generate an image editing prompt for AI-powered image modification. You will receive the Base Image description from your system configuration. The user will then supply editing specifications that detail their desired changes across these elements: Post Description, Composition, Lighting, Style, Atmosphere, Color Palette, and Text Overlay. Some aspects may remain unchanged from the base image while others will be modified.\nUsing these editing specifications, construct an image modification prompt that maintains consistency with the original image description's formatting and structure, while incorporating the requested changes for Instagram-optimized content.\nYour response must contain exclusively the revised image editing prompt. Include no explanatory text, introductions, or concluding statements.\nBase Image description: {{ $('Analyze image').item.json.content }}"
            }
          ]
        },
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "8c99af55-d9f1-4e88-9d15-bc57f48eb40c",
      "name": "Nano Bannana Image Generation",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueErrorOutput",
      "position": [
        1200,
        64
      ],
      "parameters": {
        "url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent",
        "method": "POST",
        "options": {
          "batching": {
            "batch": {
              "batchSize": 1,
              "batchInterval": 5000
            }
          }
        },
        "jsonBody": "={\n  \"contents\": [\n    {\n      \"parts\": [\n        {\n          \"text\": {{ JSON.stringify(\n            'Original Image Prompt: ' +\n            $('Analyze image').item.json.content+\n            ' Requested Edit Prompt: ' +\n            $json.text\n          ) }}\n        },\n        {\n          \"inline_data\": {\n            \"mime_type\": \"image/jpeg\",\n            \"data\": \"{{ $('Get Image').item.json['Nano Image'][0].url }}\"\n          }\n        }\n      ]\n    }\n  ],\n  \"generationConfig\": {\n    \"temperature\": 0.7,\n    \"maxOutputTokens\": 1000\n  }\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2,
      "alwaysOutputData": false
    }
  ],
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "4de01a8d-9a52-4bc1-85cc-346392d19f60",
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Get Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Rows": {
      "main": [
        [
          {
            "node": "Prompt Optimization",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Image": {
      "main": [
        [
          {
            "node": "Analyze image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze image": {
      "main": [
        [
          {
            "node": "Get Rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Publish Media": {
      "main": [
        [
          {
            "node": "Status Complete",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Airtable Upload": {
      "main": [
        []
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Prompt Optimization",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Prompt Optimization": {
      "main": [
        [
          {
            "node": "Nano Bannana Image Generation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Media Container": {
      "main": [
        [
          {
            "node": "Publish Media",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Nano Bannana Image Generation": {
      "main": [
        [
          {
            "node": "Airtable Upload",
            "type": "main",
            "index": 0
          },
          {
            "node": "Create Media Container",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Status Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}