This commit is contained in:
nusquama
2025-11-12 14:33:39 +01:00
parent c9db898bf8
commit c8750097fa
@@ -0,0 +1,317 @@
Automated Personalized Email Outreach with AI, Database Tracking & Scheduling
https://n8nworkflows.xyz/workflows/automated-personalized-email-outreach-with-ai--database-tracking---scheduling-9114
# Automated Personalized Email Outreach with AI, Database Tracking & Scheduling
### 1. Workflow Overview
This workflow automates personalized cold email outreach at scale using AI-driven email customization, lead database integration, and scheduling for follow-up contacts. It targets sales teams, recruiters, and agencies that need to initiate first-contact emails to uncontacted leads while managing outreach cadence and avoiding spam filters.
The workflow is logically divided into these blocks:
- **1.1 Scheduled Trigger & Data Retrieval:** Periodically triggers the workflow, fetches all leads from a NocoDB database.
- **1.2 Lead Filtering & Batch Limiting:** Filters leads who have not yet been contacted (no "Initial Contact Date") and limits the batch size to avoid email spam issues.
- **1.3 AI Email Personalization:** Uses an AI language model to customize a base email template by inserting each leads name and company name without altering any other content.
- **1.4 Email Sending:** Sends the personalized emails via SMTP.
- **1.5 Database Update & Scheduling:** Updates the contacted lead's record with the current outreach date and schedules a follow-up contact date 3 days later.
- **1.6 Documentation & Instructions:** Sticky notes provide detailed explanations, usage instructions, setup checklists, database structure, and troubleshooting tips.
---
### 2. Block-by-Block Analysis
#### Block 1.1: Scheduled Trigger & Data Retrieval
**Overview:**
Triggers the workflow daily at a set time, then retrieves all leads from the NocoDB project.
**Nodes Involved:**
- Schedule Trigger
- Get many rows (NocoDB)
**Node Details:**
- **Schedule Trigger**
- Type: Schedule Trigger
- Role: Initiates workflow automatically at 10:30 AM daily.
- Configuration: Triggers once daily, at 10:30 AM.
- Input: None (trigger node)
- Output: Starts workflow flow to "Get many rows" node.
- Failures: N/A (runs on schedule)
- Notes: Timing can be customized or switched to manual/webhook triggers.
- **Get many rows (NocoDB)**
- Type: Database node (NocoDB)
- Role: Fetches all lead records from the specified NocoDB table.
- Configuration:
- Operation: Get All rows
- Table: "mznkwe3wz0dofde"
- Project ID: "psinm4yvd05vnvy"
- Authentication: NocoDB API token
- Return All: true (fetches entire dataset)
- Input: Trigger from Schedule Trigger
- Output: List of all leads to Filter node
- Failure modes: API errors, invalid credentials, network issues
- Credentials: NocoDB API token required
---
#### Block 1.2: Lead Filtering & Batch Limiting
**Overview:**
Filters leads who have not been contacted (no "Initial Contact Date") and limits to 15 leads per run to protect email reputation.
**Nodes Involved:**
- Filter
- Limit
**Node Details:**
- **Filter**
- Type: Filter node
- Role: Passes only leads without "Initial Contact Date" set (uncontacted leads).
- Configuration: Condition checks if "Initial Contact Date" field does not exist or is empty.
- Input: Output from "Get many rows"
- Output: Leads meeting condition to "Limit" node
- Failures: Expression errors if field is missing or misnamed; results in zero output if no matches.
- Notes: Ensures no duplicate outreach emails.
- **Limit**
- Type: Limit node
- Role: Restricts the number of leads processed in one batch to 15.
- Configuration: Maximum items set to 15
- Input: Filtered leads
- Output: Limited batch to AI personalization
- Failures: None expected; acts as a safeguard
- Notes: Helps reduce spam risk and maintain good sender reputation.
---
#### Block 1.3: AI Email Personalization
**Overview:**
Personalizes the email template for each lead by replacing only the recipients name and company name using an AI language model, preserving all other text and formatting.
**Nodes Involved:**
- Basic LLM Chain
- Groq Chat Model
**Node Details:**
- **Basic LLM Chain**
- Type: LangChain LLM Chain node
- Role: Constructs the prompt for AI to personalize emails based on lead data; calls AI model.
- Configuration:
- Prompt instructs replacing only recipient name and company placeholders in the template.
- Uses input JSON fields `first_name` and `organization_name` for replacements.
- Output is the modified email text only, no extra commentary.
- Input: Limited leads from "Limit" node, AI language model from "Groq Chat Model" node
- Output: Personalized email text to "Send email" node
- Failures: Prompt syntax errors, missing data fields, AI service outages, incorrect model credentials
- Notes: Prompt is fully customizable for branding and style.
- **Groq Chat Model**
- Type: LangChain AI language model node (Groq)
- Role: Provides the AI engine that actually processes the prompt and returns the personalized email text.
- Configuration:
- Model selected: "openai/gpt-oss-120b" via Groq API
- Credentials: Groq API key required
- Input: Prompt from "Basic LLM Chain"
- Output: AI-generated personalized email text to "Basic LLM Chain"
- Failures: API key issues, rate limits, model unavailability
---
#### Block 1.4: Email Sending
**Overview:**
Sends personalized emails generated by AI to each lead via SMTP.
**Nodes Involved:**
- Send email
**Node Details:**
- **Send email**
- Type: Email Send node (SMTP)
- Role: Sends the personalized email text to each leads email address.
- Configuration:
- Subject: "Quick Question About Lead Qualification" (static text)
- To: Uses leads email from "Limit" node JSON data
- Body: Uses personalized email text from AI output
- Format: Plain text
- Append Attribution: disabled
- Input: Personalized email text from "Basic LLM Chain"
- Output: Passes to "Date & Time" node for scheduling update
- Failures: SMTP authentication errors, invalid email addresses, network issues
- Credentials: SMTP server credentials required
---
#### Block 1.5: Database Update & Scheduling
**Overview:**
Updates the leads record with current date as "Initial Contact Date" and schedules the next follow-up contact date 3 days later.
**Nodes Involved:**
- Date & Time
- Update a row (NocoDB)
**Node Details:**
- **Date & Time**
- Type: Date & Time node
- Role: Generates current date and calculates next follow-up date (+3 days).
- Configuration: Uses current date/time; formats dates as M/dd/yy strings.
- Input: Output from "Send email"
- Output: Date fields to "Update a row" node
- Failures: None expected; dependent on system clock
- **Update a row (NocoDB)**
- Type: NocoDB node
- Role: Updates the leads database record with new dates.
- Configuration:
- Operation: Update row in the same table
- Fields updated:
- "Initial Contact Date" set to current date
- "Next Follow up/Contact" set to current date plus 3 days
- Row ID: Uses leads unique "Id" field from "Get many rows" data
- Input: Date info from "Date & Time" node
- Output: Workflow ends or continues for other processing
- Failures: Incorrect ID reference, credential issues, API errors
---
#### Block 1.6: Documentation & Instructions
**Overview:**
Multiple sticky notes are used to document workflow purpose, usage instructions, setup checklist, database schema, and troubleshooting tips for users.
**Nodes Involved:**
- Sticky Note
- Sticky Note1
- Sticky Note2
- Sticky Note3
**Node Details:**
- All sticky notes provide extensive textual information covering:
- Workflow purpose and use cases
- Step-by-step usage and customization tips
- Setup instructions for database, workflow, and credentials
- Database field requirements and structure
- Troubleshooting common errors and issues
- Best practices and recommendations for safe emailing
- They do not interact with data but serve as inline documentation for maintainers and users.
---
### 3. Summary Table
| Node Name | Node Type | Functional Role | Input Node(s) | Output Node(s) | Sticky Note |
|-------------------|------------------------|----------------------------------------|---------------------|----------------------|----------------------------------------------------------------------------------------------|
| Schedule Trigger | Schedule Trigger | Initiates workflow daily at 10:30 AM | N/A | Get many rows | ## How to use: The Schedule Trigger runs daily by default, customizable timing |
| Get many rows | NocoDB | Fetches all lead records | Schedule Trigger | Filter | ## Database Structure: Shows required lead fields |
| Filter | Filter | Filters leads without Initial Contact Date | Get many rows | Limit | ## Troubleshooting: Ensures leads with Initial Contact Date are excluded |
| Limit | Limit | Limits processing to 15 leads per run | Filter | Basic LLM Chain | Helps avoid spam filters by limiting daily email volume |
| Basic LLM Chain | LangChain LLM Chain | Constructs prompt and calls AI for personalization | Limit, Groq Chat Model | Send email | Customize email template for personalization |
| Groq Chat Model | LangChain AI Model | AI engine providing text personalization | Basic LLM Chain | Basic LLM Chain | Requires Groq API key; AI personalization costs approx. $0.001 |
| Send email | Email Send (SMTP) | Sends personalized emails via SMTP | Basic LLM Chain | Date & Time | Use SMTP or Gmail; verify credentials |
| Date & Time | Date & Time | Generates current date and next follow-up date | Send email | Update a row | Formats dates for database update |
| Update a row | NocoDB | Updates lead record with contact and follow-up dates | Date & Time | N/A | Updates database to track outreach status |
| Sticky Note | Sticky Note | Workflow purpose, use cases, and overview | N/A | N/A | Provides detailed workflow introduction and best practices |
| Sticky Note1 | Sticky Note | Usage instructions and requirements | N/A | N/A | Setup instructions and customization tips |
| Sticky Note2 | Sticky Note | Setup checklist for database and workflow | N/A | N/A | Step-by-step setup guide |
| Sticky Note3 | Sticky Note | Database schema and troubleshooting tips | N/A | N/A | Lists required fields and common error resolutions |
---
### 4. Reproducing the Workflow from Scratch
1. **Create Schedule Trigger Node**
- Type: Schedule Trigger
- Set to trigger daily at 10:30 AM (adjust as needed)
- Connect output to "Get many rows" node
2. **Create NocoDB "Get many rows" Node**
- Type: NocoDB
- Operation: Get All
- Table: your leads table (e.g., "mznkwe3wz0dofde")
- Project ID: your NocoDB project ID
- Authentication: Use NocoDB API Token credentials
- Connect output to "Filter" node
3. **Create Filter Node**
- Type: Filter
- Condition: Check if "Initial Contact Date" field does NOT exist or is empty
- Connect output to "Limit" node
4. **Create Limit Node**
- Type: Limit
- Set max items to 15 (adjustable)
- Connect output to "Basic LLM Chain" node
5. **Create LangChain Basic LLM Chain Node**
- Type: LangChain LLM Chain
- Prompt: Insert your email template with placeholders ((name)) and ((company))
- Instructions: Replace only recipients name and company name using input JSON fields `first_name` and `organization_name`
- Connect AI language model input to the Groq Chat Model node
- Connect output to "Send email" node
6. **Create LangChain Groq Chat Model Node**
- Type: LangChain LM Chat Groq
- Configure with Groq API key credentials
- Model: "openai/gpt-oss-120b" or your chosen model
- Connect output to "Basic LLM Chain" ai_languageModel input
7. **Create Send Email Node**
- Type: Email Send (SMTP)
- To: Use lead's email address from the limited batch JSON data
- Subject: Set static subject line (e.g., "Quick Question About Lead Qualification")
- Body: Use personalized email text from AI output
- Format: Plain text
- Credentials: Configure SMTP or Gmail OAuth2 credentials
- Connect output to "Date & Time" node
8. **Create Date & Time Node**
- Type: Date & Time
- Configure to get current date/time and calculate next follow-up date by adding 3 days
- Format both dates as "M/dd/yy" strings
- Connect output to "Update a row" node
9. **Create NocoDB "Update a row" Node**
- Type: NocoDB
- Operation: Update
- Table: Same as in "Get many rows"
- Fields to update:
- "Initial Contact Date" = current date
- "Next Follow up/Contact" = current date + 3 days
- Row ID: Use leads unique Id from the original dataset
- Credentials: NocoDB API Token
- Connect output as needed (usually end of workflow)
10. **Add Sticky Note Nodes** (Optional but recommended)
- Add sticky notes containing workflow overview, usage instructions, setup checklists, database structure, and troubleshooting tips for maintainers.
---
### 5. General Notes & Resources
| Note Content | Context or Link |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------|
| This workflow automates personalized first-contact email outreach with AI personalization and lead tracking. Ideal for sales teams, recruiters, and agencies managing outreach at scale. | Workflow Overview (Sticky Note) |
| The daily limit of 15 emails helps avoid spam filters and protects email reputation; adjust according to your needs. | Limit node and Sticky Note1 |
| AI personalization costs vary by provider; Groq costs approx. $0.001 per personalization with a free tier available. | Groq Chat Model node details |
| Use NocoDB for flexible, no-code database management; can be replaced with any other database node if needed. | Sticky Note and Setup Instructions |
| SMTP or Gmail OAuth2 can be used for sending emails; ensure correct credentials and avoid sending to invalid email addresses to minimize bounces. | Send Email node notes |
| Modify the email template inside the AI node prompt to match branding and tone; keep placeholders for ((name)) and ((company)). | Basic LLM Chain node prompt |
| Scheduling intervals (initial outreach and follow-up) can be customized by adjusting the Schedule Trigger node and Date & Time calculations. | Date & Time node and Schedule Trigger node notes |
| Troubleshooting tips include checking credentials, field names (case sensitivity), and ensuring leads have proper data entries to avoid errors or duplicate emails. | Sticky Note3 |
| You can switch AI providers by replacing the Groq model node with OpenAI, Anthropic, or local LangChain-compatible models. | Sticky Note1 |
| For ease of setup, import the workflow JSON into n8n and configure credentials for NocoDB, AI provider, and SMTP/Gmail as described in the setup checklist. | Sticky Note2 |
---
**Disclaimer:** The provided text is extracted exclusively from an n8n automation workflow. It complies strictly with content policies and contains no illegal, offensive, or protected elements. All data processed is legal and public.