{
  "name": "Personalised email",
  "nodes": [
    {
      "parameters": {
        "url": "=https://api.apify.com/v2/datasets/(THE ID OF THE AGENT RUN)/items",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            },
            {
              "name": "Authorization",
              "value": "API key"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -500,
        180
      ],
      "id": "2528d005-a93b-489d-b17c-def1f3dd9f88",
      "name": "Get data of the Run"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "446ea17f-3782-4a37-934b-b9a5ab60de0e",
              "leftValue": "={{ $json.reviewsCount }}",
              "rightValue": 30,
              "operator": {
                "type": "number",
                "operation": "gte"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2.2,
      "position": [
        -260,
        180
      ],
      "id": "4d0b9245-cd74-424c-8688-8da5f1c2bf1d",
      "name": "Filter"
    },
    {
      "parameters": {
        "url": "=http://{{ $('Get data of the Run').item.json.website.extractDomain() }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        640,
        200
      ],
      "id": "30dbf898-2640-4dfa-919d-4626caef312a",
      "name": "HTTP Request",
      "alwaysOutputData": true,
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "html": "={{ $('HTTP Request').item.json.data }}",
        "options": {}
      },
      "type": "n8n-nodes-base.markdown",
      "typeVersion": 1,
      "position": [
        820,
        200
      ],
      "id": "5fced66c-daee-479b-98c6-2efc69fea887",
      "name": "Markdown"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "82a5c856-459e-4d79-b509-8891c972dd39",
              "name": "Data",
              "value": "=### Lead (Person)\n\n**Name**:{{ $json.result.personFullName }}\n**Job Title**:{{ $('Scrape data').item.json['Lead Job Title'] }}\n\n**Summary**:{{ $('Scrape data').item.json['Lead(Person) Summary'] }}\n\n### Business Data\n{{ $('Basic LLM Chain1').item.json.text }}\n",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        2000,
        200
      ],
      "id": "77a62dd5-6b4d-4437-9390-df2ec7dc2ed2",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "amount": 2
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1320,
        200
      ],
      "id": "be7569ed-02e5-424f-81b6-f1f25097e13d",
      "name": "Wait",
      "webhookId": "86da588e-a391-4291-8cd8-14c9a2ad73e2"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.data }}",
        "messages": {
          "messageValues": [
            {
              "message": "=# Role \nYou are a helpful,intelligent web scraping assistant. \n# Task \nYour task is to take the raw Markdown of a website, and convert it into structured data.Leave nothing that's important. # Instructions - Don't add any starting filler words.\n# Note\n- Dont add any starting filler words.E.g:\"Here is the following....\""
            }
          ]
        }
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.6,
      "position": [
        1000,
        200
      ],
      "id": "5f5ea32f-c583-4b2a-9986-3a365260ade2",
      "name": "Basic LLM Chain"
    },
    {
      "parameters": {
        "model": "deepseek/deepseek-chat:free",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "typeVersion": 1,
      "position": [
        920,
        420
      ],
      "id": "d2188bf6-181f-43aa-ae81-32ae64602107",
      "name": "OpenRouter Chat Model",
      "credentials": {
        "openRouterApi": {
          "id": "IpqvXtbgyeuVXIOS",
          "name": "OpenRouter account 2"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.text }}",
        "messages": {
          "messageValues": [
            {
              "message": "=# Role \nYou are a world class lead researcher.\n# Task\nYour task is to analyze all the business data and then provide insights about the business and make sure that no stone is unturned. Leave nothing that's important.\n# Note\n- Dont add any starting filler words.E.g:\"Here is the following....\""
            }
          ]
        }
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.6,
      "position": [
        1480,
        200
      ],
      "id": "fc736ce8-4273-486e-afa2-d4b6091b43f4",
      "name": "Basic LLM Chain1"
    },
    {
      "parameters": {
        "model": "deepseek/deepseek-chat:free",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "typeVersion": 1,
      "position": [
        1480,
        420
      ],
      "id": "da43d4f7-98b1-4be5-a329-6e57062a8bdb",
      "name": "OpenRouter Chat Model1",
      "credentials": {
        "openRouterApi": {
          "id": "IpqvXtbgyeuVXIOS",
          "name": "OpenRouter account 2"
        }
      }
    },
    {
      "parameters": {
        "batchSize": 2,
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        100,
        180
      ],
      "id": "73901a59-0201-4bf0-bc82-236a5ff67036",
      "name": "Loop Over Items"
    },
    {
      "parameters": {
        "maxItems": 2
      },
      "type": "n8n-nodes-base.limit",
      "typeVersion": 1,
      "position": [
        -60,
        180
      ],
      "id": "3a5ccef4-661f-4d24-8533-477853121f55",
      "name": "Limit"
    },
    {
      "parameters": {
        "resource": "draft",
        "subject": "={{ $json.output.text.Subject }}",
        "message": "={{ $json.output.text.Message }}",
        "options": {
          "sendTo": "={{ $('Get Decision Maker Email').item.json.result.email }}"
        }
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        2500,
        200
      ],
      "id": "4de6251b-50c6-4e5c-b70b-91196d40af60",
      "name": "Gmail",
      "webhookId": "0e96847b-2a45-4d79-bc9f-944366aa6d11",
      "credentials": {
        "gmailOAuth2": {
          "id": "tB34lOJHbtIwkOQI",
          "name": "Gmail account"
        }
      }
    },
    {
      "parameters": {
        "resource": "draft",
        "operation": "getAll",
        "limit": 3,
        "options": {}
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        -560,
        640
      ],
      "id": "d17007d2-1543-4d0f-83b4-05aeff7a2dca",
      "name": "Gmail1",
      "webhookId": "77da81f3-55ac-4b6c-90a8-e33a9032ba57",
      "credentials": {
        "gmailOAuth2": {
          "id": "tB34lOJHbtIwkOQI",
          "name": "Gmail account"
        }
      }
    },
    {
      "parameters": {
        "resource": "draft",
        "operation": "delete",
        "messageId": "={{ $json.id }}"
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        -260,
        640
      ],
      "id": "ba8bb2f1-ef7f-4e31-b094-5ac6b46a7618",
      "name": "Gmail2",
      "webhookId": "03d786df-cd2b-43e2-bc8b-bd4318608bfa",
      "credentials": {
        "gmailOAuth2": {
          "id": "tB34lOJHbtIwkOQI",
          "name": "Gmail account"
        }
      },
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "sendTo": "={{ $('Wait1').item.json.headers.to.extractEmail() }}",
        "subject": "={{ $('Gmail1').item.json.subject }}",
        "emailType": "text",
        "message": "={{ $('Gmail1').item.json.text }}",
        "options": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        40,
        640
      ],
      "id": "f6d44f46-8b9b-480b-ab35-3119b3bffe84",
      "name": "Gmail3",
      "webhookId": "ad3552ac-ba10-42e9-a1d7-1f2c8a770cbd",
      "credentials": {
        "gmailOAuth2": {
          "id": "tB34lOJHbtIwkOQI",
          "name": "Gmail account"
        }
      }
    },
    {
      "parameters": {
        "amount": 1
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        -400,
        640
      ],
      "id": "d6cf0cd9-c0ca-4195-840c-68487a5ab378",
      "name": "Wait1",
      "webhookId": "c3229238-064d-4495-aea9-703c1065b375"
    },
    {
      "parameters": {
        "amount": 1
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        -120,
        640
      ],
      "id": "ec9fe85c-425f-44b1-addb-0287e42282ff",
      "name": "Wait2",
      "webhookId": "8578876b-d0ca-4bd3-a093-928a2459a71a"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.anymailfinder.com/v5.0/search/decision-maker.json",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer {Enter Your API Key here}"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "domain",
              "value": "={{ $('Loop Over Items').item.json.website.extractDomain() }}"
            },
            {
              "name": "decision_maker_category",
              "value": "ceo"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1820,
        200
      ],
      "id": "5a60f6d0-9a94-42ba-92fa-071593531971",
      "name": "Get Decision Maker Email",
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=Research:{{ $('Edit Fields').item.json.Data }}",
        "hasOutputParser": true,
        "messages": {
          "messageValues": [
            {
              "message": "=# Role \nYou are a world-class cold email specialist with insane convertion rates,excellent communication.\n# Task\nYou will be given data about a business and you have to write a cold email to that business based on our offer and the provided Research.\n# Instructions\n- Make sure to add new line where needed.\n- Don't make the Subject line like a person force selling them write like how a person writes to another friend.\n- Use the information from the research to create a subject line.For Example:\"Benjamin I thought you might be interested in this\" be creative.\n- My name is Alex.\n- After Greeting make sure to start off my taking about something related to them.\n# Offer\n- AI transformation retainer of $20k/m for 6 months to transform their whole business.\n# Notes\n- Use the information from the research to create a subject line.For Example:\"Benjamin I thought you might be interested in this\" be creative.\n- Have a casual speech and spartan tone, no frillz.\n- Email should be ~200 words."
            }
          ]
        }
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.6,
      "position": [
        2160,
        200
      ],
      "id": "e6dbf396-7240-4af7-8b4a-b19f7ff6ce28",
      "name": "Basic LLM Chain2"
    },
    {
      "parameters": {
        "model": "deepseek/deepseek-chat:free",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "typeVersion": 1,
      "position": [
        2120,
        380
      ],
      "id": "1305fa55-16ff-4ee4-a873-ae07701814a7",
      "name": "OpenRouter Chat Model2",
      "credentials": {
        "openRouterApi": {
          "id": "IpqvXtbgyeuVXIOS",
          "name": "OpenRouter account 2"
        }
      }
    },
    {
      "parameters": {
        "jsonSchemaExample": "{\n  \"text\":{\n  \"Subject\":\"Here enter the subject line and nothing else.\",\n  \"Message\":\"Here Enter the Email Body and nothing else.\"\n}\n}"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.2,
      "position": [
        2320,
        380
      ],
      "id": "5d5d6895-5cc8-447d-a4f8-0323cffd75a5",
      "name": "Structured Output Parser"
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 30
            }
          ]
        }
      },
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        -740,
        640
      ],
      "id": "d272567a-8533-4550-8909-cb688d762780",
      "name": "Schedule Trigger"
    },
    {
      "parameters": {
        "content": "## Scrape for Ideal Leads using Google\n",
        "height": 560,
        "width": 1100
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -780,
        0
      ],
      "id": "a783575f-59f1-4d07-a173-42d90fe68608",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "content": "## Get data about the company and decision maker email\n",
        "height": 560,
        "width": 1660,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        320,
        0
      ],
      "id": "c6685f80-9fcf-40e1-b3d9-87fb83665dbc",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "content": "## Make a personalised email draft with the data we scraped\n",
        "height": 560,
        "width": 680,
        "color": 6
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1980,
        0
      ],
      "id": "ed930840-9287-46c5-b042-5d977eddb345",
      "name": "Sticky Note2"
    },
    {
      "parameters": {
        "content": "## Schedule to deliver all the drafts the automation made",
        "height": 240,
        "width": 3440,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -780,
        560
      ],
      "id": "1bbc4dbe-d904-4589-9bc8-fefab43b5d81",
      "name": "Sticky Note3"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -740,
        180
      ],
      "id": "d340a6ee-429c-4a5b-bc6a-2fd808040e0d",
      "name": "When clicking ‘Test workflow’"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.perplexity.ai/chat/completions",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer "
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"model\": \"sonar\",\n  \"messages\": [\n    {\n      \"role\": \"system\",\n      \"content\": \"{{ $json.system_prompt }}\"\n    },\n    {\n      \"role\": \"user\",\n      \"content\": \"{{ $json.user_prompt }} this is the website to analyze now {{ $json['Website link'] }}\"\n    }\n  ],\n  \"max_tokens\": 10000,\n  \"temperature\": 0.2,\n  \"top_p\": 0.9,\n  \"search_domain_filter\": null,\n  \"return_images\": false,\n  \"return_related_questions\": false,\n  \"search_recency_filter\": \"month\",\n  \"top_k\": 0,\n  \"stream\": false,\n  \"presence_penalty\": 0,\n  \"frequency_penalty\": 1,\n  \"response_format\": null\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        480,
        200
      ],
      "id": "aea2f802-87ab-4d51-bfda-914da2ef3cf2",
      "name": "Company Analyst"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "677b8ed0-33b5-4d75-a281-f35745bd1ab1",
              "name": "Website link",
              "value": "={{ $json.website }}",
              "type": "string"
            },
            {
              "id": "a9a3dc74-62d8-4632-a949-afb57605725c",
              "name": "system_prompt",
              "value": "You are a company website analyst expert.",
              "type": "string"
            },
            {
              "id": "b3777c13-24e8-446c-90f5-83078040569b",
              "name": "user_prompt",
              "value": "=Act like a professional website analyst. You will be provided with a company domain name and you will search the internet for context about the company and try to find a decision maker of the company, we will need the name of the decision maker, email and title or any information about the ceo/decision maker",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        340,
        200
      ],
      "id": "45028fed-41b9-408c-addb-03ca0a381fbe",
      "name": "Set Fields"
    }
  ],
  "pinData": {},
  "connections": {
    "Get data of the Run": {
      "main": [
        [
          {
            "node": "Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Markdown",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Markdown": {
      "main": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Basic LLM Chain2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Basic LLM Chain1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter": {
      "main": [
        [
          {
            "node": "Limit",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Basic LLM Chain": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Basic LLM Chain1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Set Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Limit": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Basic LLM Chain1": {
      "main": [
        [
          {
            "node": "Get Decision Maker Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail1": {
      "main": [
        [
          {
            "node": "Wait1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail2": {
      "main": [
        [
          {
            "node": "Wait2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait1": {
      "main": [
        [
          {
            "node": "Gmail2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait2": {
      "main": [
        [
          {
            "node": "Gmail3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Decision Maker Email": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "Basic LLM Chain2",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Basic LLM Chain2",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Basic LLM Chain2": {
      "main": [
        [
          {
            "node": "Gmail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Gmail1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "Get data of the Run",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Company Analyst": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Fields": {
      "main": [
        [
          {
            "node": "Company Analyst",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "82128a1d-7a3e-415e-a308-644fcb0569b5",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "23d9eda5afd3fcfb37cffd8f5326d43351db43feedecb3c0a78b15fc9cc27c78"
  },
  "id": "ssSlmNpFahkl5OS5",
  "tags": [
    {
      "createdAt": "2025-03-23T20:50:48.289Z",
      "updatedAt": "2025-03-23T20:50:48.289Z",
      "id": "43LKxl5gRE07nsyq",
      "name": "workflow"
    }
  ]
}