How to Set Up AI Sales Agent — Hyper-Personalized Follow-up Emails with Real-Time Company Intelligence in n8n

Your sales team is sitting on deals that go cold not because the prospect lost interest — but because the follow-up email said nothing worth responding to. "Just checking in" is not a strategy. It's n

How to Set Up AI Sales Agent — Hyper-Personalized Follow-up Emails with Real-Time Company Intelligence in n8n

Your sales team is sitting on deals that go cold not because the prospect lost interest — but because the follow-up email said nothing worth responding to. "Just checking in" is not a strategy. It's noise. What actually gets replies is relevance: showing up at the right moment with something the prospect cares about right now. This workflow automates exactly that, at scale, without requiring your reps to spend 20 minutes researching each company before drafting an email.

The Problem: Generic Follow-Ups Kill Pipeline Velocity

Most CRMs have deals rotting in the pipeline not from lack of intent, but from lack of follow-through. Sales reps get overwhelmed, prioritize hot leads, and let the middle-of-the-funnel deals go quiet. When they do follow up, the email is a template blast — same copy to a CFO at a Series B fintech as to a solo founder running an e-commerce store.

The result: low reply rates, missed context, and deals that competitors close because they showed up at the right moment with the right message. The fix isn't more reps. It's smarter automation that treats every prospect like they're the only one.

The workflow described here runs every weekday morning, finds every deal in your CRM that's gone quiet for a configurable number of days, researches what that company has been doing lately — product launches, funding rounds, press coverage, executive changes — and writes a follow-up email that references something real. It sends via Gmail and logs everything back to HubSpot. Your rep's name is on the email. The AI did the work.

How the Workflow Works: Architecture Overview

The automation runs on a daily Schedule Trigger in n8n, set to fire at a time your team chooses — typically 07:00 or 08:00 in the prospect's timezone. From there, it follows a four-stage pipeline:

Stage 1 — Deal Discovery: A HubSpot node pulls all open deals where the last activity date is older than your threshold (default: 5 days). It returns deal name, associated contact, company domain, and deal stage. You can filter by pipeline, owner, or deal stage to avoid spamming deals that are already in active negotiation.

Stage 2 — Company Intelligence: For each deal, an HTTP Request node queries Perplexity's API with a structured prompt: "What has [company name] announced or published in the last 30 days? Focus on product launches, funding, press mentions, hiring changes, or executive moves." Perplexity returns grounded, cited results from current web sources — not hallucinated summaries.

Stage 3 — Email Generation: The intelligence output gets passed to an OpenAI node (GPT-4o) with a system prompt that frames the AI as a senior sales assistant. The prompt includes the deal context, the prospect's name and role from HubSpot, the company news, and your product's core value proposition. GPT-4o writes a three-paragraph email: an opener that references the specific company news, a bridge to how your product is relevant given what they're doing, and a low-friction CTA that asks for a 15-minute call or a specific question.

Stage 4 — Send and Log: A Gmail node sends the email from your rep's address. A HubSpot node logs the activity against the deal — timestamped, with the email body stored as a note — and updates the last activity date so the deal won't trigger again tomorrow.

Step-by-Step Setup in n8n

1. Schedule Trigger node: Set the interval to "Days" and configure the time to fire each weekday morning. Enable the "Only on Weekdays" toggle. This is the entry point — every execution starts here.

2. HubSpot — Get Deals node: Use the HubSpot CRM node with operation "Get All" on the Deals object. Add a filter property: hs_last_activity_date is before {{$now.minus({days: 5}).toISO()}}. Add a second filter: dealstage is not equal to "closedwon" or "closedlost". Set limit to 50 per run to keep execution time manageable. Map the output fields: deal ID, deal name, associated company ID, associated contact ID.

3. HubSpot — Get Contact and Company nodes: Branch into two parallel nodes after the deals list. One fetches contact details (first name, last name, job title, email) by contact ID. The other fetches company details (name, domain, industry) by company ID. Use a Merge node to combine both back with the original deal data before moving to the next stage.

4. HTTP Request — Perplexity API: Method: POST. URL: https://api.perplexity.ai/chat/completions. Add your Perplexity API key as a Bearer token in the Authorization header. Body (JSON): set model to llama-3.1-sonar-large-128k-online for real-time web access. The messages array should contain a user message: "What has {{company.name}} (domain: {{company.domain}}) announced, published, or been mentioned in over the last 30 days? Include product launches, funding rounds, partnerships, press coverage, or executive changes. Be specific and cite sources." Set temperature to 0.2 for factual output.

5. OpenAI — GPT-4o node: Use the OpenAI Chat Model node with model set to gpt-4o. System prompt: "You are a senior sales assistant helping write hyper-personalized B2B follow-up emails. Write in a direct, professional tone. Never use filler phrases like 'I hope this finds you well.' Reference specific company news when available. Keep emails under 150 words. Always end with a single, specific call to action." User message: "Write a follow-up email to {{contact.firstName}} {{contact.lastName}}, {{contact.jobTitle}} at {{company.name}}. We last spoke about [deal name]. Recent company news: {{perplexityOutput}}. Our product helps [your one-line value proposition]. Write the subject line and email body."

6. Gmail — Send Email node: Use the Gmail node with operation "Send." Set "To" to the contact's email address pulled from HubSpot. Parse the GPT-4o output to split subject line from body — use a Set node with a simple regex or split on the first line break. Set "From Name" to your rep's name (store this in n8n credentials or as a workflow variable).

7. HubSpot — Log Activity node: After the email sends, use a HubSpot Engagement node to create an Email engagement against the deal. Set type to "EMAIL", timestamp to now, and include the email body as the description. This updates hs_last_activity_date automatically and keeps your CRM clean.

8. Error Handling: Wrap the Perplexity and OpenAI nodes in a Try/Catch flow. If Perplexity returns no useful news (empty or "no recent activity found"), fall back to a simpler GPT-4o prompt that generates a generic-but-personalized email based only on deal context and company industry. Never skip a deal because the research came back empty.

Benefits for Sales and Operations Teams

The immediate metric that moves is reply rate. Emails that reference a specific event — a funding round, a new product announcement, a recent press mention — consistently outperform generic follow-ups by a factor of three to five in reply rate. Your reps aren't writing better emails; the AI is, at 06:55 every morning before anyone's opened their laptop.

The second benefit is coverage. A rep with 80 open deals cannot realistically follow up on all of them every week. This workflow does it for them — every deal that goes quiet gets touched, automatically, with a relevant message. Pipeline leakage from neglected deals drops significantly in the first month.

Third: everything is logged. Every email sent, every piece of research used, every response received — it all lives in HubSpot against the deal record. Your managers can review what was sent, sales calls have context, and handoffs between reps don't start from zero.

Common Pitfalls and How to Avoid Them

Perplexity returning generic summaries: This happens when the company name is too common or the domain isn't included in the query. Always pass both company name and domain in the Perplexity prompt. If the response contains phrases like "I couldn't find specific recent news," treat it as a fallback trigger, not a valid research result.

GPT-4o hallucinating company details: If you pass Perplexity output without validation, GPT-4o may incorporate uncertain information as if it were fact. Add a validation step: use a Set node to check if the Perplexity response contains a citation URL. If no URLs are present, flag the output as unverified and instruct GPT-4o to hedge appropriately — "I saw some activity around your space recently" rather than stating specific facts as certain.

Sending to the wrong contacts: HubSpot deals can have multiple associated contacts. Add a filter to only target the primary contact or the contact with the "Decision Maker" role. Sending a personalized email to an intern while the VP goes untouched is worse than not sending at all.

Cooldown logic missing: Without a cooldown, deals that still have no activity after the first automated email will trigger again the next morning. The HubSpot activity log handles this if you've set it up correctly, but double-check that the hs_last_activity_date filter is reading the updated timestamp, not a cached value from the deal pull at the start of execution.

Email tone mismatch: GPT-4o defaults to a somewhat formal register. If your brand voice is more casual, include three to five example emails in the system prompt and tell the model to match that style. The difference between "I wanted to reach out" and "Saw you just closed a Series B — congrats" is entirely in how you prompt the model.

Rate limits on high deal volumes: If you have more than 100 stale deals, running all of them in parallel will hit OpenAI and Perplexity rate limits. Add a Wait node between iterations (set to 2–3 seconds) or use n8n's built-in concurrency controls to cap parallel executions at 5.

AI Sales Agent — Hyper-Personalized Follow-up Emails with Real-Time Company Intelligence
PRONTO PARA USAR

Ja construimos isso pra voce

Nao comece do zero. O AI Sales Agent — Hyper-Personalized Follow-up Emails with Real-Time Company Intelligence e um workflow n8n pronto para instalar — conecta suas ferramentas em minutos, sem codigo.

Instalar por $39 →