← All posts
How-ToAugust 21, 2026 · 5 min

how to build cold outreach ai agents with n8n and Perplexity API

You can spin up a fully autonomous cold-outreach pipeline in under two hours by connecting n8n (a visual workflow engine) to the Perplexity API (a fast, knowledge-aware LLM). The resulting agents continuously scrape target lists, craft hyper-personalised messages, and fire them off without human touch, giving you a reproducible lead-generation engine that runs on its own schedule.

cold outreach automation is the systematic use of software to discover, contact, and follow up with prospects who have never interacted with you before.

Below you'll learn exactly how to build cold outreach AI agents that source leads, write emails, and track results - all without writing a single line of server code.


What you need

ToolPlan / PriceRole
n8n Cloud (or self-hosted Docker)Free tier: 2 000 workflow executions / month · Paid: $20 / month for 20 000 executions (see <https://n8n.io/pricing>)Orchestrates the whole pipeline - scheduling, branching, API calls, and logging
Perplexity APIFree tier: 5 000 tokens / month · Pay-as-you-go: $0.002 / token (check the latest pricing at <https://docs.perplexity.ai>)Generates prospect lists and writes personalized outreach copy
Gmail / SMTP accountFree (Gmail) or any paid SMTP providerSends the outbound emails
Google Sheets (optional)Free Google accountStores lead status and reply metrics
Docker (if self-hosting n8n)Free (download from Docker Hub)Runs n8n on your own server
What you need — how to build cold outreach ai agents
What you need — how to build cold outreach ai agents

Estimated build time: 90 minutes for a cloud-only setup, 120 minutes if you provision a self-hosted Docker instance (includes pulling the image and opening ports).


Step-by-step build

1. Spin up n8n

Cloud route (recommended for speed): - Sign up at <https://n8n.io> and select the Free plan. - Create a new workspace called Cold Outreach AI.

Self-hosted route:

bash
docker run -d \
 --name n8n \
 -p 5678:5678 \
 -e N8N_BASIC_AUTH_ACTIVE=true \
 -e N8N_BASIC_AUTH_USER=admin \
 -e N8N_BASIC_AUTH_PASSWORD=CHANGE_ME \
 n8nio/n8n:latest

Tip: The environment variables above enable basic auth; replace CHANGE_ME with a strong password. After the container starts, open http://localhost:5678 and log in.

2. Grab a Perplexity API key

  • Register at <https://docs.perplexity.ai> and create an API key.
  • Store the key in n8n's Credentials store: Perplexity API → API Key. This keeps the secret out of your workflow JSON.

3. Create a scheduled trigger

  1. In the n8n editor, click + → Trigger → Cron.
  2. Set it to run daily at 09:00 UTC (adjust for your time zone).
  3. Name the node Daily Lead Generator.

4. Query Perplexity for a prospect list

We'll ask Perplexity to return 10-15 companies that match a niche. Add an HTTP Request node:

  • Method: POST
  • URL: https://api.perplexity.ai/v1/chat/completions
  • Authentication: Choose the Perplexity API credential you saved.
  • Headers: Content-Type: application/json
  • Body (JSON):
json
{
 "model": "pplx-70b-online",
 "messages": [
 {
 "role": "system",
 "content": "You are a lead-generation assistant."
 },
 {
 "role": "user",
 "content": "Give me 12 SaaS companies in Europe that have raised > $5M in the last 12 months and have less than 50 employees. Return JSON with fields: name, domain, founder, latest_funding_amount."
 }
 ],
 "temperature": 0.2,
 "max_tokens": 800
}

What this does: Calls the Perplexity LLM and asks it to produce a machine-readable list of target companies.

When the node runs, you should see a response like:

json
{
 "choices": [
 {
 "message": {
 "content": "[{\"name\":\"Acme Labs\",\"domain\":\"acmelabs.io\",\"founder\":\"Laura Müller\",\"latest_funding_amount\":\"$7M\"}, ...]"
 }
 }
 ]
}

5. Parse the JSON into n8n items

Add a Set node named Parse Leads:

  • Turn the string {{$json["choices"][0]["message"]["content"]}} into an object using the built-in JSON.parse() expression:
javascript
{{ JSON.parse($json["choices"][0].message.content) }}
  • This node will output one item per prospect, each with name, domain, founder, and latest_funding_amount.

6. Enrich each lead (optional)

If you need more data (e.g., LinkedIn URL), attach another HTTP Request node that hits a public enrichment API such as Clearbit (free tier 100 requests/day). Map the domain field into the query string.

7. Generate a personalised email

Add another HTTP Request node (Write Email) that re-uses Perplexity for copy:

  • Body (JSON):
json
{
 "model": "pplx-70b-online",
 "messages": [
 {
 "role": "system",
 "content": "You are a witty B2B sales copywriter."
 },
 {
 "role": "user",
 "content": "Write a short cold email (max 120 words) to {{ $json.founder }} of {{ $json.name }}. Mention their recent ${{ $json.latest_funding_amount }} raise and propose a 15-minute demo of our AI-driven analytics platform."
 }
 ],
 "temperature": 0.5,
 "max_tokens": 250
}
  • Output: The content field will contain the email body.

8. Send the email

Use the Gmail node (or SMTP if you prefer a corporate relay):

  • From: sales@yourcompany.com
  • To: {{ $json.founder }} <{{ $json.domain }}> (you may need to look up the founder's email via a separate enrichment step).
  • Subject: Congrats on your ${{ $json.latest_funding_amount }} raise, {{ $json.founder }}!
  • Body: {{ $json["choices"][0].message.content }} (the email text from the previous node).

Enable 'Throw On Error' so any failed send is caught by the error branch later.

9. Log the outreach

Add a Google Sheets node (Log to Sheet) to append a row with:

TimestampCompanyFounderDomainFundingEmail Sent

Map the fields directly from the current item. This gives you a single source of truth for reporting.

10. Add error handling and retry logic

  • Connect the Error output of the Gmail node to a Function node that marks the row in the sheet as "Failed - retry later".
  • Use an IF node to check {{ $json["choices"][0].message.content }} length; if it's "null" or shorter than 30 characters, route the item back to Write Email with a higher temperature (0.8) to encourage more creative output.

11. Activate the workflow

Hit Activate in the top right. The Cron trigger will now fire each day, pulling fresh leads, generating copy, sending emails, and logging everything automatically.


!Step-by-step build — how to build cold outreach ai agents ## Where this breaks

Most failures stem from external-API limits, not n8n itself.

Failure modeSymptomFix
Perplexity rate-limit (free tier)"429 Too Many Requests" error after ~5 calls/secondAdd a Delay node of 2 seconds before each HTTP Request; upgrade to a paid plan if you need higher throughput
Token exhaustionResponse is cut off, email body is incompleteIncrease max_tokens to 800 (still under the 1 024 token max for the 70B model) or batch leads fewer at a time
Missing founder emailGmail node throws "Invalid recipient address"Insert an enrichment step (Clearbit or Hunter) and fallback to a generic sales@{{domain}} address
Gmail quota (5000/day for free accounts)Emails stop after a few hundred sendsSwitch to a dedicated SMTP relay (e.g., SendGrid) or request a higher quota from Google Workspace
n8n execution cap (free tier)"Execution limit reached" in the UIUpgrade to the $20 / month plan (20 000 executions/month) or self-host the Docker container, which has no built-in cap
JSON parsing errors"Unexpected token" in the Parse Leads nodeEnsure Perplexity returns a valid JSON string; wrap the prompt with "Return ONLY a JSON array." and double-check quoting

Proactive monitoring: Add a Telegram node that notifies you on any error branch, so you can intervene before the pipeline stalls.


For a deeper technical reference, see n8n's documentation.

FAQ

How many leads can I safely process per day on the free tiers?

Perplexity's free tier allows around 5 000 tokens per month, which equates to roughly 10-12 full-prompt executions daily (each execution consumes ~400-500 tokens). n8n's free tier gives you 2 000 workflow executions per month, so a daily batch of 12 leads stays well within both limits.

Can I replace Perplexity with another LLM (e.g., OpenAI) without changing the workflow?

Yes. Swap the HTTP Request node's URL to https://api.openai.com/v1/chat/completions, update the Authentication credential to an OpenAI API key, and change the payload's model field (e.g., "gpt-4o"). The JSON structure is identical, so downstream nodes remain unchanged.

What if a prospect unsubscribes or replies "stop emailing me"?

Add an IMAP Email node that watches your inbox for the phrase "unsubscribe". When it fires, use a Set node to mark the domain as "Do Not Contact" in your Google Sheet, and filter it out with an IF node at the start of the workflow.

Do I need to host my own n8n instance to meet GDPR requirements?

Self-hosting gives you full control over data residency. Deploy the Docker image behind your own firewall, configure a PostgreSQL database for persistent storage, and set N8N_ENCRYPTION_KEY environment variable to encrypt credentials at rest.

How much will this cost at scale (e.g., 5 000 emails per month)?

Assuming 5 000 emails, you'll need roughly 5 000 Perplexity tokens for lead generation + 5 000 for copy, totaling 10 000 tokens ≈ $20 / month on a pay-as-you-go plan. n8n's paid tier at $20 / month gives you 20 000 executions, sufficient for the extra HTTP calls and logging. Add any SMTP provider fees (SendGrid starts free up to 100 emails/day). Expect < $50 / month total for a medium-scale deployment.


By following this guide you now have a production-ready, autonomous cold-outreach AI agent built on n8n and the Perplexity API. The same pattern can be extended to LinkedIn outreach, SMS follow-ups, or even multi-step nurture sequences - just replace the Gmail node with the channel you need.

If you're hunting for more ready-made automations you can sell, check out the AI automations you can sell. And for a deeper dive into scaling lead-gen pipelines, grab the free guide.

Happy building.

Frequently asked questions

how do I store my Perplexity API key securely?

Create a Credential of type *API Key* in n8n and paste the key there. The credential value is encrypted at rest by n8n, and the key is never exposed in workflow JSON exports.

can I replace Google Sheets with a database?

Yes. n8n offers native nodes for PostgreSQL, MySQL, and MongoDB. Swap the *Read Leads* and *Append Row* nodes with the corresponding database query nodes, and adjust the field mapping accordingly.

what is the best way to avoid being flagged as spam?

Use a verified sending domain, set up SPF/DKIM/DMARC records, keep the email body concise, personalize each message, and include a clear unsubscribe link. Sending no more than 50 emails per hour from a new IP is a practical warm-up schedule.

how many leads can this workflow handle per day?

The practical limit depends on your Perplexity token budget and SMTP provider's daily send quota. A typical safe setting is 100-150 leads per day with 150-token prompts, which stays well under most free-tier limits and keeps costs predictable.

where can I learn more about building sellable AI automations?

Check out the guide on AI automations you can sell and grab the free guide for deeper case studies and pricing templates.

Get the full toolkit

Grab the free guide with the node-by-node build for all 10 automations.

No spam. Unsubscribe anytime. Just the good stuff.