{
  "id": "dOrj0Cw8m7nUiZOc",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "N8N MailPoet Test",
  "tags": [],
  "nodes": [
    {
      "id": "0f34145b-5db5-4e52-b962-02cf053ec86f",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -560,
        -576
      ],
      "parameters": {
        "height": 464,
        "content": "## Trigger: Form Submission\nThis node listens to your WordPress form submission.\nIt collects the following fields:\n- First Name\n- Last Name\n- Email"
      },
      "typeVersion": 1
    },
    {
      "id": "7538d4ed-08ff-4723-87f7-325e57b537b3",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -288,
        -576
      ],
      "parameters": {
        "width": 384,
        "height": 464,
        "content": "## Check Existing Subscribers\nThis node checks your Google Sheet or MailPoet API to see if the subscriber already exists.\nThis helps avoid duplicate entries in MailPoet."
      },
      "typeVersion": 1
    },
    {
      "id": "b7cef22a-f80d-44b7-9b27-0bb25d671a9d",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        128,
        -576
      ],
      "parameters": {
        "width": 864,
        "height": 464,
        "content": "## Conditional Branch: IF Node\n- If subscriber does not exist \u2192 Add subscriber via HTTP Request node\n- If subscriber exists \u2192 Skip to completion message\nThis ensures that new users are only added once.\n- Add users to subscribers \n- Logs the subscriber data into Google Sheet\n"
      },
      "typeVersion": 1
    },
    {
      "id": "f13b3492-d54f-420d-9fef-15797fc1bd97",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1024,
        -576
      ],
      "parameters": {
        "width": 304,
        "height": 464,
        "content": "## Logging & Completion\n- Sends the completion message to the user (\u201cThank you for your review!\u201d)\nOptional: Add Slack notification or email alert to the admin."
      },
      "typeVersion": 1
    },
    {
      "id": "cc21e6a3-4356-4f4e-a55e-a410922f3cfb",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -544,
        -912
      ],
      "parameters": {
        "color": 1,
        "width": 1872,
        "height": 288,
        "content": "## Workflow Overview\nThis workflow automates the full subscriber management process:\n\n1. Trigger: WordPress form submission\n2. Check if subscriber exists\n3. Add new subscriber via TWZ MailPoet API\n4. Log subscriber data to Google Sheet\n5. Optional: Notify admin via Slack\n6. Show completion message to user\n\nUse this workflow to streamline MailPoet subscriber automation."
      },
      "typeVersion": 1
    },
    {
      "id": "f4f93433-be9c-4a32-80bf-9cfe85812c62",
      "name": "On form submission",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -480,
        -272
      ],
      "parameters": {
        "options": {
          "appendAttribution": false,
          "respondWithOptions": {
            "values": {
              "redirectUrl": "https://example.com",
              "respondWith": "redirect"
            }
          }
        },
        "formTitle": "Let's Start Your Project",
        "formFields": {
          "values": [
            {
              "fieldLabel": "FIRST NAME",
              "requiredField": true
            },
            {
              "fieldLabel": "LAST NAME",
              "requiredField": true
            },
            {
              "fieldType": "email",
              "fieldLabel": "YOUR EMAIL",
              "requiredField": true
            }
          ]
        }
      },
      "notesInFlow": false,
      "typeVersion": 2.3
    },
    {
      "id": "0ad71acb-2e27-4991-85ac-d1d860d9835a",
      "name": "Check If Subscriber Already Exists",
      "type": "n8n-nodes-base.if",
      "position": [
        -32,
        -272
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "ddeb15df-3126-46e2-a671-4f3953bb0cf4",
              "operator": {
                "type": "object",
                "operation": "notExists",
                "singleValue": true
              },
              "leftValue": "",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "25738522-5d2b-478d-81cb-c711fa3b800c",
      "name": "Get Subscriber From  MailPoet",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        192,
        -352
      ],
      "parameters": {
        "url": "=http://example.com/wp-json/twz-mailpoet/v1/subscriber/{{ $json[\"YOUR EMAIL\"] }}",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpBasicAuth": {
          "name": "<your credential>"
        },
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "40aeed39-bd91-474b-9f09-bed303d68cc7",
      "name": "Check If Subscriber Exists In MailPoet",
      "type": "n8n-nodes-base.if",
      "position": [
        416,
        -352
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "2e005957-5ae4-4a45-b9ec-61577d0977be",
              "operator": {
                "type": "string",
                "operation": "notExists",
                "singleValue": true
              },
              "leftValue": "subscriber",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "ba882216-b693-4371-97c5-bb14ece26d3a",
      "name": "Add Subscriber to MailPoet",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        640,
        -416
      ],
      "parameters": {
        "url": "http://example.com/wp-json/twz-mailpoet/v1/subscribers",
        "options": {},
        "jsonBody": "={\n    \"email\": \"{{ $json[\"YOUR EMAIL\"] }}\",\n    \"first_name\": \"{{ $json[\"FIRST NAME\"] }}\",\n    \"last_name\": \"{{ $json[\"LAST NAME\"] }}\"\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "e8637c40-735a-40b8-8b74-c4a8f13fdaaa",
      "name": "Check Google Sheet for Existing Subscriber",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -256,
        -272
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {}
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1FvjhY3IsLOaB-chqUp3v8EhFdRCtND3-h5km27b4JK8",
          "cachedResultUrl": "",
          "cachedResultName": "titles"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "97254e6e-cc98-454f-8f9e-719298b0c777",
      "name": "Completion Message to User",
      "type": "n8n-nodes-base.form",
      "position": [
        1136,
        -272
      ],
      "parameters": {
        "options": {},
        "operation": "completion",
        "completionTitle": "Thank you for your review!"
      },
      "typeVersion": 1
    },
    {
      "id": "1be3ff3d-7493-49e8-bd3f-af53dd5addd1",
      "name": "Log Subscriber to Google Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        864,
        -416
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [
            {
              "id": "title",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "used",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "used",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "url",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "METATITLE",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "METATITLE",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "METADESCRIPTION",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "METADESCRIPTION",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "audio",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "audio",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1FvjhY3IsLOaB-chqUp3v8EhFdRCtND3-h5km27b4JK8",
          "cachedResultUrl": "",
          "cachedResultName": "titles"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "192b0e2f-d205-45be-9974-91173f763994",
  "connections": {
    "On form submission": {
      "main": [
        [
          {
            "node": "Check Google Sheet for Existing Subscriber",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add Subscriber to MailPoet": {
      "main": [
        [
          {
            "node": "Log Subscriber to Google Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Completion Message to User": {
      "main": [
        []
      ]
    },
    "Get Subscriber From  MailPoet": {
      "main": [
        [
          {
            "node": "Check If Subscriber Exists In MailPoet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Subscriber to Google Sheet": {
      "main": [
        [
          {
            "node": "Completion Message to User",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check If Subscriber Already Exists": {
      "main": [
        [
          {
            "node": "Get Subscriber From  MailPoet",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Completion Message to User",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check If Subscriber Exists In MailPoet": {
      "main": [
        [
          {
            "node": "Add Subscriber to MailPoet",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Completion Message to User",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Google Sheet for Existing Subscriber": {
      "main": [
        [
          {
            "node": "Check If Subscriber Already Exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}