{
  "name": "GetResponse Newsletter Subscriber Template",
  "nodes": [
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        1232,
        416
      ],
      "id": "8ae1f4cc-37a7-4c02-b23d-c729a95ddfdb",
      "name": "When clicking 'Execute workflow'"
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.3,
      "position": [
        1232,
        608
      ],
      "id": "33431d34-5f65-48c5-b6bf-a3fc21652d99",
      "name": "Schedule Trigger"
    },
    {
      "parameters": {
        "jsCode": "return [{ json: { TEST_MODE: true, TEST_CONTACT_ID: '193813993616', POSSIBILITY_NO_BUDGET: 'Iptal - 0' } }];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1424,
        416
      ],
      "id": "f5eb6af4-57d3-40c7-b97c-1de293533d10",
      "name": "Config"
    },
    {
      "parameters": {
        "authentication": "appToken",
        "operation": "search",
        "filterGroupsUi": {
          "filterGroupsValues": [
            {
              "filtersUi": {
                "filterValues": [
                  {
                    "propertyName": "=hubspot_owner_id|enumeration",
                    "value": "=REPLACE_OWNER_ID"
                  },
                  {
                    "propertyName": "possibility|enumeration",
                    "operator": "NOT_HAS_PROPERTY"
                  }
                ]
              }
            }
          ]
        },
        "additionalFields": {
          "properties": [
            "firstname",
            "lastname",
            "email",
            "getresponse_added",
            "possibility",
            "num_contacted_notes",
            "do_you_have_a_budget_to_pay_university_fees_",
            "do_you_have_a_budget_to_cover_your_living_expenses",
            "what_is_your_citizenship"
          ]
        }
      },
      "type": "n8n-nodes-base.hubspot",
      "typeVersion": 2.2,
      "position": [
        1648,
        416
      ],
      "id": "8846dcb6-c283-4158-ac8f-1200252566c5",
      "name": "Search contacts",
      "credentials": {
        "hubspotAppToken": {
          "id": "REPLACE_ME",
          "name": "Add your credential"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "const config = $('Config').first().json;\nconst contacts = $input.all();\nconst notAlreadyAdded = contacts.filter((item) => {\n  const raw = String(item.json?.properties?.getresponse_added ?? '').trim().toLowerCase();\n  return !['true', '1', 'yes'].includes(raw);\n});\nif (!config.TEST_MODE) return notAlreadyAdded;\nconst testContactId = String(config.TEST_CONTACT_ID || '').trim();\nif (!testContactId) return [];\nreturn notAlreadyAdded\n  .filter((item) => String(item.json.id || '').trim() === testContactId)\n  .map((item) => ({ json: { ...item.json, test_mode: true, test_contact_id: testContactId } }));"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1856,
        416
      ],
      "id": "b25de3a6-5bcf-4919-a4cc-7c6603569b6e",
      "name": "Skip synced and apply test mode"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "879f3198-9b4e-4c02-bd6a-5f43eb491c07",
              "leftValue": "={{ String($json.properties.do_you_have_a_budget_to_pay_university_fees_ || '').trim() }}",
              "rightValue": "no_i_do_not_have_the_budget_",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            },
            {
              "id": "fbc3ce52-24ee-4581-b3df-11e912812267",
              "leftValue": "={{ String($json.properties.do_you_have_a_budget_to_cover_your_living_expenses || '').trim() }}",
              "rightValue": "no_i_do_not_have_that_budget",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        2080,
        416
      ],
      "id": "175eee0c-031b-4daa-956b-f40335ccb6f2",
      "name": "Both budget answers are no"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.getresponse.com/v3/contacts",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "getResponseApi",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "contentType": "raw",
        "rawContentType": "application/json",
        "body": "={   \"email\": \"{{ $json.properties.email }}\",   \"name\": \"{{ $json.properties.firstname }} {{ $json.properties.lastname }}\",   \"campaign\": {     \"campaignId\": \"PYe9m\"   },   \"dayOfCycle\": 0 }",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        2368,
        432
      ],
      "id": "3ff7bd70-5284-40a5-99ac-14711a44ae59",
      "name": "Add to GetResponse",
      "credentials": {
        "getResponseApi": {
          "id": "REPLACE_ME",
          "name": "Add your credential"
        }
      },
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "7382a6ff-8427-41c1-964e-d211c7c795fe",
              "leftValue": "={{ String($json.error?.description || '') }}",
              "rightValue": "Contact already added",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "or"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        2608,
        432
      ],
      "id": "5382044a-f3fb-4b5a-8ec2-154cbbaf6efd",
      "name": "Already added?"
    },
    {
      "parameters": {
        "authentication": "appToken",
        "email": "={{ $json.properties.email }}",
        "additionalFields": {
          "customPropertiesUi": {
            "customPropertiesValues": [
              {
                "property": "getresponse_added",
                "value": "true"
              }
            ]
          }
        }
      },
      "type": "n8n-nodes-base.hubspot",
      "typeVersion": 2.2,
      "position": [
        2848,
        432
      ],
      "id": "663ceaf1-07bb-4495-a215-8ba6c31a9fb8",
      "name": "Mark GetResponse added",
      "credentials": {
        "hubspotAppToken": {
          "id": "REPLACE_ME",
          "name": "Add your credential"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "d8bc53f3-45c2-4814-90f5-d8a90b5abaca",
              "name": "contact_id",
              "value": "={{ String($json.id || $json.vid || $json.properties?.hs_object_id || '') }}",
              "type": "string"
            },
            {
              "id": "19fa4d1c-f7b9-4536-b0f2-9356ec8eb5a6",
              "name": "email",
              "value": "={{ String($json.properties?.email?.value || $json.properties?.email || $json.email || '') }}",
              "type": "string"
            },
            {
              "id": "5bb42fd8-8df1-4ed2-9f25-37dc3517d207",
              "name": "firstname",
              "value": "={{ String($json.properties?.firstname?.value || $json.properties?.firstname || $json.firstname || '') }}",
              "type": "string"
            },
            {
              "id": "4f7585b1-b7e6-4184-a400-050877525f17",
              "name": "lastname",
              "value": "={{ String($json.properties?.lastname?.value || $json.properties?.lastname || $json.lastname || '') }}",
              "type": "string"
            },
            {
              "id": "fcbcb339-85a1-464f-a0c5-c8dfd31ee692",
              "name": "getresponse_added",
              "value": "true",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        3088,
        432
      ],
      "id": "ae81f8a5-1cc7-413d-8dd6-4ad7f1fbb586",
      "name": "Trim output"
    }
  ],
  "pinData": {},
  "connections": {
    "When clicking 'Execute workflow'": {
      "main": [
        [
          {
            "node": "Config",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Config",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Config": {
      "main": [
        [
          {
            "node": "Search contacts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search contacts": {
      "main": [
        [
          {
            "node": "Skip synced and apply test mode",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Skip synced and apply test mode": {
      "main": [
        [
          {
            "node": "Both budget answers are no",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Both budget answers are no": {
      "main": [
        [],
        [
          {
            "node": "Add to GetResponse",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add to GetResponse": {
      "main": [
        [
          {
            "node": "Already added?",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Already added?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Already added?": {
      "main": [
        [
          {
            "node": "Mark GetResponse added",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Mark GetResponse added",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mark GetResponse added": {
      "main": [
        [
          {
            "node": "Trim output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false
  },
  "versionId": "f8ba113c-85a6-4708-abae-477d2f968eae",
  "meta": {
    "instanceId": "38c984ab3c887cf0a803e31f65e2a86ba2641bf95d08f3130b66e0f79af98e81"
  },
  "id": "QZj9iv1sao5gpO0S",
  "tags": []
}
