{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "7b815687-00ea-4dc8-a97c-503ba6e90361",
      "name": "Start Workflow",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        240,
        4016
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "27c7bcf8-92f6-4e9e-8341-392b41e45728",
      "name": "Set Image Prompt",
      "type": "n8n-nodes-base.set",
      "position": [
        416,
        4016
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "5f36bc2b-9acb-4159-b9c3-98a6f9650787",
              "name": "Prompt",
              "type": "string",
              "value": "Make an image of an attractive person standing in new york city"
            },
            {
              "id": "e5823995-d822-4f59-b580-c9efaabc465c",
              "name": "Name",
              "type": "string",
              "value": "woman-nyc"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "dca87162-622b-4c42-8642-d60501673a79",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -208,
        3088
      ],
      "parameters": {
        "width": 1600,
        "height": 100,
        "content": "**Need more help?**  \nWebsite: https://ynteractive.com  \nEmail: robert@ynteractive.com"
      },
      "typeVersion": 1
    },
    {
      "id": "899e1ec5-b857-4863-a8d5-a07b8065df8d",
      "name": "Loop Over Items1",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        496,
        4256
      ],
      "parameters": {
        "options": {
          "reset": false
        }
      },
      "typeVersion": 3
    },
    {
      "id": "27472c1e-6c24-491a-b759-c6d544fbdd6c",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -208,
        3232
      ],
      "parameters": {
        "color": 3,
        "width": 1072,
        "height": 1480,
        "content": "## Step-by-Step Implementation Guide\n\n### Prerequisites\nBefore setting up this workflow, you'll need:\n\n1. **n8n instance** (cloud or self-hosted)\n2. **OpenAI API account** with DALL-E access\n3. **GotoHuman account** for review management\n\n### Step 1: Set Up OpenAI API Credentials\n\n1. Go to [OpenAI's website](https://platform.openai.com/api-keys)\n2. Create an account or sign in\n3. Navigate to \"API Keys\" in your dashboard\n4. Click \"Create new secret key\"\n5. Copy the API key and save it securely\n6. In n8n, go to **Credentials** \u2192 **Add Credential** \u2192 **OpenAI API**\n7. Paste your API key and save as \"OpenAI account\"\n\n### Step 2: Set Up GotoHuman Credentials\n\n1. Visit [GotoHuman](https://gotohuman.com/) and create an account\n2. Navigate to your API settings/dashboard\n3. Generate an API key\n4. In n8n, go to **Credentials** \u2192 **Add Credential** \u2192 **GotoHuman API**\n5. Enter your API credentials and save as \"gotoHuman account\"\n\n### Step 3: Configure the Review Template\n\n1. In your GotoHuman dashboard, create a new review template with ID: `3473LaRDbdf03sd6uzYG`\n2. Set up the template with:\n   - **Image field**: For displaying the generated image\n   - **Prompt field**: For showing the original prompt\n   - **Review options**: Approve/Reject buttons\n3. Configure reviewers and notification settings\n\n### Step 4: Import and Configure the Workflow\n\n1. Copy the provided workflow JSON\n2. In n8n, click **Import from File** or **Import from Clipboard**\n3. Paste the workflow JSON\n4. The workflow will automatically create the following nodes:\n\n#### Node Configuration Details:\n\n##### Start Workflow (Manual Trigger)\n- No configuration needed\n- Used to manually start the workflow\n\n##### Set Image Prompt\n- **Prompt**: \"Make an image of an attractive person standing in new york city\"\n- **Name**: \"woman-nyc\"\n- *Customize these values for your specific use case*\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "dd0abc01-e2a4-4892-9b76-547b0573d6c8",
      "name": "Initial Review",
      "type": "@gotohuman/n8n-nodes-gotohuman.gotoHuman",
      "position": [
        704,
        4576
      ],
      "parameters": {
        "fields": {
          "value": {
            "Image": "={{\n  JSON.stringify([\n    {\n      url: $json.url,\n      label: 'Generated Image'\n    }\n  ])\n}}\n",
            "Prompt": "={{ $('Set Image Prompt').item.json.Prompt }}"
          },
          "schema": [
            {
              "id": "Image",
              "type": "array",
              "display": true,
              "required": false,
              "displayName": "Image (imageGrid)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Prompt",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Prompt (text)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "additionalFields": {},
        "reviewTemplateID": {
          "__rl": true,
          "mode": "list",
          "value": "3473LaRDbdf03sd6uzYG",
          "cachedResultName": "Image Review (3473LaRDbdf03sd6uzYG)"
        }
      },
      "credentials": {
        "gotoHumanApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "520b4b3c-0ddc-4349-8af9-66103ace3701",
      "name": "Initial Image Generation",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        624,
        4384
      ],
      "parameters": {
        "model": "dall-e-2",
        "prompt": "={{ $json.Prompt }}",
        "options": {
          "returnImageUrls": true
        },
        "resource": "image"
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "8ef0f626-05d2-4867-be56-b3b2ea045b01",
      "name": "Second Image Generation",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        1056,
        4464
      ],
      "parameters": {
        "model": "dall-e-2",
        "prompt": "={{ $('Initial Review').item.json.responseValues.Prompt.value }}",
        "options": {
          "returnImageUrls": true
        },
        "resource": "image"
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "2761ec7f-7eea-455a-9fdb-edc36028a9d8",
      "name": "Second Review",
      "type": "@gotohuman/n8n-nodes-gotohuman.gotoHuman",
      "position": [
        1248,
        4480
      ],
      "parameters": {
        "fields": {
          "value": {
            "Image": "={{\n  JSON.stringify([\n    {\n      url: $json.url,\n      label: 'Generated Image'\n    }\n  ])\n}}\n",
            "Prompt": "={{ $('Set Image Prompt').item.json.Prompt }}"
          },
          "schema": [
            {
              "id": "Image",
              "type": "array",
              "display": true,
              "required": false,
              "displayName": "Image (imageGrid)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Prompt",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Prompt (text)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "additionalFields": {},
        "reviewTemplateID": {
          "__rl": true,
          "mode": "list",
          "value": "3473LaRDbdf03sd6uzYG",
          "cachedResultName": "Image Review (3473LaRDbdf03sd6uzYG)"
        }
      },
      "credentials": {
        "gotoHumanApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "f2860033-4ce8-4ca2-8a96-b2040ad0ed3d",
      "name": "If rejected",
      "type": "n8n-nodes-base.if",
      "position": [
        928,
        4240
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "159a5db4-20d3-4c84-86bb-a405de6d9ab4",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.response }}",
              "rightValue": "rejected"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "2220b8db-85df-4ec4-a1e5-50d9e20ca25b",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        896,
        3232
      ],
      "parameters": {
        "color": 5,
        "width": 496,
        "height": 1480,
        "content": "##### Loop Over Items1 (Split in Batches)\n- Processes items in batches\n- No additional configuration needed\n\n##### Initial Image Generation (OpenAI)\n- **Resource**: Image\n- **Model**: DALL-E 2\n- **Prompt**: Uses the prompt from \"Set Image Prompt\"\n- **Credentials**: Select your \"OpenAI account\"\n\n##### Initial Review (GotoHuman)\n- **Review Template ID**: 3473LaRDbdf03sd6uzYG\n- **Fields**: Maps image URL and prompt to review form\n- **Credentials**: Select your \"gotoHuman account\"\n\n##### If Rejected (Conditional Logic)\n- Checks if review response equals \"rejected\"\n- Routes to regeneration if rejected\n\n##### Second Image Generation (OpenAI)\n- Same configuration as initial generation\n- Uses updated prompt from review feedback\n\n##### Second Review (GotoHuman)\n- Same configuration as initial review\n- Final quality check\n\n### Step 5: Customize for Your Use Case\n\n1. **Update Image Prompts**: Modify the \"Set Image Prompt\" node with your specific requirements\n2. **Adjust Review Criteria**: Update your GotoHuman template with specific quality guidelines\n3. **Configure Notifications**: Set up email or Slack notifications in GotoHuman for reviewers\n\n### Step 6: Test the Workflow\n\n1. Click **Execute Workflow** on the manual trigger\n2. Monitor the execution flow\n3. Check that images are generated and sent for review\n4. Verify the conditional logic works when images are rejected\n5. Confirm final approved images are properly handled\n"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "If rejected": {
      "main": [
        [],
        [
          {
            "node": "Second Image Generation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Initial Review": {
      "main": [
        [
          {
            "node": "If rejected",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start Workflow": {
      "main": [
        [
          {
            "node": "Set Image Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items1": {
      "main": [
        [],
        [
          {
            "node": "Initial Image Generation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Image Prompt": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Second Image Generation": {
      "main": [
        [
          {
            "node": "Second Review",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Initial Image Generation": {
      "main": [
        [
          {
            "node": "Initial Review",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}