{
  "nodes": [
    {
      "id": "765f12b4-f9cd-4824-a0e2-6236b730fa49",
      "name": "Typeform Trigger",
      "type": "n8n-nodes-base.typeformTrigger",
      "position": [
        -1024,
        -448
      ],
      "parameters": {
        "formId": "tcNgdBxH"
      },
      "credentials": {},
      "typeVersion": 1.1
    },
    {
      "id": "718dcac5-5244-4b89-829a-fe155a40922c",
      "name": "Extract Domain",
      "type": "n8n-nodes-base.code",
      "position": [
        -816,
        -448
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "// Extract domain from email and convert to website URL\nconst email = $input.item.json['Work Email']; // Adjust this path based on your input data structure\n\n// Extract domain from email (part after @)\nconst domain = email.split('@')[1];\n\n// Convert to website URL (assuming https)\nconst websiteUrl = `https://${domain}`;\n\n$input.item.json.domain = domain\n$input.item.json.websiteUrl = websiteUrl\n\n// Return the result\nreturn $input.item;"
      },
      "typeVersion": 2
    },
    {
      "id": "2a4a1c0f-82cd-4855-a781-191e3d66efa5",
      "name": "Flag personal email addresses",
      "type": "n8n-nodes-base.code",
      "position": [
        -608,
        -448
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "// Flag items based on common email providers\nconst commonProviders = [\n  'gmail', 'yahoo', 'ymail', 'rocketmail',\n  'outlook', 'hotmail', 'live', 'msn',\n  'icloud', 'me', 'mac', 'aol',\n  'zoho', 'protonmail', 'mail', 'gmx'\n];\n\n// Get the domain from the input\nconst domain = $input.item.json.domain;\n\n// Extract the main domain part (remove .com, .net, etc.)\nconst domainParts = domain.split('.');\nconst mainDomain = domainParts[0].toLowerCase();\n\n// Check if it's a common provider\nconst isCommonProvider = commonProviders.includes(mainDomain);\n\n$input.item.json.isPersonalEmail = isCommonProvider;\n\nreturn $input.item;"
      },
      "typeVersion": 2
    },
    {
      "id": "9383f89d-befe-4a0e-b645-85bc97d4c6a3",
      "name": "Is Personal Email?",
      "type": "n8n-nodes-base.if",
      "position": [
        -400,
        -448
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "d7f56829-f0e9-4271-b981-0800d8faad1e",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.isPersonalEmail }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "a5a9eea3-a479-4783-b663-b0ae2ed4363f",
      "name": "Scrape the website",
      "type": "@mendable/n8n-nodes-firecrawl.firecrawl",
      "position": [
        -992,
        -32
      ],
      "parameters": {
        "url": "={{ $json.websiteUrl }}",
        "operation": "scrape",
        "requestOptions": {}
      },
      "credentials": {},
      "typeVersion": 1
    },
    {
      "id": "90494bf7-7ca2-476c-a403-dcc21a9d9da6",
      "name": "AI Sales Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -816,
        432
      ],
      "parameters": {
        "text": "=We have a new inbound lead as someone left their email address on our landing page. We already scraped their website, find it below, and I now need you to analyze this prospect and help me write an initial outreach email.\n\nFetch our own company description as well as our ICP description with the given tools to make a proper lead assessment, reason about why they might be interested in our offering, what would be a good unique angle/hook to reach out, and write an accurate personalized outreach email.\nUse Github-flavored-markdown for interest, ICP and personalization reasoning.\nThe email draft needs to be in plain text though!\nAlso fetch previous positive examples to use as a reference of what is a good analysis and email draft.\n\n<Lead Info>\nEmail: {{ $('Is Personal Email?').item.json['Work Email'] }}\nCompany: {{ $('Is Personal Email?').item.json.Company }}\nWebsite: {{ $('Is Personal Email?').item.json.websiteUrl }}\n</Lead Info>\n\n<Website Summary>\n{{ $json.message.content }}\n</Website Summary>\n\nToday is  {{ $today }}.",
        "options": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "246927ff-c4bf-4262-bde5-633c5ac58094",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -992,
        656
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {},
      "typeVersion": 1.2
    },
    {
      "id": "c165c375-74ec-4537-a525-97e9d78ae00d",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -432,
        656
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n\t\"type\": \"object\",\n    \"required\": [\n      \"industry\",\n      \"reasoningForInterestInOurProduct_markdown\",\n      \"reasoningIfIdealCustomerProfile_markdown\",\n      \"personalizationHook_markdown\",\n      \"companyBudgetAssessment\",\n      \"priorityRating\",\n      \"emailDraftSubject\",\n      \"emailDraftBodyPlainText\"\n    ],\n\t\"properties\": {\n        \"industry\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n        \"reasoningForInterestInOurProduct_markdown\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n        \"reasoningIfIdealCustomerProfile_markdown\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"reasoningPersonalizationHook_markdown\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"companyBudgetAssessment\": {\n\t\t\t\"enum\": [\"high\", \"medium\", \"low\"]\n\t\t},\n\t\t\"priorityRating\": {\n\t\t\t\"type\": \"integer\",\n            \"minimum\": 0,\n            \"maximum\": 10\n\t\t},\n\t\t\"emailDraftSubject\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"emailDraftBodyPlainText\": {\n\t\t\t\"type\": \"string\"\n\t\t}\n\t}\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "e57e25f5-3a90-45c0-8dc9-6e1a31f8537c",
      "name": "Get our company profile",
      "type": "n8n-nodes-base.googleDocsTool",
      "position": [
        -848,
        656
      ],
      "parameters": {
        "operation": "get",
        "documentURL": ""
      },
      "credentials": {},
      "typeVersion": 2
    },
    {
      "id": "952dec83-6929-452c-b6ef-2c623b776a88",
      "name": "Get our ICP description",
      "type": "n8n-nodes-base.googleDocsTool",
      "position": [
        -720,
        656
      ],
      "parameters": {
        "operation": "get",
        "documentURL": ""
      },
      "credentials": {},
      "typeVersion": 2
    },
    {
      "id": "01b6354c-c7c6-4bba-83d5-b97d96a28e15",
      "name": "Fetch approved history",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        -576,
        656
      ],
      "parameters": {
        "url": "https://api.gotohuman.com/queryResponses",
        "options": {},
        "sendQuery": true,
        "authentication": "predefinedCredentialType",
        "queryParameters": {
          "parameters": [
            {
              "name": "formId",
              "value": ""
            },
            {
              "name": "fieldIds",
              "value": "companySummary,reasoningInterest,reasoningIcp,personalizationHook,budget,priorityRating,emailToSendSubject,emailToSendBody"
            },
            {
              "name": "approvedValuesOnly",
              "value": "true"
            }
          ]
        },
        "toolDescription": "Fetches positive human-approved examples from past runs to use as orientation for your own reasoning and generating the output.",
        "nodeCredentialType": "gotoHumanApi"
      },
      "credentials": {},
      "typeVersion": 4.2
    },
    {
      "id": "ffb75d90-cff6-4db8-b9fb-6ff162e8edd2",
      "name": "Summarize website",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        -784,
        -32
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini",
          "cachedResultName": "GPT-4.1-MINI"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "content": "=We scraped a website. Please summarize the content in markdown (gfm) in 2-3 paragraphs highlighting their industry, positioning, service or product offerings and any hints on recent activities and strategic moves.\n\n<ScrapingResult>\n{{ $json.data.markdown }}\n</ScrapingResult>"
            }
          ]
        }
      },
      "credentials": {},
      "typeVersion": 1.8
    },
    {
      "id": "0373be96-43e3-419b-9d7d-31360be25113",
      "name": "Wait for Human Approval",
      "type": "@gotohuman/n8n-nodes-gotohuman.gotoHuman",
      "position": [
        272,
        496
      ],
      "parameters": {
        "fields": {
          "value": {
            "budget": "={{\n{\ndefault: $json.output.companyBudgetAssessment\n}\n}}",
            "industry": "={{ $json.output.industry }}",
            "leadEmail": "={{ $('Flag personal email addresses').item.json['Work Email'] }}",
            "leadCompany": "={{ $('Flag personal email addresses').item.json.Company }}",
            "reasoningIcp": "={{ $json.output.reasoningIfIdealCustomerProfile_markdown }}",
            "websiteLinks": "={{\n[\n{\n\"url\": $('Flag personal email addresses').item.json.websiteUrl\n}\n]\n}}",
            "companySummary": "={{ $('Summarize website').item.json.message.content }}",
            "priorityRating": "={{ $json.output.priorityRating }}",
            "emailToSendBody": "={{ $json.output.emailDraftBodyPlainText }}",
            "reasoningInterest": "={{ $json.output.reasoningForInterestInOurProduct_markdown }}",
            "emailToSendSubject": "={{ $json.output.emailDraftSubject }}",
            "personalizationHook": "={{ $json.output.reasoningPersonalizationHook_markdown }}"
          },
          "schema": [
            {
              "id": "leadEmail",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "leadEmail (textShort)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "leadCompany",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "leadCompany (textShort)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "websiteLinks",
              "type": "array",
              "display": true,
              "required": false,
              "displayName": "websiteLinks (urlLinks)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "industry",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "industry (textShort)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "companySummary",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "companySummary (text)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "reasoningInterest",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "reasoningInterest (markdown)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "reasoningIcp",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "reasoningIcp (markdown)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "personalizationHook",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "personalizationHook (markdown)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "budget",
              "type": "object",
              "display": true,
              "required": false,
              "displayName": "budget (buttonSelect)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "priorityRating",
              "type": "number",
              "display": true,
              "required": false,
              "displayName": "priorityRating (rating)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "emailToSendSubject",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "emailToSendSubject (textShort)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "emailToSendBody",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "emailToSendBody (text)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "additionalFields": {},
        "reviewTemplateID": {
          "__rl": true,
          "mode": "list"
        }
      },
      "credentials": {},
      "typeVersion": 1
    },
    {
      "id": "79fc41ac-2357-49f2-9fef-abc0dd995efc",
      "name": "Send a message",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1104,
        448
      ],
      "parameters": {
        "sendTo": "={{ $json.responseValues.leadEmail.value }}",
        "message": "={{ $json.responseValues.emailToSendBody.value }}",
        "options": {
          "appendAttribution": false
        },
        "subject": "={{ $json.responseValues.emailToSendSubject }}",
        "emailType": "text"
      },
      "credentials": {},
      "typeVersion": 2.1
    },
    {
      "id": "eacf795f-111e-4e09-9e27-cc87f08c38e4",
      "name": "Is approved?",
      "type": "n8n-nodes-base.if",
      "position": [
        880,
        448
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "4a2c31a4-ba0e-46de-a4b1-8f8488d841cd",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.response }}",
              "rightValue": "approved"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "12907535-d4bd-427f-9e3b-aba347c95d8f",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1952,
        -704
      ],
      "parameters": {
        "width": 704,
        "height": 832,
        "content": "## \ud83d\udcbc Lead Outreach Agent\nThis AI workflow helps you quickly react to new leads with an initial personalized outreach. A great start of your lead nurturing sequence to avoid loosing precious leads that could turn into paying customers.\nMost importantly it uses **gotoHuman** so you can review the AI-analysis and the AI-generated editable email draft before it is sent out in your name.\n\n### How to set up\n\n1. **Most importantly, [install the gotoHuman node](https://docs.gotohuman.com/Integrations/n8n#add-the-node) before importing this template!**\n(Just add the node to a blank canvas before importing)\n2. Set up your credentials for the different services\n3. In gotoHuman, select and create the pre-built review template \"Lead Outreach Agent\" or import the ID: `T873fI1Xli5nt3eh33Rj`\n4. Select this template in the gotoHuman node\n\n## Requirements\n\nYou need accounts for\n- gotoHuman (Human Supervision)\n- OpenAI (AI Agent)\n- Typeform (Lead Form Submissions)\n- Firecrawl (Website Scraping)\n- Gmail\n- Google Docs (Company Wiki)\n\n## How to customize\n\n- Replace the Typeform trigger with any other way you might receive or find new leads\n- Provide the _AI Sales Agent_ with more context to properly analyze the lead and create better personalized emails. Consider adding tools that allow the agent to fetch more infos about the prospect's company or personal profile, or to find out more about your specific product/service offerings and how your sales pitches look like."
      },
      "typeVersion": 1
    },
    {
      "id": "cac04e35-b084-4737-b201-0baa711bd87e",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        32,
        -736
      ],
      "parameters": {
        "width": 560,
        "height": 1040,
        "content": "![pic1](https://cdn1.gotohuman.com/public%2Fn8n-templates%2Flead-outreach%2Freview1.jpg?alt=media)\n![pic1](https://cdn1.gotohuman.com/public%2Fn8n-templates%2Flead-outreach%2Freview2.jpg?alt=media)\n![pic1](https://cdn1.gotohuman.com/public%2Fn8n-templates%2Flead-outreach%2Freview3.jpg?alt=media)"
      },
      "typeVersion": 1
    },
    {
      "id": "d8d24fc1-ab4e-4f9f-a3b1-7dbd1ce0bac9",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1136,
        -576
      ],
      "parameters": {
        "color": 7,
        "width": 992,
        "height": 368,
        "content": "## Receive lead and check email\nWe receive a new form submission incl. the email address and company name of the prospect and extract the website URL from the address. We proceed only for company email addresses."
      },
      "typeVersion": 1
    },
    {
      "id": "7f8bbfae-cfd6-4f2f-977e-6c1758e31dbd",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1136,
        -176
      ],
      "parameters": {
        "color": 7,
        "width": 992,
        "height": 368,
        "content": "## Scrape and Summarize Company Website\nWe scrape the website using Firecrawl and summarize it with OpenAI"
      },
      "typeVersion": 1
    },
    {
      "id": "72c21482-fe16-42b5-be80-fdca47f14c48",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1136,
        240
      ],
      "parameters": {
        "color": 7,
        "width": 992,
        "height": 640,
        "content": "## AI Analysis and Outreach Drafting\nOur AI agent runs an analysis based on the lead information and documents describing our own company and the defined Ideal Customer Profiles.\nIt also fetches previously approved examples from **gotoHuman** so you're effectively creating a **self-learning** agent.\nIt responds with the analysis and the drafted outreach email."
      },
      "typeVersion": 1
    },
    {
      "id": "5d671365-1e9d-457a-b56f-b50c31165e22",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        144,
        368
      ],
      "parameters": {
        "color": 7,
        "width": 336,
        "height": 336,
        "content": "![gotoHuman Logo](https://cdn1.gotohuman.com/public%2Fn8n-templates%2FgotoHuman%20full%20logo%201224px.png?alt=media)"
      },
      "typeVersion": 1
    },
    {
      "id": "58b912fb-6ed1-4c5f-a847-67e6175ce169",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        752,
        256
      ],
      "parameters": {
        "color": 7,
        "width": 560,
        "height": 544,
        "content": "## Send Human-Approved Email\nWe can now send our email including any edits made during the review and be sure that we are using high-quality content instead of AI slop."
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Is approved?": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Sales Agent": {
      "main": [
        [
          {
            "node": "Wait for Human Approval",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Domain": {
      "main": [
        [
          {
            "node": "Flag personal email addresses",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Typeform Trigger": {
      "main": [
        [
          {
            "node": "Extract Domain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Sales Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Summarize website": {
      "main": [
        [
          {
            "node": "AI Sales Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Personal Email?": {
      "main": [
        [],
        [
          {
            "node": "Scrape the website",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrape the website": {
      "main": [
        [
          {
            "node": "Summarize website",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch approved history": {
      "ai_tool": [
        [
          {
            "node": "AI Sales Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get our ICP description": {
      "ai_tool": [
        [
          {
            "node": "AI Sales Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get our company profile": {
      "ai_tool": [
        [
          {
            "node": "AI Sales Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Wait for Human Approval": {
      "main": [
        [
          {
            "node": "Is approved?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI Sales Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Flag personal email addresses": {
      "main": [
        [
          {
            "node": "Is Personal Email?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}