{
  "id": "o6mSU4XZUB22R7vi",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Nimply Demo - AI Agent Caption + Draft Post",
  "tags": [],
  "nodes": [
    {
      "id": "841f4fb6-e388-4841-883a-c11e92af8a6e",
      "name": "OpenRouter Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        1152,
        768
      ],
      "parameters": {
        "model": "nvidia/nemotron-3-nano-30b-a3b:free",
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "112d36de-d9ef-40d7-b8cc-3604a9dbc1fd",
      "name": "When clicking \u2018Execute workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        432,
        560
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "ffe879b4-b7a9-4b31-8a5d-1117f07bf3a8",
      "name": "Create a post",
      "type": "@nimply/n8n-nodes-nimply.nimply",
      "position": [
        2496,
        560
      ],
      "parameters": {
        "content": "={{ $('Generate AI Caption').item.json.output }}",
        "schedule": "now",
        "channelIds": [
          "4361fc5d-e027-4a83-a24c-75b9609fc2fe"
        ],
        "additionalFields": {
          "mediaIds": "={{ $('Upload Image to Nimply').item.json.id }}",
          "contentType": "POST"
        }
      },
      "credentials": {
        "nimplyApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "6ffb923b-08d9-47f2-8eca-aa606d7202b6",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -16,
        144
      ],
      "parameters": {
        "color": 7,
        "width": 368,
        "height": 832,
        "content": "## \n\nAutomatically selects a random image, generates an AI-powered social media caption, uploads the media to Nimply, and creates a draft post.\n\n### How it works\n\n1. Start the workflow manually.\n2. Select a random image from the configured list.\n3. Generate an engaging caption with AI.\n4. Upload the image to Nimply.\n5. Find the target channel.\n6. Create a post with the generated content.\n\n### Setup\n\n- Connect your OpenRouter credentials.\n- Connect your Nimply credentials.\n- Replace the sample image URLs.\n- Update the Nimply channel.\n\n### Customize\n\n- Replace the Manual Trigger with a Schedule Trigger.\n- Use another image source such as Google Drive or S3.\n- Adjust the AI prompt, tone, hashtags, or model."
      },
      "typeVersion": 1
    },
    {
      "id": "4c62136b-a46e-42ed-9741-6ea6fde94972",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        592,
        368
      ],
      "parameters": {
        "color": 7,
        "width": 400,
        "height": 352,
        "content": "## Prepare Image\n\nStores the available image URLs and randomly selects one for the current execution. This makes every run generate a post using a different image without changing the workflow."
      },
      "typeVersion": 1
    },
    {
      "id": "fa472240-215f-45fa-b8cf-b00c4f94d4b1",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1104,
        352
      ],
      "parameters": {
        "color": 7,
        "width": 400,
        "height": 560,
        "content": "## Generate Caption with AI\n\nSends the selected image URL to the language model and generates a ready-to-publish social media caption. The prompt controls the writing style, emoji usage, word limit, and hashtag formatting."
      },
      "typeVersion": 1
    },
    {
      "id": "8b130c67-efef-4931-836a-c3849493e712",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1600,
        384
      ],
      "parameters": {
        "color": 7,
        "width": 384,
        "height": 352,
        "content": "## Upload Media\n\nUploads the selected image to Nimply and returns the media ID required when creating the social media post."
      },
      "typeVersion": 1
    },
    {
      "id": "e1350537-066f-4898-90b6-fbeb74febf3e",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2096,
        336
      ],
      "parameters": {
        "color": 7,
        "width": 576,
        "height": 480,
        "content": "## Publish to Nimply\n\nRetrieves the available Nimply channels, checks for the configured destination, and creates a draft post using the AI-generated caption together with the uploaded media."
      },
      "typeVersion": 1
    },
    {
      "id": "3df6fe8c-dc2c-4df2-87cb-6065855d0ec0",
      "name": "Prepare Image URLs",
      "type": "n8n-nodes-base.set",
      "position": [
        640,
        560
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "cfg-images",
              "name": "imageUrls",
              "type": "array",
              "value": "={{ [\n  \"https://images.unsplash.com/photo-1500530855697-b586d89ba3ee\",\n  \"https://images.unsplash.com/photo-1519389950473-47ba0277781c\",\n  \"https://images.unsplash.com/photo-1498050108023-c5249f4df085\",\n  \"https://images.unsplash.com/photo-1522202176988-66273c2fd55f\",\n  \"https://images.unsplash.com/photo-1516321318423-f06f85e504b3\"\n] }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "313d5a0c-dc0b-48b8-9592-d23644bedb71",
      "name": "Select Random Image",
      "type": "n8n-nodes-base.code",
      "position": [
        864,
        560
      ],
      "parameters": {
        "jsCode": "const cfg = items[0].json;\nconst urls = cfg.imageUrls;\n\nif (!Array.isArray(urls) || urls.length === 0) {\n  throw new Error('imageUrls array is empty or missing in Config node.');\n}\n\nconst imageUrl = urls[Math.floor(Math.random() * urls.length)];\n\nreturn [{ json: { ...cfg, imageUrl } }];"
      },
      "typeVersion": 2
    },
    {
      "id": "af10f16f-ce52-4947-b251-9473da33c4f1",
      "name": "Generate AI Caption",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1200,
        560
      ],
      "parameters": {
        "text": "=Write an engaging LinkedIn/social media caption for a photo located at this URL: {{ $json.imageUrl }}\n\nRules:\n- Use emojis\n- Maximum 120 words\n- Include exactly 3 hashtags\n- Return ONLY the caption text, no preamble or explanation",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 1.9
    },
    {
      "id": "68612a63-e8af-4a7f-887e-da462b2a179b",
      "name": "Upload Image to Nimply",
      "type": "@nimply/n8n-nodes-nimply.nimply",
      "position": [
        1744,
        560
      ],
      "parameters": {
        "url": "={{ $('Select Random Image').item.json.imageUrl }}",
        "resource": "media",
        "additionalFields": {}
      },
      "credentials": {
        "nimplyApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "9c06b7a8-6316-4029-ba7c-6354eb9a0815",
      "name": "Get Connected channels",
      "type": "@nimply/n8n-nodes-nimply.nimply",
      "position": [
        2128,
        560
      ],
      "parameters": {
        "resource": "channel"
      },
      "credentials": {
        "nimplyApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "b40edad6-8560-4eae-b927-89bbbb197781",
      "name": "If(Check Target Channel)",
      "type": "n8n-nodes-base.if",
      "position": [
        2304,
        688
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "418e302c-7b32-46e6-a3ee-fb0da4b18699",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.name }}",
              "rightValue": "=Rozar"
            }
          ]
        }
      },
      "typeVersion": 2.3
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "availableInMCP": false,
    "executionOrder": "v1"
  },
  "versionId": "7b923c57-fbd5-48bc-9dfd-b7cde30430cc",
  "nodeGroups": [],
  "connections": {
    "Create a post": {
      "main": [
        []
      ]
    },
    "Prepare Image URLs": {
      "main": [
        [
          {
            "node": "Select Random Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate AI Caption": {
      "main": [
        [
          {
            "node": "Upload Image to Nimply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Select Random Image": {
      "main": [
        [
          {
            "node": "Generate AI Caption",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Generate AI Caption",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Get Connected channels": {
      "main": [
        [
          {
            "node": "If(Check Target Channel)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload Image to Nimply": {
      "main": [
        [
          {
            "node": "Get Connected channels",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If(Check Target Channel)": {
      "main": [
        [
          {
            "node": "Create a post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Prepare Image URLs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}