{
  "name": "08 · White-Label Agency Onboarding",
  "nodes": [
    {
      "name": "Agency Signup Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        0,
        224
      ],
      "parameters": {
        "httpMethod": "POST",
        "path": "agency-onboard",
        "options": {}
      },
      "webhookId": "0c8a65b4-cdc5-4c56-851b-ab660479d152"
    },
    {
      "name": "Create Agency Client",
      "type": "n8n-nodes-lindo.lindo",
      "typeVersion": 1,
      "position": [
        224,
        224
      ],
      "parameters": {
        "resource": "client",
        "email": "={{ $json.body.contact_email }}"
      },
      "credentials": {
        "lindoApi": {
          "id": "EZiHryOUuVuxcDYQ",
          "name": "Lindo account"
        }
      }
    },
    {
      "name": "Allocate Partner Credits",
      "type": "n8n-nodes-lindo.lindo",
      "typeVersion": 1,
      "position": [
        448,
        224
      ],
      "parameters": {
        "resource": "credits",
        "clientId": "={{ $json.client_id }}",
        "creditType": "monthly",
        "amount": 500,
        "additionalFields": {}
      },
      "credentials": {
        "lindoApi": {
          "id": "EZiHryOUuVuxcDYQ",
          "name": "Lindo account"
        }
      }
    },
    {
      "name": "Plan 3 Portfolio Templates",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3.1,
      "position": [
        672,
        224
      ],
      "parameters": {
        "promptType": "define",
        "hasOutputParser": true,
        "text": "=Generate 3 portfolio website template prompts for a new agency partner.\n\nAgency: {{ $(\"Agency Signup Webhook\").first().json.body.agency_name }}\nIndustry Focus: {{ $(\"Agency Signup Webhook\").first().json.body.industry_focus }}\n\nCreate 3 distinct template prompts tailored to {{ $(\"Agency Signup Webhook\").first().json.body.industry_focus }} businesses. Each should be a complete, ready-to-use website that the agency can show to their clients as examples.\n\nReturn JSON: `{ \"items\": [{\"prompt\":\"...\"},{\"prompt\":\"...\"},{\"prompt\":\"...\"}] }`",
        "options": {
          "systemMessage": "Generate 3 industry-specific portfolio template prompts for an agency partner."
        }
      }
    },
    {
      "name": "OpenAI",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.3,
      "position": [
        688,
        448
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "Yuica5wlzDrhFTNk",
          "name": "OpenAi account"
        }
      }
    },
    {
      "name": "Parse 3 Prompts",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.3,
      "position": [
        816,
        448
      ],
      "parameters": {
        "jsonSchemaExample": "{ \"items\": [{\"prompt\":\"...\"},{\"prompt\":\"...\"},{\"prompt\":\"...\"}] }"
      }
    },
    {
      "name": "Persist Plan",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1024,
        224
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a1",
              "name": "items",
              "value": "={{ JSON.stringify($json.output.items) }}",
              "type": "string"
            },
            {
              "id": "a2",
              "name": "client_id",
              "value": "={{ $(\"Create Agency Client\").first().json.client_id }}",
              "type": "string"
            },
            {
              "id": "a3",
              "name": "agency_name",
              "value": "={{ $(\"Agency Signup Webhook\").first().json.body.agency_name }}",
              "type": "string"
            },
            {
              "id": "a4",
              "name": "contact_email",
              "value": "={{ $(\"Agency Signup Webhook\").first().json.body.contact_email }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "name": "Batch Create 3 Templates",
      "type": "n8n-nodes-lindo.lindo",
      "typeVersion": 1,
      "position": [
        1248,
        224
      ],
      "parameters": {
        "operation": "batchCreate",
        "items": "={{ $json.items }}"
      },
      "credentials": {
        "lindoApi": {
          "id": "EZiHryOUuVuxcDYQ",
          "name": "Lindo account"
        }
      }
    },
    {
      "name": "Persist Workflow IDs",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1472,
        224
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "b1",
              "name": "workflow_ids",
              "value": "={{ JSON.stringify(($json.items || []).filter(i => i.success).map(i => i.workflow_id)) }}",
              "type": "string"
            },
            {
              "id": "b2",
              "name": "client_id",
              "value": "={{ $(\"Persist Plan\").first().json.client_id }}",
              "type": "string"
            },
            {
              "id": "b3",
              "name": "agency_name",
              "value": "={{ $(\"Persist Plan\").first().json.agency_name }}",
              "type": "string"
            },
            {
              "id": "b4",
              "name": "contact_email",
              "value": "={{ $(\"Persist Plan\").first().json.contact_email }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "name": "Batch Check Status",
      "type": "n8n-nodes-lindo.lindo",
      "typeVersion": 1,
      "position": [
        1696,
        224
      ],
      "parameters": {
        "resource": "workflow",
        "operation": "batchCheckWebsite",
        "workflowIds": "={{ $(\"Persist Workflow IDs\").first().json.workflow_ids }}"
      },
      "credentials": {
        "lindoApi": {
          "id": "EZiHryOUuVuxcDYQ",
          "name": "Lindo account"
        }
      }
    },
    {
      "name": "Carry Forward",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1920,
        160
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "c1",
              "name": "done",
              "value": "={{ $json.done }}",
              "type": "boolean"
            },
            {
              "id": "c2",
              "name": "items",
              "value": "={{ JSON.stringify($json.items || []) }}",
              "type": "string"
            },
            {
              "id": "c3",
              "name": "client_id",
              "value": "={{ $(\"Persist Workflow IDs\").first().json.client_id }}",
              "type": "string"
            },
            {
              "id": "c4",
              "name": "agency_name",
              "value": "={{ $(\"Persist Workflow IDs\").first().json.agency_name }}",
              "type": "string"
            },
            {
              "id": "c5",
              "name": "contact_email",
              "value": "={{ $(\"Persist Workflow IDs\").first().json.contact_email }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "name": "Done?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        2144,
        160
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "d1",
              "leftValue": "={{ $json.done }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      }
    },
    {
      "name": "Generate Magic Link",
      "type": "n8n-nodes-lindo.lindo",
      "typeVersion": 1,
      "position": [
        2368,
        112
      ],
      "parameters": {
        "resource": "client",
        "operation": "generateMagicLink",
        "clientId": "={{ $json.client_id }}"
      },
      "credentials": {
        "lindoApi": {
          "id": "EZiHryOUuVuxcDYQ",
          "name": "Lindo account"
        }
      }
    },
    {
      "name": "Send Partner Welcome",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3.1,
      "position": [
        2592,
        112
      ],
      "parameters": {
        "promptType": "define",
        "text": "=Send a partner onboarding email.\n\nAgency: {{ $(\"Carry Forward\").first().json.agency_name }}\nEmail: {{ $(\"Carry Forward\").first().json.contact_email }}\nMagic Link: {{ $json.magic_link }}\nTemplates (JSON): {{ $(\"Carry Forward\").first().json.items }}\n\nWelcome them to the partner program. List the 3 starter templates with URLs. Include magic link to their dashboard. Mention 500 monthly credits. Send via Emailr.",
        "options": {
          "systemMessage": "Welcome email for new agency partner. List 3 template sites + portal link."
        }
      }
    },
    {
      "name": "OpenAI Email",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.3,
      "position": [
        2608,
        336
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "Yuica5wlzDrhFTNk",
          "name": "OpenAi account"
        }
      }
    },
    {
      "name": "Emailr",
      "type": "n8n-nodes-emailr.emailrTool",
      "typeVersion": 1,
      "position": [
        2736,
        336
      ],
      "parameters": {
        "from": "lindo.ai <partners@lindo.ai>",
        "to": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('To', '') }}",
        "subject": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Subject', '') }}",
        "html": "=",
        "text": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Text_Body', ``, 'string') }}"
      },
      "credentials": {
        "emailrApi": {
          "id": "1QJ6NqiurNRi9d4C",
          "name": "Emailr account"
        }
      }
    },
    {
      "name": "Slack: New Partner",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.4,
      "position": [
        2944,
        112
      ],
      "parameters": {
        "resource": "message",
        "operation": "post",
        "text": "=🤝 New agency partner onboarded: {{ $(\"Carry Forward\").first().json.agency_name }}. 3 templates created, 500 credits allocated.",
        "otherOptions": {}
      },
      "webhookId": "90663e7c-eb13-4a91-ac77-d73f22bbd154",
      "credentials": {
        "slackApi": {
          "id": "sXUjiMVMx3RPbSTG",
          "name": "Slack account"
        }
      }
    },
    {
      "name": "Wait 60s",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        2368,
        320
      ],
      "parameters": {
        "amount": 60
      },
      "webhookId": "655ddae2-c439-4795-9867-aae1478b703a"
    },
    {
      "name": "Sticky Note 1b45e5b4",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1472,
        496
      ],
      "parameters": {
        "content": "### 08 · White-Label Agency Onboarding\n\n**How it works:** Agency signup webhook → creates client account → allocates 500 monthly credits → AI plans 3 industry-specific portfolio templates → batch-creates all 3 → polls status → generates magic link → sends partner welcome email with template URLs → alerts team in Slack.\n\n**Setup:** POST to /webhook/agency-onboard with body: { agency_name, industry_focus, contact_email }. Connect Emailr and Slack credentials.\n\n**Customisation:** Adjust credit amount (default 500). Change number of templates. Modify industry prompt. Add CRM integration for partner tracking.",
        "color": 2,
        "width": 3244,
        "height": 408
      }
    },
    {
      "name": "Sticky Note e005b6ae",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1472,
        496
      ],
      "parameters": {
        "content": "## Client & Credits\nCreates Lindo client account and allocates 500 monthly partner credits.",
        "color": 1,
        "width": 524,
        "height": 200
      }
    },
    {
      "name": "Sticky Note 27e71838",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1472,
        496
      ],
      "parameters": {
        "content": "## AI Template Planning\nGPT-4o generates 3 distinct portfolio prompts tailored to the agency industry focus.",
        "color": 1,
        "width": 652,
        "height": 200
      }
    },
    {
      "name": "Sticky Note fa641e63",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1472,
        496
      ],
      "parameters": {
        "content": "## Batch Build & Delivery\nBatch-creates 3 templates, polls status, then sends welcome email + Slack alert.",
        "color": 1,
        "width": 1996,
        "height": 408
      }
    }
  ],
  "connections": {
    "Agency Signup Webhook": {
      "main": [
        [
          {
            "node": "Create Agency Client",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Agency Client": {
      "main": [
        [
          {
            "node": "Allocate Partner Credits",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Allocate Partner Credits": {
      "main": [
        [
          {
            "node": "Plan 3 Portfolio Templates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Plan 3 Portfolio Templates": {
      "main": [
        [
          {
            "node": "Persist Plan",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI": {
      "ai_languageModel": [
        [
          {
            "node": "Plan 3 Portfolio Templates",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Parse 3 Prompts": {
      "ai_outputParser": [
        [
          {
            "node": "Plan 3 Portfolio Templates",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Persist Plan": {
      "main": [
        [
          {
            "node": "Batch Create 3 Templates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Batch Create 3 Templates": {
      "main": [
        [
          {
            "node": "Persist Workflow IDs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Persist Workflow IDs": {
      "main": [
        [
          {
            "node": "Batch Check Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Batch Check Status": {
      "main": [
        [
          {
            "node": "Carry Forward",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Carry Forward": {
      "main": [
        [
          {
            "node": "Done?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Done?": {
      "main": [
        [
          {
            "node": "Generate Magic Link",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait 60s",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Magic Link": {
      "main": [
        [
          {
            "node": "Send Partner Welcome",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Partner Welcome": {
      "main": [
        [
          {
            "node": "Slack: New Partner",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Email": {
      "ai_languageModel": [
        [
          {
            "node": "Send Partner Welcome",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Emailr": {
      "ai_tool": [
        [
          {
            "node": "Send Partner Welcome",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Wait 60s": {
      "main": [
        [
          {
            "node": "Batch Check Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": false
  }
}