AutomationFlowsAI & RAG › Email Outreach Drafter Based on Hubspot Data

Email Outreach Drafter Based on Hubspot Data

ByMiha @miha on n8n.io

This n8n template turns a small, targeted HubSpot list into tailored outreach. It scans each contact’s recent Gmail conversations, builds a lightweight persona with AI (tone, goals, pain points, decision style), then drafts a concise sales email aligned to your offer—saved to…

Event trigger★★★★☆ complexityAI-powered17 nodesGmailHubSpotInformation ExtractorGoogle Gemini Chat
AI & RAG Trigger: Event Nodes: 17 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #8968 — we link there as the canonical source.

This workflow follows the Gmail → HubSpot recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "5eb22f9c-dfae-495f-9bf4-027f92670bc5",
      "name": "Contact Ref",
      "type": "n8n-nodes-base.noOp",
      "position": [
        960,
        480
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "d1a1b59f-b746-40ef-846f-c596564a2538",
      "name": "Get All Customer's Emails",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1456,
        480
      ],
      "parameters": {
        "limit": 20,
        "simple": false,
        "filters": {
          "q": "=from:{{ $json.email }}"
        },
        "options": {},
        "operation": "getAll"
      },
      "typeVersion": 2.1
    },
    {
      "id": "22c3f6bb-9344-4319-9eeb-4b2d3232aee3",
      "name": "Create Draft Email for Review",
      "type": "n8n-nodes-base.gmail",
      "position": [
        3024,
        624
      ],
      "parameters": {
        "message": "={{ $json.output.body }}",
        "options": {
          "sendTo": "={{ $('Variables').first().json.email }}"
        },
        "subject": "={{ $json.output.subject }}",
        "resource": "draft",
        "emailType": "html"
      },
      "typeVersion": 2.1
    },
    {
      "id": "d77dac1f-5f9c-45de-b4f3-3a0c076c67b6",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -384,
        128
      ],
      "parameters": {
        "color": 5,
        "width": 544,
        "height": 632,
        "content": "## Email Outreach Drafter with HubSpot context\n\n### How it works\n1. Click **Test workflow** to start.\n2. **HubSpot:** fetch contacts (e.g., decision makers).\n3. **Gmail:** pull each contact\u2019s recent email threads.\n4. **AI (Gemini):** build a quick persona from the correspondence.\n5. **AI:** generate a tailored sales email using the persona + your product pitch.\n6. **Gmail:** save the message as a **draft** for review.\n\n### Setup\n- [ ] Connect **HubSpot** (OAuth) and **Gmail**.\n- [ ] Add your **Gemini** API key to both Gemini nodes.\n- [ ] In **Get Contacts** set up filters to fetch relevant contacts\n- [ ] In **Variables**, set `firstname`, `lastname`, `email` mappings and edit `product_to_sell`.\n- [ ] (Optional) Adjust HubSpot filters (e.g., buying role) and Gmail fetch limits.\n\n### Customization\n- **Persona extraction:** tweak traits in **Analyse and Build Persona** (role, goals, pain points, tone, etc.).\n- **Email style:** edit the system prompt in **Generate Sales Email** (voice, length, CTA).\n- **Targeting:** refine HubSpot search criteria or switch to a list view.\n- **Review flow:** keep as drafts, or add an approval step (e.g., Slack) before sending.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "c20148a9-b8f6-4e24-9522-1df4e72842b2",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2832,
        448
      ],
      "parameters": {
        "color": 7,
        "width": 464,
        "height": 376,
        "content": "## 5. Create a draft in gmail \nSave the AI-written pitch as a draft in Gmail. Skim, tweak, send, and save hours! "
      },
      "typeVersion": 1
    },
    {
      "id": "12677fce-489c-4e08-b7fc-558533542de6",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2256,
        336
      ],
      "parameters": {
        "color": 7,
        "width": 560,
        "height": 444,
        "content": "## 4. Creat a sales email draft using the persona\nFeed the persona to AI and have it draft a tailored pitch that matches the customer\u2019s beliefs, priorities, and communication style."
      },
      "typeVersion": 1
    },
    {
      "id": "d5f35beb-ac07-4f6e-96ed-ce9395e38aee",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1696,
        336
      ],
      "parameters": {
        "color": 7,
        "width": 540,
        "height": 444,
        "content": "## 3. Build person from the emails\nFor each prospect, use AI to create a simple persona based on emails. Use the **Information Extractor** node to tell the LLM which traits to pull (eg: role, goals, pain points, decision style, tone)."
      },
      "typeVersion": 1
    },
    {
      "id": "c8c9b8c7-1c38-4142-b2fa-d5f0e69e2a5e",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1152,
        336
      ],
      "parameters": {
        "color": 7,
        "width": 520,
        "height": 372,
        "content": "## 2. Get previous email threads"
      },
      "typeVersion": 1
    },
    {
      "id": "75f939f6-954a-413f-93ed-267ade013491",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        512,
        336
      ],
      "parameters": {
        "color": 7,
        "width": 608,
        "height": 372,
        "content": "## 1. Get target customers in Hubspot\n"
      },
      "typeVersion": 1
    },
    {
      "id": "6aae27da-13ce-4535-9e80-b7ff190595ee",
      "name": "For Each Contact",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        752,
        464
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "e091dea6-9880-48fd-a7ca-7b4fadce66ce",
      "name": "Get Contacts",
      "type": "n8n-nodes-base.hubspot",
      "position": [
        560,
        464
      ],
      "parameters": {
        "operation": "search",
        "authentication": "oAuth2",
        "filterGroupsUi": {
          "filterGroupsValues": [
            {
              "filtersUi": {
                "filterValues": [
                  {
                    "value": "DECISION_MAKER",
                    "propertyName": "hs_buying_role|enumeration"
                  }
                ]
              }
            }
          ]
        },
        "additionalFields": {}
      },
      "credentials": {
        "hubspotOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": true,
      "typeVersion": 2.1
    },
    {
      "id": "3dc19bf4-167e-46fe-b483-53e752fe0ad2",
      "name": "Analyse and Build Persona",
      "type": "@n8n/n8n-nodes-langchain.informationExtractor",
      "position": [
        1808,
        480
      ],
      "parameters": {
        "text": "={{\n$input.all()\n  .map(item => `subject: ${item.json.subject}\ndate: ${$json.headers.date}\nmessage: ${item.json.text.substr(0, item.json.text.indexOf('> wrote:') ?? item.json.text.length).replace(/^On[\\w\\W]+$/im, '')}`\n  ).join('\\n---\\n')\n}}",
        "options": {
          "systemPromptTemplate": "=Your task is to build a persona of a customer or potential customer so that we may better serve them for our business. Analyse the recent correspondence of the user, {{ $('Variables').item.json.email }}, and extract the required attributes."
        },
        "attributes": {
          "attributes": [
            {
              "name": "decision_making_style",
              "required": true,
              "description": "=Analytical vs. Intuitive: Do they rely on data or gut feelings?\n\nRisk Appetite: Conservative, calculated risk-YOUR_OPENAI_KEY_HERE, or bold?\n\nSpeed of Decision-Making: Quick and assertive or deliberate and methodical?"
            },
            {
              "name": " communication_preferences",
              "required": true,
              "description": "=Preferred Medium: Email, phone calls, in-person meetings, messaging apps?\n\nDetail Orientation: High-level summaries or deep-dive explanations?\n\nTone & Formality: Casual vs. professional, direct vs. diplomatic?"
            },
            {
              "name": "pain_points_challenges",
              "required": true,
              "description": "=Current Business Challenges: What problems are they actively trying to solve?\n\nIndustry Pressures: Competitive landscape, economic concerns, regulatory issues?\n\nOperational Bottlenecks: Efficiency, team structure, technology gaps?"
            },
            {
              "name": "professional_goals_motivations",
              "required": true,
              "description": "=Personal Career Goals: Promotion, recognition, financial growth, legacy-building?\n\nBusiness Priorities: Revenue growth, innovation, market expansion, cost reduction?\n\nKey Performance Indicators (KPIs): How do they measure success?"
            },
            {
              "name": "work_style_preferences",
              "required": true,
              "description": "=Collaboration vs. Independence: Do they prefer teamwork or autonomy?\n\nLevel of Involvement: Hands-on or delegate-and-review?\n\nResponse Time Expectation: Do they expect immediate follow-ups or are they flexible?"
            },
            {
              "name": "personality_behavioral_traits",
              "required": true,
              "description": "=Big Five Traits: Are they open to new ideas, structured, agreeable, extroverted?\n\nConflict Resolution Style: Do they avoid, confront, or negotiate?\n\nTrust-Building Factors: Do they value reliability, transparency, exclusivity?"
            },
            {
              "name": " buying_investment_behavior",
              "required": true,
              "description": "=Budget Sensitivity: Price-conscious or value-focused?\n\nBrand Loyalty vs. Openness: Do they stick with familiar providers or explore new options?\n\nDecision Influencers: Do they rely on peers, market research, gut instinct?"
            },
            {
              "name": "preferred_business_culture_ethics",
              "required": true,
              "description": "=Formality vs. Informality: Corporate structure vs. entrepreneurial mindset?\n\nCore Values: Integrity, innovation, customer-first, sustainability?\n\nCultural Sensitivity: Are there cultural nuances to be aware of in their decision-making?"
            },
            {
              "name": "industry_competitive_awareness",
              "required": true,
              "description": "=Market Trends Interest: Do they actively track industry shifts?\n\nCompetitor Awareness: Are they reactive to competitors, or focused on internal growth?\n\nTech Adoption: Do they embrace innovation, or are they slow adopters?"
            }
          ]
        }
      },
      "executeOnce": true,
      "typeVersion": 1
    },
    {
      "id": "a692062b-c142-47de-997e-10ae6c5420ee",
      "name": "Generate Sales Email",
      "type": "@n8n/n8n-nodes-langchain.informationExtractor",
      "position": [
        2416,
        480
      ],
      "parameters": {
        "text": "=# Profile of {{ $('Variables').first().json.firstname }} {{ $('Variables').first().json.lastname }}\n{{ Object.keys($json.output).map(key => `## ${key}\\n${$json.output[key]}`).join('\\n') }}",
        "options": {
          "systemPromptTemplate": "=You are a sales representative drafting an email to close a potential customer on the following product: <product>{{ $('Variables').first().json.product_to_sell }}</product>\n\nUse the provided profile to draft the a suitable email which reflects similar communication style and addresses their values, ultimately convinces the customer to inquire about and/or buy this product. Provide only the subject and body of the message as this text will go into a template. Omit the subject and signature."
        },
        "attributes": {
          "attributes": [
            {
              "name": "subject",
              "required": true,
              "description": "the subject of the message"
            },
            {
              "name": "body",
              "required": true,
              "description": "the body of the message with html styling"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "5b325d06-e4e9-4a50-a260-ce733d57f007",
      "name": "Google Gemini Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        2496,
        640
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.0-flash"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "b6cb19c3-db32-4c56-8a61-8eac39c7cae0",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1888,
        640
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.0-flash"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "018a8972-546c-43cc-986a-b72fa9d0d4d9",
      "name": "Variables",
      "type": "n8n-nodes-base.set",
      "position": [
        1248,
        480
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a6c47778-33f4-46a3-a86a-fd1e75930d93",
              "name": "firstname",
              "type": "string",
              "value": "={{ $json.properties.firstname }}"
            },
            {
              "id": "0e50b2bc-4bea-4fd0-95c0-46a87da69c19",
              "name": "lastname",
              "type": "string",
              "value": "={{ $json.properties.lastname }}"
            },
            {
              "id": "ee15f298-77f6-4c4a-b03b-c2cf9a53bdc2",
              "name": "email",
              "type": "string",
              "value": "={{ $json.properties.email }}"
            },
            {
              "id": "98a718f5-4372-4282-8a9a-46f2af39677a",
              "name": "product_to_sell",
              "type": "string",
              "value": "=AI partnerships: a consulting package of AI development and services. We help customers find a strong foothold on AI initiatives bringing them to life cost effectively and always with results."
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "d8dab6ac-acfe-452f-921d-55d27060ed6a",
      "name": "When clicking 'Execute workflow'",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        304,
        464
      ],
      "parameters": {},
      "typeVersion": 1
    }
  ],
  "connections": {
    "Variables": {
      "main": [
        [
          {
            "node": "Get All Customer's Emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Contact Ref": {
      "main": [
        [
          {
            "node": "Variables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Contacts": {
      "main": [
        [
          {
            "node": "For Each Contact",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "For Each Contact": {
      "main": [
        [],
        [
          {
            "node": "Contact Ref",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Sales Email": {
      "main": [
        [
          {
            "node": "Create Draft Email for Review",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Analyse and Build Persona",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Analyse and Build Persona": {
      "main": [
        [
          {
            "node": "Generate Sales Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get All Customer's Emails": {
      "main": [
        [
          {
            "node": "Analyse and Build Persona",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Generate Sales Email",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Create Draft Email for Review": {
      "main": [
        [
          {
            "node": "For Each Contact",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking 'Execute workflow'": {
      "main": [
        [
          {
            "node": "Get Contacts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This n8n template turns a small, targeted HubSpot list into tailored outreach. It scans each contact’s recent Gmail conversations, builds a lightweight persona with AI (tone, goals, pain points, decision style), then drafts a concise sales email aligned to your offer—saved to…

Source: https://n8n.io/workflows/8968/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

By now, it should be common knowledge that we can leverage AI to generate unique emails but in a way, they can remain generic as the AI lacks the customer context to be truly personalised. One way to

Google Gemini Chat, Gmail, Information Extractor +1
AI & RAG

Manually adding important term dates to your calendar by hand? Stop! Automate it with this simple AI/LLM-powered document understanding and extraction template. This cool use-case can be applied to ma

HTTP Request, Information Extractor, Google Gemini Chat +1
AI & RAG

Stop wasting time on video editing! This template is designed for content creators and marketers who need a fast, scalable way to convert simple text scripts into polished, shareable AI-generated vide

Information Extractor, Google Gemini Chat, Form Trigger +2
AI & RAG

Customer Feedback Loop Analyzer. Uses formTrigger, lmChatGoogleGemini, gmail, slack. Event-driven trigger; 11 nodes.

Form Trigger, Google Gemini Chat, Gmail +4
AI & RAG

Who is this for? Event organizers, conference planners, and marketing teams fighting registration drop-off who want 4-field forms with LinkedIn-level attendee intelligence. What problem is this workfl

Data Table, HubSpot, Email Send +4