{
  "name": "02 · CRM Deal Won → Auto-Build Client Site",
  "nodes": [
    {
      "name": "HubSpot Deal Won",
      "type": "n8n-nodes-base.hubspotTrigger",
      "typeVersion": 1,
      "position": [
        0,
        128
      ],
      "parameters": {
        "eventsUi": {
          "eventValues": [
            {
              "name": "deal.propertyChange"
            }
          ]
        }
      },
      "webhookId": "308e5192-fc5c-4918-ac5b-491c6eae5305",
      "credentials": {
        "hubspotDeveloperApi": {
          "id": "60gSVpZzxHcPVVr2",
          "name": "HubSpot Developer account"
        }
      }
    },
    {
      "name": "Get Deal Details",
      "type": "n8n-nodes-base.hubspot",
      "typeVersion": 2.2,
      "position": [
        224,
        128
      ],
      "parameters": {
        "resource": "deal",
        "operation": "get",
        "dealId": "={{ $json.objectId }}"
      }
    },
    {
      "name": "Create Website Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3.1,
      "position": [
        448,
        128
      ],
      "parameters": {
        "promptType": "define",
        "text": "=Create a professional website for this closed deal using the Lindo tool.\n\nDeal: {{ $json.properties.dealname }}\nCompany: {{ $json.properties.company }}\nDescription: {{ $json.properties.description }}\n\nGenerate a detailed prompt and use the Lindo Create Website tool. Return the workflow_id.",
        "options": {
          "systemMessage": "You create websites for closed deals. Use the Lindo tool with a detailed prompt."
        }
      }
    },
    {
      "name": "OpenAI",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.3,
      "position": [
        464,
        352
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "Yuica5wlzDrhFTNk",
          "name": "OpenAi account"
        }
      }
    },
    {
      "name": "Lindo Create Website",
      "type": "n8n-nodes-lindo.lindoTool",
      "typeVersion": 1,
      "position": [
        592,
        352
      ],
      "parameters": {
        "prompt": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Prompt', '') }}"
      },
      "credentials": {
        "lindoApi": {
          "id": "EZiHryOUuVuxcDYQ",
          "name": "Lindo account"
        }
      }
    },
    {
      "name": "Extract Workflow ID",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        800,
        128
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a1",
              "name": "workflow_id",
              "value": "={{ $json.output.match(/workflow_id[:\\\\s]*([\\\\w-]+)/)?.[1] || $json.output }}",
              "type": "string"
            },
            {
              "id": "a2",
              "name": "deal_id",
              "value": "={{ $(\"Get Deal Details\").first().json.id }}",
              "type": "string"
            },
            {
              "id": "a3",
              "name": "company",
              "value": "={{ $(\"Get Deal Details\").first().json.properties.company }}",
              "type": "string"
            },
            {
              "id": "a4",
              "name": "contact_email",
              "value": "={{ $(\"Get Deal Details\").first().json.properties.contact_email }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "name": "Check Website Status",
      "type": "n8n-nodes-lindo.lindo",
      "typeVersion": 1,
      "position": [
        1024,
        128
      ],
      "parameters": {
        "resource": "workflow",
        "operation": "checkWebsite",
        "workflowId": "={{ $(\"Extract Workflow ID\").first().json.workflow_id }}"
      },
      "credentials": {
        "lindoApi": {
          "id": "EZiHryOUuVuxcDYQ",
          "name": "Lindo account"
        }
      }
    },
    {
      "name": "Carry Forward",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1248,
        48
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "b1",
              "name": "done",
              "value": "={{ $json.done }}",
              "type": "boolean"
            },
            {
              "id": "b2",
              "name": "status",
              "value": "={{ $json.status }}",
              "type": "string"
            },
            {
              "id": "b3",
              "name": "website_url",
              "value": "={{ $json.result?.domain || \"\" }}",
              "type": "string"
            },
            {
              "id": "b4",
              "name": "website_name",
              "value": "={{ $json.result?.website_name || \"\" }}",
              "type": "string"
            },
            {
              "id": "b5",
              "name": "deal_id",
              "value": "={{ $(\"Extract Workflow ID\").first().json.deal_id }}",
              "type": "string"
            },
            {
              "id": "b6",
              "name": "company",
              "value": "={{ $(\"Extract Workflow ID\").first().json.company }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "name": "Done?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        1472,
        48
      ],
      "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": "Update HubSpot Deal",
      "type": "n8n-nodes-base.hubspot",
      "typeVersion": 2.2,
      "position": [
        1696,
        0
      ],
      "parameters": {
        "resource": "deal",
        "operation": "update",
        "dealId": "={{ $json.deal_id }}",
        "updateFields": {
          "customPropertiesUi": {
            "customPropertiesValues": [
              {
                "property": "website_url",
                "value": "={{ $json.website_url }}"
              }
            ]
          }
        }
      }
    },
    {
      "name": "Slack: Sales Win",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.4,
      "position": [
        1920,
        0
      ],
      "parameters": {
        "resource": "message",
        "operation": "post",
        "channel": "#sales-wins",
        "text": "=🎉 Site live for {{ $(\"Carry Forward\").first().json.company }}: {{ $(\"Carry Forward\").first().json.website_url }}"
      },
      "webhookId": "36ea274d-692b-4304-85df-beb1f612ee2c",
      "credentials": {
        "slackApi": {
          "id": "sXUjiMVMx3RPbSTG",
          "name": "Slack account"
        }
      }
    },
    {
      "name": "Wait 60s",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1696,
        224
      ],
      "parameters": {
        "amount": 60
      },
      "webhookId": "695fd9fa-6d78-4ddf-a9ca-8b11af492df8"
    },
    {
      "name": "Sticky Note 50847e5f",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        960,
        400
      ],
      "parameters": {
        "content": "### 02 · CRM Deal Won → Auto-Build Client Site\n\n**How it works:** HubSpot deal closed-won trigger fires → fetches deal details → AI agent generates a tailored website via Lindo → polls build status every 60s → updates deal record with live URL → celebrates in Slack.\n\n**Setup:** Connect HubSpot trigger credentials. Ensure the deal has `company` and `description` properties. Add a custom `website_url` property to your deal pipeline. Connect Slack to #sales-wins channel.\n\n**Customisation:** Change the AI system prompt to match your brand voice. Adjust the Slack channel. Add more deal properties to enrich the website prompt. Extend with a welcome email step after the Slack notification.",
        "color": 2,
        "width": 2220,
        "height": 424
      }
    },
    {
      "name": "Sticky Note ac34c2f5",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        960,
        400
      ],
      "parameters": {
        "content": "## Trigger & Data\nHubSpot deal.propertyChange fires on close-won. Get Deal Details fetches full deal record.",
        "color": 1,
        "width": 524,
        "height": 200
      }
    },
    {
      "name": "Sticky Note 0a309e73",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        960,
        400
      ],
      "parameters": {
        "content": "## AI Website Creation\nAgent uses GPT-4o + Lindo tool to generate a complete website from deal context.",
        "color": 1,
        "width": 300,
        "height": 200
      }
    },
    {
      "name": "Sticky Note 15c4ee21",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        960,
        400
      ],
      "parameters": {
        "content": "## Status Polling Loop\nChecks build status every 60s until done, then proceeds to update CRM and notify.",
        "color": 1,
        "width": 972,
        "height": 376
      }
    }
  ],
  "connections": {
    "HubSpot Deal Won": {
      "main": [
        [
          {
            "node": "Get Deal Details",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Deal Details": {
      "main": [
        [
          {
            "node": "Create Website Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Website Agent": {
      "main": [
        [
          {
            "node": "Extract Workflow ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI": {
      "ai_languageModel": [
        [
          {
            "node": "Create Website Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Lindo Create Website": {
      "ai_tool": [
        [
          {
            "node": "Create Website Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Extract Workflow ID": {
      "main": [
        [
          {
            "node": "Check Website Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Website Status": {
      "main": [
        [
          {
            "node": "Carry Forward",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Carry Forward": {
      "main": [
        [
          {
            "node": "Done?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Done?": {
      "main": [
        [
          {
            "node": "Update HubSpot Deal",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait 60s",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update HubSpot Deal": {
      "main": [
        [
          {
            "node": "Slack: Sales Win",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 60s": {
      "main": [
        [
          {
            "node": "Check Website Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": false
  }
}