{
  "id": "google-sheets-to-mailchimp",
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "name": "Google_Sheets_to_MailChimp_Subscriber_Sync",
  "tags": [
    "email-marketing",
    "mailchimp",
    "google-sheets",
    "automation"
  ],
  "nodes": [
    {
      "id": "597e03c8-f634-4b1c-add0-e98c39019603",
      "name": "Workflow Documentation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2200,
        -340
      ],
      "parameters": {
        "color": 4,
        "width": 400,
        "height": 800,
        "content": "# Google Sheets to MailChimp Sync Workflow\n\n## Features:\n- **Simple Setup**: Connect your Google Sheets and MailChimp accounts\n- **Automated Processing**: Reads contact data from your sheet\n- **Smart Parsing**: Splits full names into first and last names\n- **Field Mapping**: Maps sheet columns to MailChimp merge fields\n- **Error Handling**: Continues processing even if some contacts fail\n\n## Setup Requirements:\n1. **Google Sheets API** credentials\n2. **MailChimp API** credentials\n\n## Expected Sheet Format:\nYour Google Sheet should have these columns:\n- **Names** (Full name of the contact)\n- **Email address** (Valid email address)\n- **Phone Number** (Optional phone number)\n\n## Configuration Steps:\n1. Connect your Google Sheets account\n2. Connect your MailChimp account\n3. Select your Google Sheet and worksheet\n4. Update the MailChimp list ID in the MailChimp node\n5. Run the workflow to import your subscribers\n\n## Process Flow:\n1. Trigger workflow manually\n2. Read all rows from Google Sheet\n3. Extract and format contact data\n4. Split names into first and last names\n5. Add subscribers to MailChimp with merge fields\n6. Generate import summary"
      },
      "typeVersion": 1
    },
    {
      "id": "1bef150a-fd2b-4615-9252-81b094ef99f2",
      "name": "Edit Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        -1020,
        -340
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "bf70886e-befb-4d2e-914c-01645a18d80c",
              "name": "Names",
              "type": "string",
              "value": "={{ $json.Names }}"
            },
            {
              "id": "abea01b7-4a8f-4a57-aa9b-773a56a43bd6",
              "name": "Email address",
              "type": "string",
              "value": "={{ $json['Email address'] }}"
            },
            {
              "id": "443f7274-b0ac-46cd-8e0f-f65e21fe0dbb",
              "name": "Phone Number",
              "type": "string",
              "value": "={{ $json['Phone Number'] }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "d5d6c985-cb23-4919-9267-e57c4138fe61",
      "name": "When clicking 'Execute workflow'",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -1460,
        -340
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "2b86344d-a425-43f0-82f9-e441279ce653",
      "name": "Format Subscriber Data",
      "type": "n8n-nodes-base.code",
      "position": [
        -800,
        -340
      ],
      "parameters": {
        "jsCode": "const subscribers = [];\n\nfor (const item of $input.all()) {\n  subscribers.push({\n    json: {\n      email_address: item.json[\"Email address\"],\n      status: \"subscribed\",\n      merge_fields: {\n        FNAME: item.json.Names.split(' ')[0] || '',\n        LNAME: item.json.Names.split(' ').slice(1).join(' ') || '',\n        PHONE: item.json[\"Phone Number\"] || ''\n      }\n    }\n  });\n}\n\nreturn subscribers;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "f83a85d7-5411-48a6-9f43-b16ea14d3ea9",
      "name": "Add to MailChimp",
      "type": "n8n-nodes-base.mailchimp",
      "onError": "continueRegularOutput",
      "position": [
        -540,
        -340
      ],
      "parameters": {
        "list": "YOUR_MAILCHIMP_LIST_ID",
        "email": "={{ $node['Format Subscriber Data'].json.email_address }}",
        "status": "subscribed",
        "options": {},
        "mergeFieldsUi": {
          "mergeFieldsValues": [
            {
              "name": "FNAME",
              "value": "={{ $json.merge_fields.FNAME }}"
            },
            {
              "name": "LNAME",
              "value": "={{ $json.merge_fields.LNAME }}"
            },
            {
              "name": "PHONE",
              "value": "={{ $json.merge_fields.PHONE }}"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "1d40a00a-17f1-4ad3-9ea8-e31534f9ebae",
      "name": "Create Import Summary",
      "type": "n8n-nodes-base.set",
      "position": [
        -240,
        -340
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "summary-report",
              "name": "importSummary",
              "type": "string",
              "value": "\ud83d\udcca **MailChimp Import Summary**\n\n**Import Date:** {{ DateTime.now().toFormat('yyyy-MM-dd HH:mm:ss') }}\n**Total Processed:** {{ $items().length }} contacts\n\n**Email:** {{ $json.email_address }}\n**Status:** {{ $json.status || 'Processed' }}\n\n**Source:** Google Sheets Import"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "c33257fa-1fd0-4547-8113-0eccf826319d",
      "name": "Get Google Sheet Data",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -1240,
        -340
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "YOUR_SHEET_NAME"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "YOUR_GOOGLE_SHEET_ID"
        }
      },
      "typeVersion": 4.6
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "1.0.0",
  "connections": {
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Format Subscriber Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add to MailChimp": {
      "main": [
        [
          {
            "node": "Create Import Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Google Sheet Data": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Subscriber Data": {
      "main": [
        [
          {
            "node": "Add to MailChimp",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking 'Execute workflow'": {
      "main": [
        [
          {
            "node": "Get Google Sheet Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}