{
  "id": "nwJlb1WVmjMS08l8",
  "name": "1. Generate Custom Text Content with IBM Granite 3.3 8B Instruct AI",
  "tags": [],
  "nodes": [
    {
      "id": "04102afd-8353-4b13-84e5-1f89e348da79",
      "name": "On clicking 'execute'",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -32,
        80
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "59353414-da00-4339-b4d1-734ff1499b7c",
      "name": "Set API Key",
      "type": "n8n-nodes-base.set",
      "position": [
        192,
        80
      ],
      "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": "f81edc17-b6a7-4a1a-979a-8977a56a23b7",
      "name": "Create Prediction",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        416,
        80
      ],
      "parameters": {
        "url": "https://api.replicate.com/v1/predictions",
        "method": "POST",
        "options": {
          "timeout": 60000
        },
        "jsonBody": "{\n  \"version\": \"3ff9e6e20ff1f31263bf4f36c242bd9be1acb2025122daeefe2b06e883df0996\",\n  \"input\": {\n    \"seed\": 1,\n    \"top_k\": 50,\n    \"top_p\": 0.9,\n    \"max_tokens\": 512,\n    \"temperature\": 0.6\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": "a084b94a-cca1-4ae6-9b93-0d2370dd2686",
      "name": "Extract Prediction ID",
      "type": "n8n-nodes-base.code",
      "position": [
        624,
        80
      ],
      "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": "4076b69b-6abf-4f3f-86da-08cf21029150",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        848,
        80
      ],
      "parameters": {
        "unit": "seconds",
        "amount": 2
      },
      "typeVersion": 1
    },
    {
      "id": "5f0369b0-f62f-4811-8151-96f9a879d02d",
      "name": "Check Prediction Status",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1072,
        80
      ],
      "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": "799bffa9-0479-4413-acd2-2c2606d7d087",
      "name": "Check If Complete",
      "type": "n8n-nodes-base.if",
      "position": [
        1296,
        80
      ],
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{ $json.status }}",
              "value2": "succeeded"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "f669b953-c1a7-499a-be5c-bcd3af83cfba",
      "name": "Process Result",
      "type": "n8n-nodes-base.code",
      "position": [
        1616,
        -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: 'ibm-granite/granite-3.3-8b-instruct',\\n  text_url: result.output\\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "95f3bffa-3a72-420d-8993-84b54d6a51fc",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        -608
      ],
      "parameters": {
        "color": 6,
        "width": 436,
        "height": 864,
        "content": "\n## \u2705 **\ud83d\udd35 SECTION 1: Trigger & Setup**\n\n### \u2699\ufe0f **Nodes**\n\n1\ufe0f\u20e3 **On clicking 'execute'**\n\n* **What it does:** Starts the workflow manually when you hit *Execute*.\n* **Why it\u2019s useful:** Perfect for testing text generation on-demand.\n\n2\ufe0f\u20e3 **Set API Key**\n\n* **What it does:** Stores your **Replicate API key** securely.\n* **Why it\u2019s useful:** You don\u2019t hardcode credentials into HTTP nodes \u2014 just set them once here.\n* **Beginner tip:** Replace `YOUR_REPLICATE_API_KEY` with your actual API key.\n\n---\n\n### \ud83d\udca1 **Beginner Benefit**\n\n\u2705 No coding needed to handle authentication.\n\u2705 You can reuse the same setup for other Replicate models.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "33be951a-35a4-42cf-b962-8ad5b34140ad",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        384,
        -928
      ],
      "parameters": {
        "color": 5,
        "width": 1044,
        "height": 1184,
        "content": "## \u2705 **\ud83e\udd16 SECTION 2: Model Request & Polling**\n\n### \u2699\ufe0f **Nodes**\n\n3\ufe0f\u20e3 **Create Prediction (HTTP Request)**\n\n* **What it does:** Sends a **POST request** to Replicate\u2019s API to start a text generation job.\n* **Parameters include:** `temperature`, `max_tokens`, `top_k`, `top_p`.\n* **Why it\u2019s useful:** Controls how creative or focused the AI text output will be.\n\n4\ufe0f\u20e3 **Extract Prediction ID (Code)**\n\n* **What it does:** Pulls the **prediction ID** and builds a URL for checking status.\n* **Why it\u2019s useful:** Replicate jobs run asynchronously, so you need the ID to track progress.\n\n5\ufe0f\u20e3 **Wait**\n\n* **What it does:** Pauses for **2 seconds** before checking the prediction again.\n* **Why it\u2019s useful:** Prevents spamming the API with too many requests.\n\n6\ufe0f\u20e3 **Check Prediction Status (HTTP Request)**\n\n* **What it does:** Polls the Replicate API for the **current status** (e.g., `starting`, `processing`, `succeeded`).\n* **Why it\u2019s useful:** Lets you loop until the AI finishes generating text.\n\n7\ufe0f\u20e3 **Check If Complete (IF Condition)**\n\n* **What it does:** If the status is **succeeded**, it goes to \u201cProcess Result.\u201d Otherwise, it loops back to **Wait** and retries.\n* **Why it\u2019s useful:** Creates an automated polling loop without writing complex code.\n\n---\n\n### \ud83d\udca1 **Beginner Benefit**\n\n\u2705 No need to manually refresh or check job status.\n\u2705 Workflow keeps retrying until text is ready.\n\u2705 Smart looping built-in with *Wait + If Condition*.\n\n---"
      },
      "typeVersion": 1
    },
    {
      "id": "10d7d2b3-64e5-42c8-bfda-1468887dbc8b",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1520,
        -640
      ],
      "parameters": {
        "color": 3,
        "width": 308,
        "height": 896,
        "content": "\n## \u2705 **\ud83d\udfe2 SECTION 3: Process & Output**\n\n### \u2699\ufe0f **Nodes**\n\n8\ufe0f\u20e3 **Process Result (Code)**\n\n* **What it does:** Collects the final **AI output**, status, metrics, and timestamps.\n* **Adds info like:**\n\n  * \u2705 `output` \u2192 Generated text\n  * \u2705 `model` \u2192 `ibm-granite/granite-3.3-8b-instruct`\n  * \u2705 `metrics` \u2192 Performance data\n* **Why it\u2019s useful:** Gives you a neat, structured JSON result that\u2019s easy to send to Sheets, Notion, or any app.\n\n---"
      },
      "typeVersion": 1
    },
    {
      "id": "155a5507-eb11-4762-b94e-8f966bcc17b0",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1680,
        -1184
      ],
      "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": "b2ba39e7-aac3-48a7-940b-1cfef0089997",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1680,
        -848
      ],
      "parameters": {
        "color": 4,
        "width": 1289,
        "height": 2942,
        "content": "# Generate Custom Text Content with IBM Granite 3.3 8B Instruct AI\n\nThis workflow connects to **Replicate\u2019s API** and uses the **ibm-granite/granite-3.3-8b-instruct** model to generate text.\n\n---\n\n## \u2705 **\ud83d\udd35 SECTION 1: Trigger & Setup**\n\n### \u2699\ufe0f **Nodes**\n\n1\ufe0f\u20e3 **On clicking 'execute'**\n\n* **What it does:** Starts the workflow manually when you hit *Execute*.\n* **Why it\u2019s useful:** Perfect for testing text generation on-demand.\n\n2\ufe0f\u20e3 **Set API Key**\n\n* **What it does:** Stores your **Replicate API key** securely.\n* **Why it\u2019s useful:** You don\u2019t hardcode credentials into HTTP nodes \u2014 just set them once here.\n* **Beginner tip:** Replace `YOUR_REPLICATE_API_KEY` with your actual API key.\n\n---\n\n### \ud83d\udca1 **Beginner Benefit**\n\n\u2705 No coding needed to handle authentication.\n\u2705 You can reuse the same setup for other Replicate models.\n\n---\n\n## \u2705 **\ud83e\udd16 SECTION 2: Model Request & Polling**\n\n### \u2699\ufe0f **Nodes**\n\n3\ufe0f\u20e3 **Create Prediction (HTTP Request)**\n\n* **What it does:** Sends a **POST request** to Replicate\u2019s API to start a text generation job.\n* **Parameters include:** `temperature`, `max_tokens`, `top_k`, `top_p`.\n* **Why it\u2019s useful:** Controls how creative or focused the AI text output will be.\n\n4\ufe0f\u20e3 **Extract Prediction ID (Code)**\n\n* **What it does:** Pulls the **prediction ID** and builds a URL for checking status.\n* **Why it\u2019s useful:** Replicate jobs run asynchronously, so you need the ID to track progress.\n\n5\ufe0f\u20e3 **Wait**\n\n* **What it does:** Pauses for **2 seconds** before checking the prediction again.\n* **Why it\u2019s useful:** Prevents spamming the API with too many requests.\n\n6\ufe0f\u20e3 **Check Prediction Status (HTTP Request)**\n\n* **What it does:** Polls the Replicate API for the **current status** (e.g., `starting`, `processing`, `succeeded`).\n* **Why it\u2019s useful:** Lets you loop until the AI finishes generating text.\n\n7\ufe0f\u20e3 **Check If Complete (IF Condition)**\n\n* **What it does:** If the status is **succeeded**, it goes to \u201cProcess Result.\u201d Otherwise, it loops back to **Wait** and retries.\n* **Why it\u2019s useful:** Creates an automated polling loop without writing complex code.\n\n---\n\n### \ud83d\udca1 **Beginner Benefit**\n\n\u2705 No need to manually refresh or check job status.\n\u2705 Workflow keeps retrying until text is ready.\n\u2705 Smart looping built-in with *Wait + If Condition*.\n\n---\n\n## \u2705 **\ud83d\udfe2 SECTION 3: Process & Output**\n\n### \u2699\ufe0f **Nodes**\n\n8\ufe0f\u20e3 **Process Result (Code)**\n\n* **What it does:** Collects the final **AI output**, status, metrics, and timestamps.\n* **Adds info like:**\n\n  * \u2705 `output` \u2192 Generated text\n  * \u2705 `model` \u2192 `ibm-granite/granite-3.3-8b-instruct`\n  * \u2705 `metrics` \u2192 Performance data\n* **Why it\u2019s useful:** Gives you a neat, structured JSON result that\u2019s easy to send to Sheets, Notion, or any app.\n\n---\n\n### \ud83d\udca1 **Beginner Benefit**\n\n\u2705 Ready-to-use text output.\n\u2705 Easy integration with any database or CRM.\n\u2705 Transparent metrics (when it started, when it finished, etc.).\n\n---\n\n## \u2705\u2705\u2705 **\u2728 FULL FLOW OVERVIEW**\n\n| Section                        | What happens                                                                 |\n| ------------------------------ | ---------------------------------------------------------------------------- |\n| \u26a1 **Trigger & Setup**          | Start workflow + set Replicate API key.                                      |\n| \ud83e\udd16 **Model Request & Polling** | Send request \u2192 get Prediction ID \u2192 loop until job completes.                 |\n| \ud83d\udfe2 **Process & Output**        | Extract clean AI-generated text + metadata for storage or further workflows. |\n\n---\n\n## \ud83d\udccc **How You Benefit Overall**\n\n\u2705 No coding needed \u2014 just configure your API key.\n\u2705 Reliable polling \u2014 the workflow waits until results are ready.\n\u2705 Flexible \u2014 you can extend output to Google Sheets, Slack, Notion, or email.\n\u2705 Beginner-friendly \u2014 clean separation of input, process, and output.\n\n---\n\n\u2728 With this workflow, you\u2019ve turned **Replicate\u2019s IBM Granite LLM** into a no-code text generator \u2014 running entirely inside **n8n**! \u2728\n\n---"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "callerPolicy": "workflowsFromSameOwner",
    "executionOrder": "v1"
  },
  "versionId": "92db822d-40d7-4314-96b9-fc9498fa0df3",
  "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
          }
        ]
      ]
    }
  }
}