This workflow corresponds to n8n.io template #14147 — we link there as the canonical source.
This workflow follows the Agent → Gmail 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 →
{
"meta": {
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "380fa486-1998-4141-a15e-dd4bb35a7873",
"name": "Schedule Trigger",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
4384,
1360
],
"parameters": {
"rule": {
"interval": [
{}
]
}
},
"typeVersion": 1.3
},
{
"id": "e43a8c91-c360-4302-84cf-33fa46e28ef8",
"name": "AI Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
5104,
1152
],
"parameters": {},
"typeVersion": 3.1
},
{
"id": "1ae8a25d-15e1-4875-9c1c-b543877ceca1",
"name": "Groq Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatGroq",
"position": [
5120,
1360
],
"parameters": {
"model": "llama-3.3-70b-versatile",
"options": {}
},
"typeVersion": 1
},
{
"id": "ad7184ac-fcf0-46f1-88cb-d4c35e1ff989",
"name": "Send a message",
"type": "n8n-nodes-base.gmail",
"position": [
5616,
1440
],
"parameters": {
"sendTo": "={{ $('Loop Over Contacts').item.json.properties.email.value }}",
"message": "=<html>\n<body>\n<div style=\"font-family: Arial, sans-serif; line-height: 1.6; color: #333; max-width: 80%; margin: auto;\">\n\n <h2 style=\"color:#2c3e50;\">Personalized Marketing Campaign Strategy</h2>\n\n <p>Hello,</p>\n\n <p>\n We analyzed your company website and generated a personalized advertising campaign strategy\n that could help attract more qualified leads and customers.\n </p>\n\n <hr>\n\n <div style=\"background:#f7f9fc; padding:20px; border-radius:8px;\">\n\n <h3 style=\"color:#34495e;\">Campaign Strategy</h3>\n\n <p style=\"white-space: pre-line;\">\n {{$json.campaign}}\n </p>\n\n </div>\n\n <br>\n\n <div style=\"background:#eef3ff; padding:15px; border-radius:6px;\">\n <p style=\"margin:0;\">\n If you'd like, we would be happy to discuss how this campaign could be implemented for your business.\n </p>\n </div>\n\n <br>\n\n <p>\n Best regards,<br>\n <strong>Marketing Strategy Team</strong>\n </p>\n\n <hr>\n\n\n</div>\n</body>\n</html>",
"options": {},
"subject": "=Your Personalized Marketing Campaign for {{ $('Loop Over Contacts').item.json.properties.company.value }}"
},
"typeVersion": 2.2
},
{
"id": "79ac6576-dc25-4a59-965e-582ce8e26dc7",
"name": "Loop Over Contacts",
"type": "n8n-nodes-base.splitInBatches",
"position": [
4864,
1360
],
"parameters": {
"options": {
"reset": false
}
},
"typeVersion": 3,
"alwaysOutputData": false
},
{
"id": "846e91dc-8fbc-4fa8-9e35-35d084d9a873",
"name": "Format AI's output",
"type": "n8n-nodes-base.code",
"position": [
5424,
1152
],
"parameters": {
"jsCode": "let text =$input.first().json.output ;\n\n// convert escaped newline characters to real HTML line breaks\ntext = text.replace(/\\\\n/g, \"<br><br>\");\n\nreturn [\n {\n json: {\n campaign: text\n }\n }\n];"
},
"typeVersion": 2
},
{
"id": "dad86144-67bf-4d18-a3f5-f69b1273846f",
"name": "Search contacts",
"type": "n8n-nodes-base.hubspot",
"position": [
4608,
1360
],
"parameters": {
"operation": "search",
"authentication": "appToken",
"filterGroupsUi": {
"filterGroupsValues": [
{
"filtersUi": {
"filterValues": [
{
"value": "={{ new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString() }}",
"operator": "=GTE",
"propertyName": "createdate|datetime"
}
]
}
}
]
},
"additionalFields": {}
},
"typeVersion": 2.2
},
{
"id": "090b1870-69ec-4e20-9e04-c49ab9a9c8be",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
3648,
848
],
"parameters": {
"width": 608,
"height": 800,
"content": "# Hyper-Personalized Ad Campaign Generator\n\nThis workflow automatically generates AI-powered advertising campaign strategies for newly created CRM contacts and sends them via email.\n\n## How it works\nThe workflow runs on a schedule and retrieves contacts created in the last 24 hours from the CRM. Each contact is processed individually through a loop. Company details such as name and website are sent to an AI agent, which analyzes the business and generates a structured advertising campaign strategy. The output is formatted into a readable format and delivered via email to the contact.\n\n## Setup steps\n1. Connect your HubSpot credentials.\n2. Configure your AI model (Groq) credentials.\n3. Connect your Gmail or SMTP account.\n4. Review and customize the AI prompt if needed.\n5. Activate the workflow.\n\n## Customization tips\n- Adjust the schedule timing based on your needs.\n- Modify the AI prompt for different industries or campaign styles.\n- Customize the email template for branding or personalization."
},
"typeVersion": 1
},
{
"id": "344b7f8c-5fa1-4610-a63d-0865c84ab0f4",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
4288,
848
],
"parameters": {
"color": 7,
"width": 464,
"height": 800,
"content": "## Fetch New Contacts\n\nRuns on schedule and retrieves contacts created in the last 24 hours from HubSpot."
},
"typeVersion": 1
},
{
"id": "620a9e05-9a1b-4a7d-b97e-37d41ca7670d",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
4784,
848
],
"parameters": {
"color": 7,
"width": 1024,
"height": 800,
"content": "## Generate Campaign & Send Email\n\nAI creates campaign strategy \u2192 format output \u2192 send personalized email."
},
"typeVersion": 1
}
],
"connections": {
"Send a message": {
"main": [
[
{
"node": "Loop Over Contacts",
"type": "main",
"index": 0
}
]
]
},
"Search contacts": {
"main": [
[
{
"node": "Loop Over Contacts",
"type": "main",
"index": 0
}
]
]
},
"Schedule Trigger": {
"main": [
[
{
"node": "Search contacts",
"type": "main",
"index": 0
}
]
]
},
"Format AI's output": {
"main": [
[
{
"node": "Send a message",
"type": "main",
"index": 0
}
]
]
}
}
}
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
This workflow runs on a schedule and retrieves newly created HubSpot contacts from the past 24 hours. It processes each contact individually and generates a tailored marketing campaign using an AI model. The generated content is formatted into a clean HTML structure. Finally, a…
Source: https://n8n.io/workflows/14147/ — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
This workflow automates customer outreach for marketing campaigns, including customer prioritization, AI-generated emails, automated sending, reply tracking, and meeting scheduling. Data Synchronizati
Email Subscription Service With N8N Forms, Airtable And Ai. Uses scheduleTrigger, airtable, gmail, executeWorkflow. Scheduled trigger; 32 nodes.
Code Schedule. Uses scheduleTrigger, airtable, gmail, executeWorkflow. Scheduled trigger; 32 nodes.
This n8n template shows how anyone can build a simple newsletter-like subscription service where users can enrol themselves to receive messages/content on a regular basis. It uses n8n forms for data c
This workflow automatically monitors competitor product prices stored in Google Sheets. It scrapes product pages, extracts pricing and offer data using AI, and compares it with historical values. Base