{
  "id": "3G0lGLofYXfFMJki",
  "name": "Personalized Cold Email System with Google Gemini AI and Telegram Approval",
  "tags": [],
  "nodes": [
    {
      "id": "13f60a77-9d63-4c40-9c9b-5d7f3dea45a5",
      "name": "Setup Guide",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -208,
        448
      ],
      "parameters": {
        "color": 4,
        "width": 428,
        "height": 388,
        "content": "## \ud83d\udce7 COLD EMAIL SYSTEM - SETUP\n\n**What it does:** AI-generated cold emails with Telegram approval\n\n**Setup:**\n1. Google Sheets: 3 tabs (Filtered Leads, Sent Leads, Emails Sent)\n2. Telegram Bot + Chat ID\n3. Google Gemini API\n4. SMTP Email\n\n**Flow:**\nFetch leads \u2192 AI generates email \u2192 Telegram approval \u2192 Send/Reject \u2192 Update sheets\n\n**Config:** Limit node = 3 leads per run"
      },
      "typeVersion": 1
    },
    {
      "id": "35009e5d-acb1-496c-9545-26e71726594e",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        352,
        560
      ],
      "parameters": {
        "color": 5,
        "width": 180,
        "height": 80,
        "content": "\ud83d\ude80 START\nManual trigger"
      },
      "typeVersion": 1
    },
    {
      "id": "80cd4231-79c4-4605-9c38-1ac7b36c884a",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1600,
        512
      ],
      "parameters": {
        "color": 6,
        "width": 180,
        "height": 100,
        "content": "\ud83d\udcca FETCH\nStatus=Available\nLimit: 3"
      },
      "typeVersion": 1
    },
    {
      "id": "c541f67c-c949-4fbd-815f-fbdc69d6e0a8",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2208,
        528
      ],
      "parameters": {
        "color": 3,
        "width": 180,
        "height": 80,
        "content": "\ud83d\udd01 LOOP\nOne lead at a time"
      },
      "typeVersion": 1
    },
    {
      "id": "bd034011-7b57-4cfd-95aa-93b976eae60f",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3344,
        528
      ],
      "parameters": {
        "color": 2,
        "width": 200,
        "height": 100,
        "content": "\ud83e\udd16 AI GENERATOR\nCreates Subject + Body"
      },
      "typeVersion": 1
    },
    {
      "id": "b7db2d1d-b507-4548-be89-50cd76e14d9c",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3904,
        560
      ],
      "parameters": {
        "color": 5,
        "width": 180,
        "height": 80,
        "content": "\ud83d\udcf1 APPROVAL\nTelegram: \u2705/\u274c"
      },
      "typeVersion": 1
    },
    {
      "id": "14a9792f-ee2a-4684-aeaa-2da41c640796",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4480,
        560
      ],
      "parameters": {
        "width": 160,
        "height": 80,
        "content": "\u2709\ufe0f SEND\nSMTP email"
      },
      "typeVersion": 1
    },
    {
      "id": "d08c43da-f73c-428f-8f9d-93a90ef2ee6b",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4144,
        976
      ],
      "parameters": {
        "color": 7,
        "width": 180,
        "height": 100,
        "content": "\ud83d\udd04 REJECT\nFeedback \u2192 Regenerate"
      },
      "typeVersion": 1
    },
    {
      "id": "90959807-8827-4587-a2f7-778bf7d91931",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2912,
        960
      ],
      "parameters": {
        "color": 2,
        "width": 180,
        "height": 100,
        "content": "\ud83d\udcdd TRACKING\n3 Sheets updated"
      },
      "typeVersion": 1
    },
    {
      "id": "4d8a3589-6829-451b-b38c-df8c30dc0c1c",
      "name": "When clicking 'Execute workflow'",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        416,
        640
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "d88be5e7-7eaf-4f3b-b73b-4ca5a5570e4c",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        3376,
        656
      ],
      "parameters": {
        "text": "Generate a personalized cold email based on the lead data provided.",
        "options": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "4169bb94-1366-4a47-be9a-d293da73bb81",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        3376,
        1008
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "7b543b43-9f4a-4614-8445-6e79a9afddfc",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        4192,
        656
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Approved",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "c49ca855-bd40-440a-979d-c383586057f7",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.data.approved }}",
                    "rightValue": "true"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Rejected",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "a312a422-53e7-4d4f-964e-ee222ef82f72",
                    "operator": {
                      "type": "boolean",
                      "operation": "false",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.data.approved }}",
                    "rightValue": "false"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "8b6572ea-7b9c-4a93-a874-662eb9975d06",
      "name": "Wait3",
      "type": "n8n-nodes-base.wait",
      "position": [
        5072,
        1504
      ],
      "parameters": {
        "amount": 1
      },
      "typeVersion": 1.1
    },
    {
      "id": "f36a5d1b-6a5d-41a9-a718-9dd064a3f2d8",
      "name": "Loop Over Items1",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        2304,
        640
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "8a80e447-ac0c-4110-b97c-28cb1bbe75c9",
      "name": "Send a text message9",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2592,
        320
      ],
      "parameters": {
        "text": "Batch Complete!\u2705",
        "chatId": "123456789",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "executeOnce": true,
      "typeVersion": 1.2
    },
    {
      "id": "ae9ca082-637f-43d4-a4ff-1524b7e2ea72",
      "name": "Send message and wait for response",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3968,
        656
      ],
      "parameters": {
        "chatId": "123456789",
        "message": "=Subject:{{ $json.output.Subject }}\n\nBody: {{ $json.output.Body }}",
        "options": {
          "appendAttribution": false
        },
        "operation": "sendAndWait",
        "approvalOptions": {
          "values": {
            "approvalType": "double"
          }
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c18f5b55-136a-4455-aa5a-3a89af529407",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        3664,
        848
      ],
      "parameters": {
        "autoFix": true,
        "jsonSchemaExample": "{\n\t\"Subject\": \"Subject Line\",\n\t\"Body\": \"Body Text\"\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "edcce28d-4449-44e0-99d1-e1cf5be9dcff",
      "name": "Google Gemini Chat Model3",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        3664,
        1008
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "5771def9-6954-498a-99b9-759b258eee66",
      "name": "AI Agent1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        2928,
        1072
      ],
      "parameters": {
        "text": "Update sheets: append to Sent Leads and update status to Sent in Filtered Leads.",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "8a0cfceb-a160-4441-80b3-9d8f5e851e59",
      "name": "Simple Memory1",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        3024,
        1360
      ],
      "parameters": {
        "sessionKey": "={{ $('Get Lead from Google Sheet').item.json['Lead \\nID'] }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 100
      },
      "typeVersion": 1.3
    },
    {
      "id": "292a0368-8d45-4211-baef-45627ed2359a",
      "name": "Google Gemini Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        2864,
        1360
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "1a4f6f59-46a7-44aa-84f7-4743bdb3c591",
      "name": "Filtered Leads Update",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        3360,
        1360
      ],
      "parameters": {
        "columns": {
          "value": {
            "Status": "={{ $fromAI('Status', '', 'string') }}",
            "Lead \nID": "={{ $fromAI('Lead__ID', '', 'string') }}"
          },
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Lead \nID"
          ]
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "13ksc1pWNwxO8yEAftFzmtUMX5IEY69P8yPS4sc_a31w"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "4ae9784f-765d-410f-879f-8c09344eeeab",
      "name": "Sent Leads Append",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        3184,
        1360
      ],
      "parameters": {
        "columns": {
          "value": {
            "Name": "={{ $fromAI('Name', '', 'string') }}",
            "Email": "={{ $fromAI('Email', '', 'string') }}",
            "Lead \nID": "={{ $fromAI('Lead__ID', '', 'string') }}",
            "Sent Date ": "={{ $fromAI('Sent_Date', '', 'string') }}"
          },
          "mappingMode": "defineBelow"
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 646128004
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "13ksc1pWNwxO8yEAftFzmtUMX5IEY69P8yPS4sc_a31w"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "64abe51f-b1d9-41bc-8c34-301260b2e1cb",
      "name": "AI Agent2",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        4480,
        272
      ],
      "parameters": {
        "text": "Archive email to Emails Sent sheet.",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "36fd7dec-3823-4cf1-bff8-c18c550aff95",
      "name": "Google Gemini Chat Model2",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        4480,
        448
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "0e3db645-32c5-4050-aa8e-1108434a4cf5",
      "name": "Send message and wait for response1",
      "type": "n8n-nodes-base.telegram",
      "position": [
        4176,
        1072
      ],
      "parameters": {
        "chatId": "123456789",
        "message": "How to change email?",
        "options": {},
        "operation": "sendAndWait",
        "responseType": "freeText"
      },
      "typeVersion": 1.2
    },
    {
      "id": "1a86c08b-7892-471c-8e14-dadb6716c094",
      "name": "AI Agent3",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        4384,
        1072
      ],
      "parameters": {
        "text": "Regenerate email based on user feedback.",
        "options": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "b6bf5560-d1df-46c8-825b-7a549e1fc7b4",
      "name": "Google Gemini Chat Model4",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        4384,
        1488
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "03b23058-3f93-4aae-8142-25a08dead41b",
      "name": "Structured Output Parser1",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        4608,
        1328
      ],
      "parameters": {
        "autoFix": true,
        "jsonSchemaExample": "{\n\t\"Subject\": \"Subject Line\",\n\t\"Body\": \"Body Text\"\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "62f96dd4-c9f0-49db-8d69-16d364415c4b",
      "name": "Google Gemini Chat Model5",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        4608,
        1488
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "77a8c096-2a84-41b5-9e77-8a17bb88112a",
      "name": "Send email",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        4544,
        640
      ],
      "parameters": {
        "text": "={{ $('AI Agent').item.json.output.Body }}\n\n--\nCompany Team",
        "options": {
          "bccEmail": "user@example.com",
          "appendAttribution": false
        },
        "subject": "={{ $('AI Agent').item.json.output.Subject }}",
        "toEmail": "={{ $('Get Lead from Google Sheet').item.json.Email }}",
        "fromEmail": "user@example.com",
        "emailFormat": "text"
      },
      "typeVersion": 2.1
    },
    {
      "id": "c7426e71-fc57-4bdc-8e28-f90eeb12e2e4",
      "name": "Date & Time",
      "type": "n8n-nodes-base.dateTime",
      "position": [
        1408,
        640
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 2
    },
    {
      "id": "dc15d5a6-e379-43d2-90f5-76bdaa3bbee3",
      "name": "Merge Data and Agent output for",
      "type": "n8n-nodes-base.merge",
      "position": [
        3824,
        272
      ],
      "parameters": {},
      "typeVersion": 3.2
    },
    {
      "id": "ec682146-6618-4d72-89cc-b4098b9a890a",
      "name": "Add Email Draft to Google Sheet",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        4816,
        432
      ],
      "parameters": {
        "columns": {
          "value": {
            "Lead \nID": "={{ $fromAI('Lead__ID', '', 'string') }}",
            "Email Body": "={{ $fromAI('Email_Body', '', 'string') }}",
            "Email Subject": "={{ $fromAI('Email_Subject', '', 'string') }}"
          },
          "mappingMode": "defineBelow"
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1377649974
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "13ksc1pWNwxO8yEAftFzmtUMX5IEY69P8yPS4sc_a31w"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "e6f1291e-0596-499e-8d9a-4293bcf50384",
      "name": "Limit Sheets Get Function",
      "type": "n8n-nodes-base.limit",
      "position": [
        2000,
        640
      ],
      "parameters": {
        "maxItems": 3
      },
      "typeVersion": 1
    },
    {
      "id": "2795d16a-e12c-4331-8eb3-eb6c3c8537fd",
      "name": "Get Lead from Google Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1664,
        640
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "Available",
              "lookupColumn": "Status"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/13ksc1pWNwxO8yEAftFzmtUMX5IEY69P8yPS4sc_a31w/edit#gid=0",
          "cachedResultName": "Filtered Leads"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "13ksc1pWNwxO8yEAftFzmtUMX5IEY69P8yPS4sc_a31w",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/13ksc1pWNwxO8yEAftFzmtUMX5IEY69P8yPS4sc_a31w/edit?usp=drivesdk",
          "cachedResultName": "FILTERED LEADS"
        }
      },
      "typeVersion": 4.7
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "d5131fde-6088-4498-b67f-54d4e02818c6",
  "connections": {
    "Wait3": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Send email",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send message and wait for response1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Merge Data and Agent output for",
            "type": "main",
            "index": 1
          },
          {
            "node": "Send message and wait for response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent3": {
      "main": [
        [
          {
            "node": "Send message and wait for response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send email": {
      "main": [
        [
          {
            "node": "Wait3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Date & Time": {
      "main": [
        [
          {
            "node": "Get Lead from Google Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory1": {
      "ai_memory": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items1": {
      "main": [
        [
          {
            "node": "Send a text message9",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge Data and Agent output for",
            "type": "main",
            "index": 0
          },
          {
            "node": "AI Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sent Leads Append": {
      "ai_tool": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Filtered Leads Update": {
      "ai_tool": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent2",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model3": {
      "ai_languageModel": [
        [
          {
            "node": "Structured Output Parser",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model4": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent3",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model5": {
      "ai_languageModel": [
        [
          {
            "node": "Structured Output Parser1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Limit Sheets Get Function": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser1": {
      "ai_outputParser": [
        [
          {
            "node": "AI Agent3",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Get Lead from Google Sheet": {
      "main": [
        [
          {
            "node": "Limit Sheets Get Function",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add Email Draft to Google Sheet": {
      "ai_tool": [
        [
          {
            "node": "AI Agent2",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Merge Data and Agent output for": {
      "main": [
        [
          {
            "node": "AI Agent2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking 'Execute workflow'": {
      "main": [
        [
          {
            "node": "Date & Time",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send message and wait for response": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send message and wait for response1": {
      "main": [
        [
          {
            "node": "AI Agent3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}