{
  "id": "7MDaHSdkdqdLQRpL",
  "name": "2. Enhance Your Workflow with 2Ndmoises_Generator AI",
  "tags": [],
  "nodes": [
    {
      "id": "a091c223-2791-499b-89e8-434bcf31e67a",
      "name": "On clicking 'execute'",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        64,
        144
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "d36b25ad-4311-4413-b0ad-4c5a46c4e188",
      "name": "Set API Key",
      "type": "n8n-nodes-base.set",
      "position": [
        288,
        144
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "64cd57c7-2224-48a6-88df-c37b310f8eb3",
              "name": "replicate_api_key",
              "type": "string",
              "value": "YOUR_REPLICATE_API_KEY"
            }
          ]
        }
      },
      "typeVersion": 3.3
    },
    {
      "id": "461d4923-1b34-4aeb-b289-bbf44e711d06",
      "name": "Create Prediction",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        512,
        144
      ],
      "parameters": {
        "url": "https://api.replicate.com/v1/predictions",
        "method": "POST",
        "options": {
          "timeout": 60000
        },
        "jsonBody": "{\n  \"version\": \"7ae928ae3e6f1614129b139f34503ff4e91e922e7487658a47ad600bca16d5b0\",\n  \"input\": {\n    \"prompt\": \"prompt value\",\n    \"seed\": 1,\n    \"width\": 1,\n    \"height\": 1,\n    \"lora_scale\": 1\n  }\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "={{ 'Bearer ' + $('Set API Key').item.json.replicate_api_key }}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "01a4bdfd-18b8-4246-9243-70a0df65d98e",
      "name": "Extract Prediction ID",
      "type": "n8n-nodes-base.code",
      "position": [
        720,
        144
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "// Extract prediction ID and initial status\\nconst prediction = $input.item.json;\\nconst predictionId = prediction.id;\\nconst initialStatus = prediction.status;\\n\\n// Store the prediction ID for polling\\nreturn {\\n  predictionId: predictionId,\\n  status: initialStatus,\\n  predictionUrl: `https://api.replicate.com/v1/predictions/${predictionId}`\\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "2ed26955-6706-4bf2-888c-73723f5959e9",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        944,
        144
      ],
      "parameters": {
        "unit": "seconds",
        "amount": 2
      },
      "typeVersion": 1
    },
    {
      "id": "1ac52ee8-c440-4811-a2b0-3615354a2955",
      "name": "Check Prediction Status",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1168,
        144
      ],
      "parameters": {
        "url": "={{ $json.predictionUrl }}",
        "options": {},
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "={{ 'Bearer ' + $('Set API Key').item.json.replicate_api_key }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "78c38493-4abd-4519-8798-c603509c4103",
      "name": "Check If Complete",
      "type": "n8n-nodes-base.if",
      "position": [
        1392,
        144
      ],
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{ $json.status }}",
              "value2": "succeeded"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "832db3de-e99d-43a8-94ee-d765d8d6b46e",
      "name": "Process Result",
      "type": "n8n-nodes-base.code",
      "position": [
        1680,
        48
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "// Process the completed prediction\\nconst result = $input.item.json;\\n\\nreturn {\\n  status: result.status,\\n  output: result.output,\\n  metrics: result.metrics,\\n  created_at: result.created_at,\\n  completed_at: result.completed_at,\\n  model: 'moicarmonas/2ndmoises_generator',\\n  other_url: result.output\\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "c9ec6eb2-ab8d-4a95-9a9b-09f5dab2ad05",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        -416
      ],
      "parameters": {
        "color": 2,
        "width": 436,
        "height": 736,
        "content": "## \ud83d\udccc Section 1: Trigger & Authentication\n\n### \u26a1 On Clicking \u2018Execute\u2019 (Manual Trigger)\n\n* Purpose: Start the workflow manually whenever you want to run it.\n* Benefit: Great for testing or running on-demand without needing automation.\n\n### \ud83d\udd11 Set API Key (Set Node)\n\n* Purpose: Stores your **Replicate API key** in the workflow.\n* How it works: Adds your API key as a variable that other nodes can reference.\n* Benefit: Keeps credentials secure and reusable.\n\n---\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "8458b03b-0d9f-4703-a8fd-0921db0e92b6",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        464,
        -528
      ],
      "parameters": {
        "color": 6,
        "width": 420,
        "height": 848,
        "content": "## \ud83d\udccc Section 2: Sending the AI Request\n\n### \ud83d\udce4 Create Prediction (HTTP Request Node)\n\n* Purpose: Sends a request to the Replicate API to start generating output with the model.\n* Input Parameters:\n\n  * **prompt** (text you provide)\n  * **seed** (for reproducibility)\n  * **width / height / lora\\_scale** (generation settings)\n* Benefit: Allows full customization of the AI\u2019s generation process.\n\n### \ud83c\udd94 Extract Prediction ID (Code Node)\n\n* Purpose: Pulls out the **Prediction ID** and **status** from the API response.\n* Why important: The ID is required to check the job\u2019s progress later.\n* Benefit: Automates polling without manual tracking.\n\n---\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "7984c90e-5a31-493f-9008-ad2dec8fdffa",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        912,
        -496
      ],
      "parameters": {
        "color": 5,
        "width": 612,
        "height": 816,
        "content": "## \ud83d\udccc Section 3: Polling & Waiting\n\n### \u23f3 Wait (Wait Node)\n\n* Purpose: Adds a short pause (2 seconds) between checks.\n* Benefit: Prevents hitting the API too quickly and avoids errors.\n\n### \ud83d\udd04 Check Prediction Status (HTTP Request Node)\n\n* Purpose: Calls Replicate again to ask if the prediction is finished.\n* Benefit: Automates progress monitoring without manual refresh.\n\n### \u2705 Check If Complete (If Node)\n\n* Purpose: Decides whether the model has finished generating.\n* Paths:\n\n  * **True** \u2192 Move on to processing the result.\n  * **False** \u2192 Go back to Wait and recheck.\n* Benefit: Ensures the workflow loops until a final output is ready.\n\n---\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "eaa16b1f-04cd-47de-858f-9edba0f06d8d",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1552,
        -448
      ],
      "parameters": {
        "color": 3,
        "width": 372,
        "height": 768,
        "content": "## \ud83d\udccc Section 4: Handling the Result\n\n### \ud83d\udce6 Process Result (Code Node)\n\n* Purpose: Cleans up the final API response and extracts:\n\n  * Status\n  * Output (generated result)\n  * Metrics\n  * Timestamps (created\\_at / completed\\_at)\n  * Model info\n* Benefit: Provides a structured, ready-to-use output for other workflows or integrations.\n\n---\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "87ad749a-a346-442e-9dcd-8285f57d659e",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1776,
        -528
      ],
      "parameters": {
        "color": 4,
        "width": 1300,
        "height": 320,
        "content": "=======================================\n            WORKFLOW ASSISTANCE\n=======================================\nFor any questions or support, please contact:\n    Yaron@nofluff.online\n\nExplore more tips and tutorials here:\n   - YouTube: https://www.youtube.com/@YaronBeen/videos\n   - LinkedIn: https://www.linkedin.com/in/yaronbeen/\n=======================================\n"
      },
      "typeVersion": 1
    },
    {
      "id": "5ec1f0de-52e9-4194-a602-f56839d0085f",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1776,
        -192
      ],
      "parameters": {
        "color": 4,
        "width": 1289,
        "height": 2510,
        "content": "# Enhance Your Workflow with 2Ndmoises_Generator AI\n\nThis n8n workflow integrates with **Replicate\u2019s `moicarmonas/2ndmoises_generator` model** to generate custom outputs based on your prompt. It handles authentication, triggers the prediction, monitors progress, and processes the final result automatically.\n\n---\n\n## \ud83d\udccc Section 1: Trigger & Authentication\n\n### \u26a1 On Clicking \u2018Execute\u2019 (Manual Trigger)\n\n* Purpose: Start the workflow manually whenever you want to run it.\n* Benefit: Great for testing or running on-demand without needing automation.\n\n### \ud83d\udd11 Set API Key (Set Node)\n\n* Purpose: Stores your **Replicate API key** in the workflow.\n* How it works: Adds your API key as a variable that other nodes can reference.\n* Benefit: Keeps credentials secure and reusable.\n\n---\n\n## \ud83d\udccc Section 2: Sending the AI Request\n\n### \ud83d\udce4 Create Prediction (HTTP Request Node)\n\n* Purpose: Sends a request to the Replicate API to start generating output with the model.\n* Input Parameters:\n\n  * **prompt** (text you provide)\n  * **seed** (for reproducibility)\n  * **width / height / lora\\_scale** (generation settings)\n* Benefit: Allows full customization of the AI\u2019s generation process.\n\n### \ud83c\udd94 Extract Prediction ID (Code Node)\n\n* Purpose: Pulls out the **Prediction ID** and **status** from the API response.\n* Why important: The ID is required to check the job\u2019s progress later.\n* Benefit: Automates polling without manual tracking.\n\n---\n\n## \ud83d\udccc Section 3: Polling & Waiting\n\n### \u23f3 Wait (Wait Node)\n\n* Purpose: Adds a short pause (2 seconds) between checks.\n* Benefit: Prevents hitting the API too quickly and avoids errors.\n\n### \ud83d\udd04 Check Prediction Status (HTTP Request Node)\n\n* Purpose: Calls Replicate again to ask if the prediction is finished.\n* Benefit: Automates progress monitoring without manual refresh.\n\n### \u2705 Check If Complete (If Node)\n\n* Purpose: Decides whether the model has finished generating.\n* Paths:\n\n  * **True** \u2192 Move on to processing the result.\n  * **False** \u2192 Go back to Wait and recheck.\n* Benefit: Ensures the workflow loops until a final output is ready.\n\n---\n\n## \ud83d\udccc Section 4: Handling the Result\n\n### \ud83d\udce6 Process Result (Code Node)\n\n* Purpose: Cleans up the final API response and extracts:\n\n  * Status\n  * Output (generated result)\n  * Metrics\n  * Timestamps (created\\_at / completed\\_at)\n  * Model info\n* Benefit: Provides a structured, ready-to-use output for other workflows or integrations.\n\n---\n\n## \ud83d\udcca Workflow Overview Table\n\n| Section           | Node Name               | Purpose                      |\n| ----------------- | ----------------------- | ---------------------------- |\n| 1. Trigger & Auth | On Clicking \u2018Execute\u2019   | Starts the workflow manually |\n|                   | Set API Key             | Stores API credentials       |\n| 2. AI Request     | Create Prediction       | Sends request to Replicate   |\n|                   | Extract Prediction ID   | Gets prediction ID + status  |\n| 3. Polling        | Wait                    | Adds delay before recheck    |\n|                   | Check Prediction Status | Monitors progress            |\n|                   | Check If Complete       | Routes based on completion   |\n| 4. Result         | Process Result          | Extracts and cleans output   |\n| Notes             | Sticky Note             | Explains setup + model info  |\n\n---\n\n## \ud83c\udfaf Key Benefits\n\n* \ud83d\udd10 **Secure authentication** using Set node for API key storage.\n* \ud83e\udd16 **Hands-free generation** \u2014 just provide a prompt, the workflow handles everything else.\n* \ud83d\udd04 **Automated polling** ensures you always get the final result without manual checking.\n* \ud83d\udce6 **Clean structured output** ready for downstream use in apps, dashboards, or notifications.\n\n---\n\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "1837efe2-a74b-46c8-8826-7442875d3d08",
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "Check Prediction Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set API Key": {
      "main": [
        [
          {
            "node": "Create Prediction",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check If Complete": {
      "main": [
        [
          {
            "node": "Process Result",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Prediction": {
      "main": [
        [
          {
            "node": "Extract Prediction ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Prediction ID": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On clicking 'execute'": {
      "main": [
        [
          {
            "node": "Set API Key",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Prediction Status": {
      "main": [
        [
          {
            "node": "Check If Complete",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}