Asynchronous AI Content Generation Polling Loop with Replicate - n8n Workflow

Deploy this advanced n8n workflow template to generate text control vectors using the Replicate Ilearnmate ICTS AI model. This n8n workflow implements crucial API polling logic.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Users needing to integrate specific, custom AI/ML models (like Ilearnmate ICTS) into their backend processes.

  • Developers requiring an n8n workflow that handles asynchronous API jobs and polling.

  • Automation specialists looking for examples of advanced flow control using the If n8n node and Wait n8n node.

Overview

Generating complex AI outputs often involves asynchronous processing, meaning the initial request immediately returns a Job ID, and the final result must be polled later. This specific n8n workflow provides a complete solution for handling this challenging technical requirement when using Replicate’s AI services.

This robust n8n template starts the prediction for the spuuntries/ilearnmate-icts model and then enters a controlled polling loop. It ensures that your automation only proceeds when the AI generation job is truly finished, preventing timeouts and maximizing efficiency. This is a crucial n8n workflow pattern for reliable AI integration.

How it Works

This complex n8n workflow operates in three primary stages: setup, execution initialization, and asynchronous polling.


  1. Trigger and Setup: The process begins with the 'On clicking 'execute'' n8n trigger. The subsequent 'Set API Key' n8n node securely configures your Replicate API key.

  2. Prediction Initialization: The 'Create Prediction' HTTP Request n8n node sends a POST request to the Replicate API, initiating the AI job using the specified model version. This action immediately returns a prediction ID and an initial status (usually 'starting' or 'processing').

  3. Extraction and Polling Start: The 'Extract Prediction ID' Code n8n node captures the unique prediction ID and constructs the specific polling URL needed to check the job status.

  4. Wait and Check: The workflow enters the polling loop, starting with the 'Wait' n8n node, pausing execution for 2 seconds. The 'Check Prediction Status' HTTP Request n8n node then uses the extracted URL and API key to retrieve the current status of the job.

  5. Flow Control Logic: The 'Check If Complete' If n8n node inspects the status. If the status is 'succeeded' (True branch), the workflow proceeds to process the output. If the status is anything else (False branch), the n8n workflow loops back to the 'Wait' n8n node, restarting the 2-second delay and status check. This loop continues until the job is complete.

  6. Result Processing: Once 'succeeded', the 'Process Result' Code n8n node extracts the final AI output, generation metrics, and metadata, completing the execution of this powerful n8n template.

Installation Guide

To use this n8n workflow, follow these steps:


  1. Import the n8n template: Copy the provided JSON code and import it into your n8n instance via the 'New' menu (Import from JSON).

  2. Configure API Credentials: Locate the 'Set API Key' n8n node.

* Replace the placeholder YOURREPLICATEAPIKEY in the replicateapikey assignment with your actual Replicate API key.

  1. Update Model Input (Optional): Review the 'Create Prediction' HTTP Request n8n node. You may adjust the seed or numexamplesperside parameters in the JSON body if you require different inputs for the Ilearnmate ICTS model.

  2. Execute: After configuration, run the n8n workflow using the 'Execute Workflow' button to test the n8n trigger and the polling logic.

Node Details

On clicking 'execute' (Manual Trigger n8n trigger): Initiates the entire n8n workflow manually for testing and deployment.
Set API Key (Set n8n node): Securely stores the Replicate API key as a variable, which is then dynamically inserted into the subsequent HTTP request headers.
Create Prediction (HTTP Request n8n node): Sends the initial API call to Replicate to start the AI generation job. Configured with a POST method, specifying the model version and input parameters.
Extract Prediction ID (Code n8n node): Custom JavaScript n8n node used to parse the immediate response and extract the unique id and formulate the specific prediction URL for subsequent polling requests.
Wait (Wait n8n node): Implements a crucial 2-second pause in the n8n workflow, preventing rate limit issues during the polling process.
Check Prediction Status (HTTP Request n8n node): The polling n8n node. Sends a GET request to the specific prediction URL, utilizing the Authorization header populated by the API key.
Check If Complete (If n8n node): The core control flow n8n node. Determines if the workflow should proceed to results processing (succeeded status) or loop back to the 'Wait' n8n node for further polling.
Process Result (Code n8n node): Final cleanup n8n node. Extracts and formats the important fields (output, status, metrics) from the final successful API response.

Related n8n Workflows

Free

Nodes: 7 Nodes
Updated: December 26 2025
View all
Created by

Building AI Agents and Automations | Growth Marketer | Entrepreneur | Book Author & Podcast Host If you need any help with Automations, feel free to reach out via linkedin: https://www.linkedin.com/in/yaronbeen/ And check out my Youtube channel: https://www.youtube.com/@YaronBeen/videos

Featured*