{
  "id": "8urb5ud9FW5of1Ct",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Automated Email Blast with Follow-Ups & Response Tracking",
  "tags": [],
  "nodes": [
    {
      "id": "263d7a2a-0185-47b5-a58b-c00a0f756dcc",
      "name": "Daily Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -80,
        -485
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "d5b54189-9981-4b23-afa1-d8c2007ce94d",
      "name": "Fetch Contact Data ",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        140,
        -485
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 686562196,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1eO0pcfO3SFEofhUXjRy8Ps_XqfNpVnu5W8fwVSAy4Ds/edit#gid=686562196",
          "cachedResultName": "Sheet3"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1eO0pcfO3SFEofhUXjRy8Ps_XqfNpVnu5W8fwVSAy4Ds",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1eO0pcfO3SFEofhUXjRy8Ps_XqfNpVnu5W8fwVSAy4Ds/edit?usp=drivesdk",
          "cachedResultName": "PageRankChecker"
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "f2525c0e-4f9b-4430-a4f1-d21c18977095",
      "name": "Iterate Contacts",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        360,
        -485
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "55ff15d6-15ed-4197-b2b4-98df8695f98c",
      "name": "Determine Follow-Up Stage",
      "type": "n8n-nodes-base.if",
      "onError": "continueErrorOutput",
      "position": [
        580,
        -560
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "8533f0cb-5664-4ba3-ac35-46587194560d",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.Reply }}",
              "rightValue": "no"
            }
          ]
        }
      },
      "typeVersion": 2.2,
      "alwaysOutputData": true
    },
    {
      "id": "11f2e1b6-0f21-4d5b-aced-a4c45e29f970",
      "name": "Route by Follow-Up Stage",
      "type": "n8n-nodes-base.switch",
      "position": [
        800,
        -560
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "bde52b5f-b028-4849-acd0-fd976bbae44d",
                    "operator": {
                      "type": "number",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json['Follow-up'] }}",
                    "rightValue": 6
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "1a69881c-21ce-4cb7-9c17-f5ed0e5dd6ac",
                    "operator": {
                      "type": "number",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json['Follow-up'] }}",
                    "rightValue": 7
                  }
                ]
              }
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "2dbd64d3-ec48-4992-a25e-f665d4f04001",
      "name": "Send Follow-Up Email 1 ",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1020,
        -660
      ],
      "parameters": {
        "sendTo": "={{ $json['User Email'] }}",
        "message": "Testing-6",
        "options": {
          "appendAttribution": false
        },
        "subject": "Testing-6",
        "emailType": "text",
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "c2ed8d92-11c0-49df-87c2-191917a18a9b",
      "name": "Send Follow-Up Email 2",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1020,
        -460
      ],
      "parameters": {
        "sendTo": "={{ $json['User Email'] }}",
        "message": "Testing-7",
        "options": {
          "appendAttribution": false
        },
        "subject": "Testing-7",
        "emailType": "text",
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "715c5558-6bdb-4b8b-afc1-ae62bbf175f0",
      "name": "Update Sheet with Follow-Up Status",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1240,
        -460
      ],
      "parameters": {
        "columns": {
          "value": {
            "Reply": "={{ $('Route by Follow-Up Stage').item.json.Reply }}",
            "Follow-up": "={{ $('Route by Follow-Up Stage').item.json['Follow-up'] + 1}}",
            "Send Mail": "=yes (Follow-up = {{ $('Route by Follow-Up Stage').item.json['Follow-up'] }}) ",
            "User Name": "={{ $('Route by Follow-Up Stage').item.json['User Name'] }}",
            "Inquiry ID": "={{ $('Route by Follow-Up Stage').item.json['Inquiry ID'] }}",
            "User Email": "={{ $('Route by Follow-Up Stage').item.json['User Email'] }}",
            "Follow-up Type": "Email",
            "Submission Date": "={{ new Date($now).toISOString().split('T')[0] }}",
            "Next Follow-up Date": "={{ new Date(Date.now() + 3 * 24 * 60 * 60 * 1000).toISOString().split('T')[0] }}"
          },
          "schema": [
            {
              "id": "User Name",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "User Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "User Email",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "User Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Inquiry ID",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Inquiry ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Reply",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Reply",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Follow-up",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Follow-up",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Send Mail",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Send Mail",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Follow-up Type",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Follow-up Type",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Communication Mode",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Communication Mode",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Comment",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Comment",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Requirement Doc",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Requirement Doc",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Workflow Diagram",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Workflow Diagram",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Test Cases",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Test Cases",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Call Schedule",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Call Schedule",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Submission Date",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Submission Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Next Follow-up Date",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Next Follow-up Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "autoMapInputData",
          "matchingColumns": [
            "User Name"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 686562196,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1eO0pcfO3SFEofhUXjRy8Ps_XqfNpVnu5W8fwVSAy4Ds/edit#gid=686562196",
          "cachedResultName": "Sheet3"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1eO0pcfO3SFEofhUXjRy8Ps_XqfNpVnu5W8fwVSAy4Ds",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1eO0pcfO3SFEofhUXjRy8Ps_XqfNpVnu5W8fwVSAy4Ds/edit?usp=drivesdk",
          "cachedResultName": "PageRankChecker"
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "009b187a-a8b6-4748-bc9a-2e7dcd69f233",
      "name": "Check Email Responses",
      "type": "n8n-nodes-base.emailReadImap",
      "position": [
        -80,
        -200
      ],
      "parameters": {
        "options": {
          "customEmailConfig": "[\"UNSEEN\", [\"SUBJECT\", \"Testing\"]]"
        }
      },
      "credentials": {
        "imap": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "91e87156-bd84-4df5-ad9e-11089af50c02",
      "name": "Update Sheet with Response ",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        140,
        -200
      ],
      "parameters": {
        "columns": {
          "value": {
            "reply": "=yes",
            "user email": "={{ $json.from }}"
          },
          "schema": [
            {
              "id": "user name",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "user name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "user email",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "user email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "reply",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "reply",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "followup",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "followup",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Send mail",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Send mail",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "user email"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 686562196,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1eO0pcfO3SFEofhUXjRy8Ps_XqfNpVnu5W8fwVSAy4Ds/edit#gid=686562196",
          "cachedResultName": "Sheet3"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1eO0pcfO3SFEofhUXjRy8Ps_XqfNpVnu5W8fwVSAy4Ds",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1eO0pcfO3SFEofhUXjRy8Ps_XqfNpVnu5W8fwVSAy4Ds/edit?usp=drivesdk",
          "cachedResultName": "PageRankChecker"
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "a599605e-e3a6-412c-a221-cc73d87d7d74",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -100,
        -960
      ],
      "parameters": {
        "color": 4,
        "width": 920,
        "height": 240,
        "content": "## Node Details\n- **Daily Trigger - 9 AM**: Triggers the workflow daily at 9 AM using a Cron schedule.\n- **Read Contact Data from Google Sheet**: Reads contact data (name, email, stage) from a specified Google Sheet range.\n- **Loop Through Contacts**: Uses SplitInBatches to process each contact individually.\n- **Determine Follow-Up Stage**: Checks the contact\u2019s stage (e.g., Initial, Follow-Up 1) using an If node.\n- **Send Main/Follow-Up Email**: Sends personalized emails via Gmail based on the stage.\n- **Update Sheet Status**: Appends or updates the Google Sheet with the new status (e.g., Sent, Replied).\n- **Check Gmail for Replies**: Periodically checks Gmail for responses using an IMAP node.\n- **Log Responses**: Writes response details (e.g., timestamp, content) to the Google Sheet."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "437e7f2a-166b-487d-a269-7fc2dbebb917",
  "connections": {
    "Daily Trigger": {
      "main": [
        [
          {
            "node": "Fetch Contact Data ",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Iterate Contacts": {
      "main": [
        [],
        [
          {
            "node": "Determine Follow-Up Stage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Contact Data ": {
      "main": [
        [
          {
            "node": "Iterate Contacts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Email Responses": {
      "main": [
        [
          {
            "node": "Update Sheet with Response ",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Follow-Up Email 2": {
      "main": [
        [
          {
            "node": "Update Sheet with Follow-Up Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Follow-Up Email 1 ": {
      "main": [
        [
          {
            "node": "Update Sheet with Follow-Up Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route by Follow-Up Stage": {
      "main": [
        [
          {
            "node": "Send Follow-Up Email 1 ",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Follow-Up Email 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Determine Follow-Up Stage": {
      "main": [
        [
          {
            "node": "Route by Follow-Up Stage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a message for followup 6": {
      "main": [
        [
          {
            "node": "HRMS api for upadte inqiery data direclty in db",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a message for followup 7": {
      "main": [
        [
          {
            "node": "HRMS api for upadte inqiery data direclty in db",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Sheet with Follow-Up Status": {
      "main": [
        [
          {
            "node": "Iterate Contacts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}