{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "d5cc818c-806e-4b8a-86a3-6eb090fbf10b",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        0,
        0
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 10,
              "triggerAtMinute": 30
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "cc7c393b-1edb-496f-9739-71ba7dcfe692",
      "name": "Get many rows",
      "type": "n8n-nodes-base.nocoDb",
      "position": [
        176,
        0
      ],
      "parameters": {
        "table": "mznkwe3wz0dofde",
        "options": {},
        "operation": "getAll",
        "projectId": "psinm4yvd05vnvy",
        "returnAll": true,
        "authentication": "nocoDbApiToken"
      },
      "credentials": {
        "nocoDbApiToken": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "2b19fa40-85c2-4d12-810c-04bcffabb877",
      "name": "Filter",
      "type": "n8n-nodes-base.filter",
      "position": [
        352,
        0
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "0fac1715-b303-4697-a3cf-1cb8c47ab439",
              "operator": {
                "type": "dateTime",
                "operation": "notExists",
                "singleValue": true
              },
              "leftValue": "={{ $json['Initial Contact Date'] }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "46c0f6e6-64c8-4f46-b322-16d20e711aa5",
      "name": "Limit",
      "type": "n8n-nodes-base.limit",
      "position": [
        560,
        0
      ],
      "parameters": {
        "maxItems": 15
      },
      "typeVersion": 1
    },
    {
      "id": "5f2d6070-ac2a-4e75-a12d-0dae1cda1abb",
      "name": "Basic LLM Chain",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        752,
        0
      ],
      "parameters": {
        "text": "=You are an email personalization assistant. Your job is to modify an email template by replacing ONLY two specific elements:\n\n1. Replace the recipient's name\n2. Replace the company name\n\nCRITICAL INSTRUCTIONS:\n- Change ONLY the name and company name\n- Keep ALL other content exactly the same\n- Maintain the exact formatting, spacing, and structure\n- Do not modify subject lines, signatures, or any other text\n- Do not add extra content or make style changes\n\nINPUT FORMAT:\nYou will receive:\n- Original Email: \n(Hey ((Name)). Love ((Company)).\nWanted to run something by you.\n\n[[Insert Email Template Here]]\n\n- New Name: {{ $json.first_name }}\n- New Company: {{ $json.organization_name }}\n\nREPLACEMENT RULES:\n- Look for placeholders like: ((name)), or obvious name placeholders\n- Look for placeholders like: ((company)), or obvious company placeholders\n- If no placeholders exist, intelligently identify where names/companies should go\n- Use the exact capitalization provided in the input\n\nOUTPUT FORMAT:\nReturn only the modified email with no additional commentary, explanations, or metadata.\n\nEXAMPLE:\nInput:\nOriginal Email: \"Hi ((name)), Welcome to ((company))! We're excited to work with you.\"\nNew Name: \"Sarah Johnson\"\nNew Company: \"TechCorp Solutions\"\n\nOutput:\nHi Sarah Johnson, Welcome to TechCorp Solutions! We're excited to work with you.",
        "batching": {},
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "7cac1b8d-5521-42ac-b33d-3dbc148b6e6d",
      "name": "Groq Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGroq",
      "position": [
        752,
        208
      ],
      "parameters": {
        "model": "openai/gpt-oss-120b",
        "options": {}
      },
      "credentials": {
        "groqApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "11d4208c-d028-4502-89a7-516e3afa3c6e",
      "name": "Send email",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        1104,
        0
      ],
      "parameters": {
        "text": "={{ $json.text }}",
        "options": {
          "appendAttribution": false
        },
        "subject": "Quick Question About Lead Qualification",
        "toEmail": "={{ $('Limit').item.json.email }}",
        "emailFormat": "text"
      },
      "credentials": {
        "smtp": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "917b005c-8f57-4692-bb07-08d1f7bcdd82",
      "name": "Update a row",
      "type": "n8n-nodes-base.nocoDb",
      "position": [
        1520,
        0
      ],
      "parameters": {
        "table": "mznkwe3wz0dofde",
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldName": "Id",
              "fieldValue": "={{ $('Get many rows').item.json.Id }}"
            },
            {
              "fieldName": "=Initial Contact Date",
              "fieldValue": "={{ $json.currentDate.toDateTime().format('M/dd/yy') }}"
            },
            {
              "fieldName": "Next Follow up/Contact",
              "fieldValue": "={{ $json.currentDate.toDateTime().plus(3, 'Days').format('M/dd/yy') }}"
            }
          ]
        },
        "operation": "update",
        "projectId": "psinm4yvd05vnvy",
        "authentication": "nocoDbApiToken"
      },
      "credentials": {
        "nocoDbApiToken": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "024256ad-46f8-4eab-82fa-e27aa8f58cd3",
      "name": "Date & Time",
      "type": "n8n-nodes-base.dateTime",
      "position": [
        1312,
        0
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 2
    },
    {
      "id": "95468996-f82e-4b7d-bc77-454221ae8e2b",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -848,
        -832
      ],
      "parameters": {
        "color": 4,
        "width": 1280,
        "height": 800,
        "content": "# Initial Outreach Email Workflow\n\nThis n8n template automates personalized first-contact cold email outreach using AI-driven personalization and lead database tracking.  \nIdeal for sales teams, recruiters, agencies, or anyone managing new lead outreach at scale.\n\n**Use cases:**\n- Reach out to uncontacted leads for the first time  \n- Initiate conversations  \n- Qualify interest  \n- Set up follow-up scheduling  \n\n---\n\n## How it works\n\n- **NocoDB** fetches all leads and filters those without an **\"Initial Contact Date\"** (i.e., leads who have not been contacted yet).  \n- **Leads are limited to 15 per execution** to help avoid triggering spam filters on Gmail or other email services (this limit is optional and adjustable).  \n- **AI personalizes an email template** by replacing only the recipient\u2019s name and company name placeholders while maintaining all other content unchanged.  \n- Personalized emails are sent through **SMTP (or Gmail node)**.  \n- The workflow **updates each contact\u2019s \"Initial Contact Date\"** to the current date and schedules a **\"Next Follow up/Contact\" date 3 days later** by default (intervals are customizable).  \n- The entire workflow is **triggered daily by default at 10:30 AM**, but this can be adjusted.  \n- Leads already contacted or with an **\"Initial Contact Date\"** set are **automatically skipped** to prevent duplicate outreach.  \n\n---\n\n## Good to know\n\n- Each AI personalization costs roughly **$0.001 with Groq** (free tier available); pricing varies by provider.  \n- The daily contact limit of **15 helps protect email reputation** and reduces spam risk\u2014users can change or remove this.  \n- The email template for personalization is **fully customizable** to match your brand\u2019s tone and offer.  \n- Scheduling intervals (initial outreach and follow-up days) are **modifiable** within the workflow to suit your sales cadence.  \n\n\n- **YOU CAN SWAP NOCODDB FOR ANY DATABASE AND SWAP THE SEND EMAIL NODE FOR THE GMAIL NODE(which is set up using OAuth, making it easier)**\n\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "76e7eb8f-a322-4418-8925-d25dcd495671",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        448,
        -832
      ],
      "parameters": {
        "color": 5,
        "width": 864,
        "height": 800,
        "content": "## How to use\n\n- The **Schedule Trigger** runs daily by default, but you can switch it to manual or webhook triggers for on-demand outreach.  \n- **Customize the email template** in the AI node by editing the content around the name and company placeholders.  \n- **Adjust the daily lead limit and timing** in the Limit and Schedule Trigger nodes as needed.  \n- **Import your lead list into NocoDB** with required fields:  \n  - `first_name`  \n  - `email`  \n  - `organization_name` (optional)  \n- **Configure credentials** in n8n for:  \n  - NocoDB  \n  - AI provider (Groq/OpenAI)  \n  - SMTP  \n\n---\n\n## Requirements\n\n- **NocoDB account** managing the lead database  \n- **Groq API key** (or other AI provider) for email personalization  \n- **SMTP or Gmail credentials** for sending emails  \n- **n8n instance** (self-hosted or cloud)  \n\n---\n\n## Customizing this workflow\n\n- **Change outreach timing** \u2192 Modify the Schedule Trigger node.  \n- **Adjust daily email volume** \u2192 Change or remove the Limit node\u2019s `maxItems` value.  \n- **Modify email content/personalization** \u2192 Edit the AI prompt template in the LLM chain node.  \n- **Switch AI providers** \u2192 Replace Groq nodes with OpenAI, Anthropic, or local models (via LangChain).  \n- **Integrate CRM/next steps** \u2192 Add nodes after the contact update for extended automation.  "
      },
      "typeVersion": 1
    },
    {
      "id": "0eef6de7-553f-4806-abf6-1e1833cdd311",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1328,
        -832
      ],
      "parameters": {
        "color": 6,
        "width": 480,
        "height": 800,
        "content": "## Setup Checklist\n\n### Database Setup (5 minutes)\n- Create NocoDB table with fields:  \n  - `first_name`  \n  - `email`  \n  - `Initial Contact Date`  \n  - `Next Follow up/Contact`  \n  - `organization_name` (optional)  \n- Add/import leads into the database (ensure uncontacted leads have no Initial Contact Date).  \n\n### Workflow Configuration (10 minutes)\n- Import this workflow JSON into n8n.  \n- Add credentials for NocoDB, Groq API, and SMTP/Gmail.  \n- Update email template inside the AI personalization node to match your copy and style.  \n\n### Testing (5 minutes)\n- Add a test lead without an Initial Contact Date and your email address.  \n- Run the workflow manually to confirm the email sends and updates fields correctly.  \n- Adjust limits/timing nodes to simulate different scenarios.  \n\n### Go Live\n- Set the Schedule Trigger to your preferred time (**default 10:30 AM daily**).  \n- Activate the workflow.  \n- Monitor initial runs to confirm successful email sending.  \n\n---\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "c1cce483-b104-4473-bd8f-25c071a3ce51",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1840,
        -832
      ],
      "parameters": {
        "color": 7,
        "width": 480,
        "height": 800,
        "content": "## Database Structure\n\n**Required fields:**\n- `first_name` \u2014 for personalized greetings  \n- `email` \u2014 recipient address  \n- `Initial Contact Date` \u2014 marks first contact, prevents duplicates  \n- `Next Follow up/Contact` \u2014 schedules next outreach  \n- `organization_name` (optional) \u2014 used for company name personalization  \n\n---\n\n## Troubleshooting\n\n- **No emails sent:**  \n  - Check if there are leads without Initial Contact Date.  \n  - Ensure the Limit node batch is not exceeded.  \n  - Verify SMTP credentials.  \n\n- **AI personalization errors:**  \n  - Check AI API key and model selection.  \n  - Verify prompt formatting in the LangChain node.  \n\n- **Database not updating:**  \n  - Confirm field names are case-sensitive.  \n  - Check NocoDB credentials.  \n\n- **Duplicate emails:**  \n  - Verify the filter node excludes leads with Initial Contact Date set.  "
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Limit": {
      "main": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter": {
      "main": [
        [
          {
            "node": "Limit",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send email": {
      "main": [
        [
          {
            "node": "Date & Time",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Date & Time": {
      "main": [
        [
          {
            "node": "Update a row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get many rows": {
      "main": [
        [
          {
            "node": "Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Basic LLM Chain": {
      "main": [
        [
          {
            "node": "Send email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Groq Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Get many rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}