{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "e401f569-314d-44ff-b95c-afdb58b478a3",
      "name": "Delete contact",
      "type": "n8n-nodes-klicktipp.klicktipp",
      "notes": "This node deletes the according contact in KlickTipp.",
      "position": [
        5344,
        1520
      ],
      "parameters": {
        "resource": "subscriber",
        "operation": "delete",
        "lookupEmail": "={{ $('Changes in Pipedrive1').item.json.previous.emails[0].value }}"
      },
      "credentials": {
        "klickTippApi": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": true,
      "typeVersion": 3,
      "alwaysOutputData": true
    },
    {
      "id": "48b7dfa3-8206-4dd4-a534-f30be14a6111",
      "name": "Contact tagged in KlickTipp",
      "type": "n8n-nodes-klicktipp.klicktippTrigger",
      "notes": "This node triggers when a webhook is executed in a KlickTipp campaign or via the activation Tag.\n\nHey I am a KlickTipp Link to a webhook \u2192 ",
      "position": [
        4224,
        448
      ],
      "parameters": {
        "path": "0b382f31-c74b-4418-bb89-caaa09915282"
      },
      "credentials": {
        "klickTippApi": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": true,
      "typeVersion": 1
    },
    {
      "id": "b3a469af-8724-4586-a88d-5312025e829b",
      "name": "Create a person",
      "type": "n8n-nodes-base.pipedrive",
      "notes": "This node creates a contact in Pipedrive if it did not exist before.",
      "position": [
        5344,
        288
      ],
      "parameters": {
        "name": "={{ $('Contact tagged in KlickTipp').item.json.fullname }}",
        "resource": "person",
        "additionalFields": {
          "email": [
            "={{ $('Contact tagged in KlickTipp').item.json.email }}"
          ],
          "phone": [
            "={{ $('Contact tagged in KlickTipp').item.json.fieldMobilePhone }}"
          ],
          "customProperties": {
            "property": [
              {
                "name": "6924b0cdabee707d314eb4c5490812112250f72c",
                "value": "={{\n(() => {\n  // Read birthday Unix timestamp (seconds) from current item\n  const birthdayTs = $json.fieldBirthday;\n\n  // If birthday is missing / null / empty \u2192 return empty string\n  if (!birthdayTs) {\n    return \"\";\n  }\n\n  // Convert Unix timestamp (seconds) \u2192 milliseconds\n  const date = new Date(birthdayTs * 1000);\n\n  // Format as YYYY-MM-DD using a locale that enforces this format\n  // and apply Europe/Berlin timezone (handles CET / CEST automatically)\n  return date.toLocaleDateString('en-CA', {\n    timeZone: 'Europe/Berlin',\n  });\n})()\n}}"
              },
              {
                "name": "19b905eba214f66b11571a1a0827d3a974cd0b2b",
                "value": "={{ $('Contact tagged in KlickTipp').item.json.id }}"
              },
              {
                "name": "95f97718036275e2013646b2c7dfb96462e17a94",
                "value": "={{\n  $('Contact tagged in KlickTipp').item.json.status === 'Subscribed'\n    ? 29\n    : 28\n}}"
              },
              {
                "name": "e53c2563a1b9d108535d55c14b4ea23ef27e6e97",
                "value": "KlickTipp"
              }
            ]
          }
        }
      },
      "credentials": {
        "pipedriveApi": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": true,
      "typeVersion": 1
    },
    {
      "id": "527e72de-be34-4519-a110-32e75a5eb4a8",
      "name": "Update a person",
      "type": "n8n-nodes-base.pipedrive",
      "notes": "This node updates the contact in case it exists already in Pipedrive.",
      "position": [
        5344,
        464
      ],
      "parameters": {
        "personId": "={{ $('Get contact data for tagging').item.json.field227685 }}",
        "resource": "person",
        "operation": "update",
        "updateFields": {
          "name": "={{ $('Contact tagged in KlickTipp').item.json.fullname }}",
          "email": [
            "={{ $('Contact tagged in KlickTipp').item.json.email }}"
          ],
          "customProperties": {
            "property": [
              {
                "name": "95cac42f721633965550204f2604728aad5844bf",
                "value": "={{\n  // Convert Unix timestamp (seconds) to milliseconds and create a Date object\n  new Date(\n    $('Contact tagged in KlickTipp').item.json.fieldBirthday * 1000\n  )\n    // Format the date as YYYY-MM-DD using a locale that enforces this format\n    // and apply the Europe/Berlin timezone (handles CET/CEST automatically)\n    .toLocaleDateString('en-CA', { timeZone: 'Europe/Berlin' })\n}}"
              },
              {
                "name": "7effe3f5fcf6d3f8e059ce4fedde89be0122ddac",
                "value": "={{ $('Contact tagged in KlickTipp').item.json.id }}"
              },
              {
                "name": "eacea8b67518c4b50fef84ac07c3b939a3ad5abf",
                "value": "={{\n  $('Contact tagged in KlickTipp').item.json.status === 'Subscribed'\n    ? 29\n    : 28\n}}"
              }
            ]
          }
        }
      },
      "credentials": {
        "pipedriveApi": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": true,
      "typeVersion": 1
    },
    {
      "id": "cedb091a-6770-44e8-92f8-37c3c3199303",
      "name": "Update contact changes in KlickTipp",
      "type": "n8n-nodes-klicktipp.klicktipp",
      "notes": "This node brings the changes on the contact from Pipedrive to KlickTipp.",
      "position": [
        5344,
        1296
      ],
      "parameters": {
        "email": "={{ $('Changes in Pipedrive1').item.json.data.emails[0].value }}",
        "fields": {
          "dataFields": [
            {
              "fieldId": "fieldFirstName",
              "fieldValue": "={{ $('Changes in Pipedrive1').item.json.data.first_name }}"
            },
            {
              "fieldId": "fieldLastName",
              "fieldValue": "={{ $('Changes in Pipedrive1').item.json.data.last_name }}"
            },
            {
              "fieldId": "fieldBirthday",
              "fieldValue": "={{\n  (() => {\n    // Read birthday from the custom field\n    // Expected format: YYYY-MM-DD\n    const bday =\n      $('Changes in Pipedrive1').item.json.data.custom_fields[\"95cac42f721633965550204f2604728aad5844bf\"]?.value;\n\n    // If the birthday does not exist, return null\n    // \u2192 n8n will treat this as an empty value\n    if (!bday) {\n      return \"\";\n    }\n    // Convert birthday to a Unix timestamp (seconds)\n    // \"T00:00:00Z\" forces UTC midnight to avoid timezone day shifts\n    return Math.floor(\n      Date.parse(bday + \"T00:00:00Z\") / 1000\n    );\n  })()\n}}"
            },
            {
              "fieldId": "field227685",
              "fieldValue": "={{ $('Changes in Pipedrive1').item.json.data.id }}"
            }
          ]
        },
        "resource": "subscriber",
        "operation": "update",
        "subscriberId": "={{ $('Changes in Pipedrive1').item.json.data.custom_fields[\"7effe3f5fcf6d3f8e059ce4fedde89be0122ddac\"].value }}",
        "identifierType": "id"
      },
      "credentials": {
        "klickTippApi": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": true,
      "typeVersion": 3
    },
    {
      "id": "7cffadf2-546e-41cc-86ac-34bf8b5fca22",
      "name": "Create contact with DOI",
      "type": "n8n-nodes-klicktipp.klicktipp",
      "notes": "This node brings the changes on the contact or the new contact creation from Pipedrive to KlickTipp.",
      "position": [
        5344,
        1088
      ],
      "parameters": {
        "email": "={{ $('Changes in Pipedrive1').item.json.data.emails[0].value }}",
        "tagId": "14029585",
        "fields": {
          "dataFields": [
            {
              "fieldId": "fieldFirstName",
              "fieldValue": "={{ $('Changes in Pipedrive1').item.json.data.first_name }}"
            },
            {
              "fieldId": "fieldLastName",
              "fieldValue": "={{ $('Changes in Pipedrive1').item.json.data.last_name }}"
            },
            {
              "fieldId": "field227685",
              "fieldValue": "={{ $('Changes in Pipedrive1').item.json.data.id }}"
            }
          ]
        },
        "listId": "358895",
        "resource": "subscriber",
        "operation": "subscribe"
      },
      "credentials": {
        "klickTippApi": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": true,
      "typeVersion": 3
    },
    {
      "id": "ad611a93-6e92-4fe7-be92-68fd6686a45f",
      "name": "Tag contact in KlickTipp2",
      "type": "n8n-nodes-klicktipp.klicktipp",
      "notes": "This node adds the contact to the according segment.",
      "position": [
        6320,
        1216
      ],
      "parameters": {
        "email": "={{ $('Changes in Pipedrive1').item.json.data.emails[0].value }}",
        "tagId": [
          "14054258"
        ],
        "resource": "contact-tagging"
      },
      "credentials": {
        "klickTippApi": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": true,
      "typeVersion": 3
    },
    {
      "id": "c57ab268-dfae-40f6-b60c-16268c8d2206",
      "name": "Tag contact in KlickTipp3",
      "type": "n8n-nodes-klicktipp.klicktipp",
      "notes": "This node adds the contact to the according segment.",
      "position": [
        6320,
        1392
      ],
      "parameters": {
        "email": "={{ $('Changes in Pipedrive1').item.json.data.emails[0].value }}",
        "tagId": [
          "14054294"
        ],
        "resource": "contact-tagging"
      },
      "credentials": {
        "klickTippApi": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": true,
      "typeVersion": 3
    },
    {
      "id": "b855f37c-f31c-4abe-9c14-0c34f4f3a4a2",
      "name": "Check relevant segment2",
      "type": "n8n-nodes-base.switch",
      "notes": "This node checks the Pipedrive Labels for Segmentation in KlickTipp via Tags.",
      "position": [
        6064,
        1296
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Label Customer exists. and Label ABC not",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "156126c5-016a-4cdc-845e-4ab6d0ecccc7",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": "={{\n(() => {\n  // Read label IDs from \"Changes in Pipedrive\"\n  // Can be either:\n  // - string like \"14,27\"\n  // - array like [14, 27]\n  const raw = $('Changes in Pipedrive1').item.json.data.label_ids ?? [];\n\n  // Normalize to array of numbers\n  const labelIds = Array.isArray(raw)\n    ? raw.map(Number)\n    : String(raw)\n        .split(',')\n        .map(s => Number(s.trim()))\n        .filter(n => !Number.isNaN(n));\n\n  // TRUE if label 14 is present\n  return labelIds.includes(14);\n})()\n}}",
                    "rightValue": "=14"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Label ABC exists and Label Customer not",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "a7a8d286-2311-4534-8cf9-ae1dca366cb7",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": "={{\n(() => {\n  // Read label IDs from \"Changes in Pipedrive\"\n  // Can be either:\n  // - string like \"14,27\"\n  // - array like [14, 27]\n  const raw = $('Changes in Pipedrive1').item.json.data.label_ids ?? [];\n\n  // Normalize to array of numbers\n  const labelIds = Array.isArray(raw)\n    ? raw.map(Number)\n    : String(raw)\n        .split(',')\n        .map(s => Number(s.trim()))\n        .filter(n => !Number.isNaN(n));\n\n  // TRUE if label 27 is present\n  return labelIds.includes(27);\n})()\n}}",
                    "rightValue": "27"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "allMatchingOutputs": true
        }
      },
      "notesInFlow": true,
      "typeVersion": 3.4
    },
    {
      "id": "2552714b-97dd-4e05-a8d8-3bcc36fa8de2",
      "name": "Add Pipedrive Person ID to KlickTipp contact",
      "type": "n8n-nodes-klicktipp.klicktipp",
      "notes": "This node saves the Salesforce ID inside of KlickTipp to facilitate further synchronisation.",
      "position": [
        5808,
        288
      ],
      "parameters": {
        "fields": {
          "dataFields": [
            {
              "fieldId": "field227685",
              "fieldValue": "={{ $json.id }}"
            }
          ]
        },
        "resource": "subscriber",
        "operation": "update",
        "lookupEmail": "={{ $('Contact tagged in KlickTipp').item.json.email }}"
      },
      "credentials": {
        "klickTippApi": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": true,
      "typeVersion": 3
    },
    {
      "id": "8beb736d-1434-4791-be62-c4c24e6ab8dc",
      "name": "Get contact data for tagging",
      "type": "n8n-nodes-klicktipp.klicktipp",
      "notes": "This node fetches the contact in order to get details to process the Tags.",
      "position": [
        4448,
        448
      ],
      "parameters": {
        "resource": "subscriber",
        "operation": "get",
        "subscriberId": "={{ $('Contact tagged in KlickTipp').item.json.id }}",
        "identifierType": "id"
      },
      "credentials": {
        "klickTippApi": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": true,
      "typeVersion": 3
    },
    {
      "id": "19cb572c-0d6a-4aa8-af0c-697f46c752aa",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4176,
        176
      ],
      "parameters": {
        "color": 7,
        "width": 432,
        "height": 1792,
        "content": "## 1. Get contact data."
      },
      "typeVersion": 1
    },
    {
      "id": "5f86dbab-479c-4eab-9970-5738f0f88b9b",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4624,
        176
      ],
      "parameters": {
        "color": 7,
        "width": 304,
        "height": 1792,
        "content": "## 2. Route by subscription."
      },
      "typeVersion": 1
    },
    {
      "id": "9c5b6b0e-68b5-4532-a148-04c0026fe84d",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4944,
        176
      ],
      "parameters": {
        "color": 7,
        "width": 272,
        "height": 1792,
        "content": "## 3. Filter contacts."
      },
      "typeVersion": 1
    },
    {
      "id": "153bc030-88d3-451a-8389-7767ddf16ba0",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5232,
        176
      ],
      "parameters": {
        "color": 7,
        "width": 304,
        "height": 1792,
        "content": "## 4. Transfer contact data."
      },
      "typeVersion": 1
    },
    {
      "id": "c26166c7-2fed-4398-8fcd-51920ac053a7",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5552,
        176
      ],
      "parameters": {
        "color": 7,
        "width": 400,
        "height": 1792,
        "content": "## 5. Save contact ID or subscription status\n"
      },
      "typeVersion": 1
    },
    {
      "id": "f0bc0849-c2ae-4b31-b0ed-601faa0fdf00",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5968,
        176
      ],
      "parameters": {
        "color": 7,
        "width": 544,
        "height": 1792,
        "content": "## 6. Segmentation."
      },
      "typeVersion": 1
    },
    {
      "id": "fe8ec5ef-1f4c-4450-95b9-982e427a2622",
      "name": "Get marketing status",
      "type": "n8n-nodes-base.pipedrive",
      "notes": "Get the marketing status to decide which status to use in KlickTipp.",
      "onError": "continueRegularOutput",
      "position": [
        4448,
        1280
      ],
      "parameters": {
        "personId": "={{ $json.data.id }}",
        "resource": "person",
        "operation": "get"
      },
      "credentials": {
        "pipedriveApi": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": true,
      "typeVersion": 1
    },
    {
      "id": "e8cd2cf2-12d5-4b20-ba01-6cee32fcd0ba",
      "name": "Create contact with SOI",
      "type": "n8n-nodes-klicktipp.klicktipp",
      "notes": "This node brings the changes on the contact or the new contact creation from Pipedrive to KlickTipp.",
      "position": [
        5344,
        880
      ],
      "parameters": {
        "email": "={{ $('Changes in Pipedrive1').item.json.data.emails[0].value }}",
        "tagId": "14029585",
        "fields": {
          "dataFields": [
            {
              "fieldId": "fieldFirstName",
              "fieldValue": "={{ $('Changes in Pipedrive1').item.json.data.first_name }}"
            },
            {
              "fieldId": "fieldLastName",
              "fieldValue": "={{ $('Changes in Pipedrive1').item.json.data.last_name }}"
            },
            {
              "fieldId": "fieldBirthday",
              "fieldValue": "={{\n  (() => {\n    // Read birthday from the custom field\n    // Expected format: YYYY-MM-DD\n    const bday =\n      $('Changes in Pipedrive1').item.json.data.custom_fields[\"95cac42f721633965550204f2604728aad5844bf\"]?.value;\n\n    // If the birthday does not exist, return null\n    // \u2192 n8n will treat this as an empty value\n    if (!bday) {\n      ;\nreturn \"\"\n    }\n    // Convert birthday to a Unix timestamp (seconds)\n    // \"T00:00:00Z\" forces UTC midnight to avoid timezone day shifts\n    return Math.floor(\n      Date.parse(bday + \"T00:00:00Z\") / 1000\n    );\n  })()\n}}"
            },
            {
              "fieldId": "field227685",
              "fieldValue": "={{ $('Changes in Pipedrive1').item.json.data.id }}"
            }
          ]
        },
        "listId": "364353",
        "resource": "subscriber",
        "operation": "subscribe"
      },
      "credentials": {
        "klickTippApi": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": true,
      "typeVersion": 3
    },
    {
      "id": "22703157-fc36-4010-bc9e-daf6bdc99429",
      "name": "Changes in Pipedrive1",
      "type": "n8n-nodes-base.pipedriveTrigger",
      "position": [
        4224,
        1280
      ],
      "parameters": {
        "entity": "person"
      },
      "credentials": {
        "pipedriveApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "b69f68e1-55cf-4db8-9bbc-6934562b743e",
      "name": "Sticky Note13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3440,
        176
      ],
      "parameters": {
        "width": 727,
        "height": 2284,
        "content": "Community Node Disclaimer: This workflow uses KlickTipp community nodes.\n\n## Introduction\nThis workflow creates a complete two-way synchronization between **KlickTipp** and **Pipedrive (Persons)**.  \nWhenever a Person is created, updated, unsubscribed, segmented, or deleted in either system, the workflow mirrors these changes across both platforms \u2014 so your CRM and email marketing database always stay aligned.\n\nIt\u2019s built for near real-time syncing of contact profiles, consent/marketing status, and segmentation (Tags \u2194 Labels), without manual updates or CSV imports.\n\n## How it works\n\n### KlickTipp \u2192 Pipedrive\nTriggered by **KlickTipp webhooks / tagging events** (\u201cContact tagged in KlickTipp\u201d):\n- Fetches the full KlickTipp contact to evaluate tags and fields.\n- Routes by whether the Pipedrive Person already exists (based on stored Pipedrive ID in KlickTipp).\n  - **Person does not exist (and not Unsubscribed)** \u2192 creates the Person in Pipedrive.\n  - **Person exists (and not Unsubscribed)** \u2192 updates the Person in Pipedrive.\n  - **Person exists \u2192 unsubscribe** \u2192 updates the Person in Pipedrive and sets the custom field value of the `KlickTipp marketing_status = unsubscribed`.\n- Writes the **Pipedrive Person ID** back into KlickTipp (custom field) to permanently link both records.\n- Mirrors consent status:\n  - KlickTipp `status = Subscribed` \u2192 Pipedrive `marketing_status = subscribed`\n  - otherwise \u2192 Pipedrive `marketing_status = no_consent`\n- Handles birthday mapping from KlickTipp (Unix seconds) to Pipedrive date:\n  - Converts timestamp \u2192 YYYY-MM-DD using `Europe/Berlin` timezone to avoid CET/CEST shifts.\n\n### Pipedrive \u2192 KlickTipp\nTriggered by the **Pipedrive Person webhook** (\u201cChanges in Pipedrive\u201d):\n1) Fetches the Person (\u201cGet marketing status\u201d) to read the current `marketing_status`.\n2) Routes logic via \u201cCheck subscription1\u201d:\n- **Single Opt-In**  \n  If no linked KlickTipp ID exists yet \u2192 create in KlickTipp via **SOI** (UI changes only).\n- **Update only**  \n  If linked KlickTipp ID exists \u2192 update in KlickTipp.\n- **Form submission \u2192 DOI**  \n  If the change source is `api` \u2192 create in KlickTipp via **DOI**.\n- **Contact deletion**  \n  If action is `delete` \u2192 delete contact in KlickTipp using the **previous email** (safe if email changed).\n\nUI-only filtering:\n- The \u201cFilter non UI events and deletions\u201d node ensures the SOI create path only processes UI-driven changes (`change_source = app`) and ignores deletions.\n\nBirthday mapping from Pipedrive to KlickTipp:\n- Reads birthday from a Pipedrive custom field (YYYY-MM-DD) and converts to Unix seconds using `\"T00:00:00Z\"` to prevent day shifting.\n\n### Segmentation: Tags \u2194 Labels\n- **KlickTipp Tags \u2192 Pipedrive Labels**  \n  Checks KlickTipp `tags` and assigns Pipedrive labels via PATCH:\n  - Tag `14054258` \u2192 Label `14` (Customer)\n  - Tag `14054294` \u2192 Label `27` (ABC)\n- **Pipedrive Labels \u2192 KlickTipp Tags**  \n  Reads `label_ids` from Pipedrive (supports array or comma-string), normalizes, then applies tags:\n  - Label `14` \u2192 Tag `14054258`\n  - Label `27` \u2192 Tag `14054294`\n\n### GDPR Deletion Requests (KlickTipp \u2192 Pipedrive)\nTriggered by **\u201cContact deletion request triggered\u201d** (when a recipient clicks the data deletion link in an email):\n\n- Immediately deletes the subscriber in **KlickTipp**.\n- If a linked **Pipedrive Person ID** exists (`field227685`), the workflow:\n  - Deletes the corresponding Person in **Pipedrive**.\n- If no Pipedrive ID exists, only the KlickTipp record is removed.\n\nThis ensures full GDPR-compliant data removal across both systems.\n\n## Setup Instructions\n\n### 1) KlickTipp Preparation\n- Create a **custom field** to store the Pipedrive reference:\n  - `Pipedrive | Person ID` (e.g. mapped to `field227685` in this workflow)\n- Create Tags for segmentation (matching the mapping you want):\n  - Example: Customer / ABC tags used here.\n- Configure a webhook/activation tag to trigger \u201cContact tagged in KlickTipp\u201d if you want KlickTipp \u2192 Pipedrive updates via campaigns.\n\n### 2) Pipedrive Preparation\n- Create custom fields (Person) to store:\n  - `KlickTipp ID` (stored in the workflow via a custom property)\n  - Birthday (optional, if you store birthday in a custom field)\n- Create / configure Labels and note their IDs:\n  - Example: Label 14 = Customer, Label 27 = ABC\n- Create a webhook for Person events (create/update/delete).\n\n### 3) Credential Configuration\n- Connect your **Pipedrive** account (API token / OAuth depending on your setup).\n- Connect your **KlickTipp** account (API credentials required).\n\n## Customization\n- Extend mapping nodes with more fields (phone, address, organization, additional custom properties).\n- Adjust SOI/DOI routing (e.g. use DOI more broadly if required).\n- Add additional segmentation branches for further Labels/Tags.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "29a1e84b-8816-4206-a566-090bcfdb8dd1",
      "name": "Filter non UI events and deletions",
      "type": "n8n-nodes-base.filter",
      "notes": "This node filters the deletions and the form submissions to only process data from the webhook that was created via the UI.",
      "position": [
        5040,
        880
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "26dcbf80-75a3-4614-bdca-47e2c4f519bc",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $('Changes in Pipedrive1').item.json.meta.change_source }}",
              "rightValue": "app"
            },
            {
              "id": "c5b82b4f-784c-4f55-b7d7-4a29f896d28b",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              },
              "leftValue": "={{ $('Changes in Pipedrive1').item.json.meta.action }}",
              "rightValue": "delete"
            }
          ]
        }
      },
      "notesInFlow": true,
      "typeVersion": 2.3
    },
    {
      "id": "f22cd785-eb7c-49af-ab7e-da28aca5a05c",
      "name": "Check subscription",
      "type": "n8n-nodes-base.switch",
      "notes": "This node checks the KlickTipp subscription status.",
      "position": [
        4720,
        448
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Person does not exist",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "156126c5-016a-4cdc-845e-4ab6d0ecccc7",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": "={{ !$json.field227685 }}",
                    "rightValue": "14054258"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Person exists",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "a7a8d286-2311-4534-8cf9-ae1dca366cb7",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": "={{ !!$json.field227685 }}",
                    "rightValue": "14054294"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "allMatchingOutputs": false
        }
      },
      "notesInFlow": true,
      "typeVersion": 3.4
    },
    {
      "id": "7400e461-730e-4281-8a5f-4b2acc3389ab",
      "name": "Check subscription1",
      "type": "n8n-nodes-base.switch",
      "notes": "This node checks the KlickTipp subscription status.",
      "position": [
        4720,
        1248
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Single Opt-In",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "156126c5-016a-4cdc-845e-4ab6d0ecccc7",
                    "operator": {
                      "type": "string",
                      "operation": "notExists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json['7effe3f5fcf6d3f8e059ce4fedde89be0122ddac'] }}",
                    "rightValue": "subscribed"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Form submission \u2192 DOI",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "976c1de1-4a7b-4ee6-b8c2-dd441f535a4d",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Changes in Pipedrive1').item.json.meta.change_source }}",
                    "rightValue": "api"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Update only",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "b5fccc04-f234-478a-9caf-b4b08ea7036d",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json['7effe3f5fcf6d3f8e059ce4fedde89be0122ddac'] }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Contact deletion",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "5e12b277-f9fe-4eda-816c-b629bf7b6ccb",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Changes in Pipedrive1').item.json.meta.action }}",
                    "rightValue": "delete"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "allMatchingOutputs": true
        }
      },
      "notesInFlow": true,
      "typeVersion": 3.4
    },
    {
      "id": "92eaca10-3d9c-4c9f-9aff-0f19b2c43c0c",
      "name": "Check relevant segment",
      "type": "n8n-nodes-base.switch",
      "notes": "This node checks the Pipedrive Labels for Segmentation in KlickTipp via Tags.",
      "position": [
        6064,
        464
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Label Customer exists and Label ABC not",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "156126c5-016a-4cdc-845e-4ab6d0ecccc7",
                    "operator": {
                      "type": "array",
                      "operation": "contains",
                      "rightType": "any"
                    },
                    "leftValue": "={{ $('Get contact data for tagging').item.json.tags }}",
                    "rightValue": "=14054258"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Label ABC exists and Label Customer not",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "a7a8d286-2311-4534-8cf9-ae1dca366cb7",
                    "operator": {
                      "type": "array",
                      "operation": "contains",
                      "rightType": "any"
                    },
                    "leftValue": "={{ $('Get contact data for tagging').item.json.tags }}",
                    "rightValue": "14054294"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "allMatchingOutputs": true
        }
      },
      "notesInFlow": true,
      "typeVersion": 3.4
    },
    {
      "id": "259372f5-b7e3-46f2-b6bf-f65241783121",
      "name": "Assign Label Customer",
      "type": "n8n-nodes-base.httpRequest",
      "notes": "This node segments the contact in Pipedrive by setting the according Labels.",
      "position": [
        6320,
        384
      ],
      "parameters": {
        "url": "=https://klicktipp3.pipedrive.com/api/v2/persons/{{ $('Contact tagged in KlickTipp').item.json.field227685 ? $('Contact tagged in KlickTipp').item.json.field227685 : $('Create a person').item.json.id }}",
        "method": "PATCH",
        "options": {},
        "jsonBody": "{\"label_ids\":[14]}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "pipedriveApi"
      },
      "credentials": {
        "pipedriveApi": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": true,
      "typeVersion": 4.3
    },
    {
      "id": "b8ca26d5-0acd-4bae-9c7e-48f2e735c91f",
      "name": "Assign Label ABC",
      "type": "n8n-nodes-base.httpRequest",
      "notes": "This node segments the contact in Pipedrive by setting the according Labels.",
      "position": [
        6320,
        560
      ],
      "parameters": {
        "url": "=https://klicktipp3.pipedrive.com/api/v2/persons/{{ $('Contact tagged in KlickTipp').item.json.field227685 ? $('Contact tagged in KlickTipp').item.json.field227685 : $('Create a person').item.json.id }}",
        "method": "PATCH",
        "options": {},
        "jsonBody": "{\"label_ids\":[27]}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "pipedriveApi"
      },
      "credentials": {
        "pipedriveApi": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": true,
      "typeVersion": 4.3
    },
    {
      "id": "b714eaf0-728e-417a-bafd-8807e59ffdd2",
      "name": "Add KlickTipp contact ID to Pipedrive",
      "type": "n8n-nodes-base.pipedrive",
      "notes": "This node updates the contact in case it exists already in Pipedrive.",
      "position": [
        5808,
        880
      ],
      "parameters": {
        "personId": "={{ $('Changes in Pipedrive1').item.json.data.id }}",
        "resource": "person",
        "operation": "update",
        "updateFields": {
          "customProperties": {
            "property": [
              {
                "name": "7effe3f5fcf6d3f8e059ce4fedde89be0122ddac",
                "value": "={{ $json.id }}"
              },
              {
                "name": "eacea8b67518c4b50fef84ac07c3b939a3ad5abf",
                "value": "29"
              }
            ]
          }
        }
      },
      "credentials": {
        "pipedriveApi": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": true,
      "typeVersion": 1
    },
    {
      "id": "59b086ee-0f03-48a6-825d-f33353cb74ec",
      "name": "Add KlickTipp contact ID to Pipedrive1",
      "type": "n8n-nodes-base.pipedrive",
      "notes": "This node updates the contact in case it exists already in Pipedrive.",
      "position": [
        5808,
        1088
      ],
      "parameters": {
        "personId": "={{ $('Changes in Pipedrive1').item.json.data.id }}",
        "resource": "person",
        "operation": "update",
        "updateFields": {
          "customProperties": {
            "property": [
              {
                "name": "7effe3f5fcf6d3f8e059ce4fedde89be0122ddac",
                "value": "={{ $json.id }}"
              },
              {
                "name": "eacea8b67518c4b50fef84ac07c3b939a3ad5abf",
                "value": "28"
              }
            ]
          }
        }
      },
      "credentials": {
        "pipedriveApi": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": true,
      "typeVersion": 1
    },
    {
      "id": "e63ecf2c-338d-407e-be36-0202b87a47da",
      "name": "Tag contact for first transactional mail",
      "type": "n8n-nodes-klicktipp.klicktipp",
      "notes": "This node adds the contact to the according segment.",
      "position": [
        6320,
        880
      ],
      "parameters": {
        "email": "={{ $('Changes in Pipedrive1').item.json.data.emails[0].value }}",
        "tagId": [
          "14152568"
        ],
        "resource": "contact-tagging"
      },
      "credentials": {
        "klickTippApi": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": true,
      "typeVersion": 3
    },
    {
      "id": "a008f32f-b662-4ef4-bf26-f9ab3ad9fd6f",
      "name": "Contact deletion request triggered",
      "type": "n8n-nodes-klicktipp.klicktippTrigger",
      "notes": "This node is triggered when a recipient of an email is clicking on the unsubscription link and requesting the deletion of data.",
      "position": [
        4224,
        1760
      ],
      "parameters": {},
      "credentials": {
        "klickTippApi": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": true,
      "typeVersion": 1
    },
    {
      "id": "813abb15-038e-4c31-bf3a-e4de5292629b",
      "name": "Only delete Pipedrive contacts",
      "type": "n8n-nodes-base.filter",
      "notes": "This node filters out all non Pipedrive deletion requests.",
      "position": [
        5024,
        1760
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "fd5e83c0-d61e-459f-9420-45ecbc7fbfe8",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $json.field227685 }}",
              "rightValue": ""
            }
          ]
        }
      },
      "notesInFlow": true,
      "typeVersion": 2.3
    },
    {
      "id": "a83c59c2-946f-4477-a826-e11a4ada91d3",
      "name": "Delete contact1",
      "type": "n8n-nodes-base.pipedrive",
      "notes": "This node deletes the contact that has requested the deletion via KlickTipp in Pipedrive.",
      "position": [
        5344,
        1760
      ],
      "parameters": {
        "personId": "={{ $('Contact deletion request triggered').item.json.field227685 }}",
        "resource": "person",
        "operation": "delete"
      },
      "credentials": {
        "pipedriveApi": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": true,
      "typeVersion": 1
    },
    {
      "id": "b7810884-759c-441e-b83f-2546ece5a438",
      "name": "Get subscription status",
      "type": "n8n-nodes-klicktipp.klicktipp",
      "notes": "This node fetches the KlickTipp subscription status.",
      "position": [
        5600,
        1296
      ],
      "parameters": {
        "resource": "subscriber",
        "operation": "get",
        "subscriberId": "={{ $('Changes in Pipedrive1').item.json.data.custom_fields[\"7effe3f5fcf6d3f8e059ce4fedde89be0122ddac\"].value }}",
        "identifierType": "id"
      },
      "credentials": {
        "klickTippApi": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": true,
      "typeVersion": 3
    },
    {
      "id": "3a7cd6ca-7710-46e3-a569-60513bbd96e5",
      "name": "Add KlickTipp subscription status to Pipedrive",
      "type": "n8n-nodes-base.pipedrive",
      "notes": "This node updates the contact in case it exists already in Pipedrive.",
      "position": [
        5808,
        1296
      ],
      "parameters": {
        "personId": "={{ $('Changes in Pipedrive1').item.json.data.id }}",
        "resource": "person",
        "operation": "update",
        "updateFields": {
          "customProperties": {
            "property": [
              {
                "name": "eacea8b67518c4b50fef84ac07c3b939a3ad5abf",
                "value": "={{\n/*\n Map contact status to numeric ID\n Opt-In Pending \u2192 28\n Subscribed     \u2192 29\n Unsubscribed   \u2192 30\n*/\n\n$json.status === 'Opt-In Pending' ? 28 :\n$json.status === 'Subscribed' ? 29 :\n$json.status === 'Unsubscribed' ? 30 :\nnull\n}}"
              }
            ]
          }
        }
      },
      "credentials": {
        "pipedriveApi": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": true,
      "typeVersion": 1
    },
    {
      "id": "0b861925-e69d-41a8-b715-45e516a6bfdd",
      "name": "Filter contact creation via API",
      "type": "n8n-nodes-base.filter",
      "notes": "This node filters the deletions and the form submissions to only process data from the webhook that was created via the UI.",
      "position": [
        5040,
        1088
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "26dcbf80-75a3-4614-bdca-47e2c4f519bc",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $('Changes in Pipedrive1').item.json.meta.change_source }}",
              "rightValue": "app"
            },
            {
              "id": "c5b82b4f-784c-4f55-b7d7-4a29f896d28b",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              },
              "leftValue": "={{ $('Changes in Pipedrive1').item.json.meta.action }}",
              "rightValue": "delete"
            },
            {
              "id": "4f0c64d1-a8c6-4d38-ae77-c48f555b22d3",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.e53c2563a1b9d108535d55c14b4ea23ef27e6e97 }}",
              "rightValue": "KlickTipp"
            }
          ]
        }
      },
      "notesInFlow": true,
      "typeVersion": 2.3
    }
  ],
  "connections": {
    "Create a person": {
      "main": [
        [
          {
            "node": "Add Pipedrive Person ID to KlickTipp contact",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update a person": {
      "main": [
        [
          {
            "node": "Check relevant segment",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check subscription": {
      "main": [
        [
          {
            "node": "Create a person",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Update a person",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check subscription1": {
      "main": [
        [
          {
            "node": "Filter non UI events and deletions",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Filter contact creation via API",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Update contact changes in KlickTipp",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Delete contact",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get marketing status": {
      "main": [
        [
          {
            "node": "Check subscription1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Changes in Pipedrive1": {
      "main": [
        [
          {
            "node": "Get marketing status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check relevant segment": {
      "main": [
        [
          {
            "node": "Assign Label Customer",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Assign Label ABC",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check relevant segment2": {
      "main": [
        [
          {
            "node": "Tag contact in KlickTipp2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Tag contact in KlickTipp3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create contact with DOI": {
      "main": [
        [
          {
            "node": "Add KlickTipp contact ID to Pipedrive1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create contact with SOI": {
      "main": [
        [
          {
            "node": "Add KlickTipp contact ID to Pipedrive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get subscription status": {
      "main": [
        [
          {
            "node": "Add KlickTipp subscription status to Pipedrive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Tag contact in KlickTipp2": {
      "main": [
        []
      ]
    },
    "Contact tagged in KlickTipp": {
      "main": [
        [
          {
            "node": "Get contact data for tagging",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get contact data for tagging": {
      "main": [
        [
          {
            "node": "Check subscription",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Only delete Pipedrive contacts": {
      "main": [
        [
          {
            "node": "Delete contact1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter contact creation via API": {
      "main": [
        [
          {
            "node": "Create contact with DOI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Contact deletion request triggered": {
      "main": [
        [
          {
            "node": "Only delete Pipedrive contacts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter non UI events and deletions": {
      "main": [
        [
          {
            "node": "Create contact with SOI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update contact changes in KlickTipp": {
      "main": [
        [
          {
            "node": "Get subscription status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add KlickTipp contact ID to Pipedrive": {
      "main": [
        [
          {
            "node": "Check relevant segment2",
            "type": "main",
            "index": 0
          },
          {
            "node": "Tag contact for first transactional mail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add KlickTipp contact ID to Pipedrive1": {
      "main": [
        []
      ]
    },
    "Add Pipedrive Person ID to KlickTipp contact": {
      "main": [
        [
          {
            "node": "Check relevant segment",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add KlickTipp subscription status to Pipedrive": {
      "main": [
        [
          {
            "node": "Check relevant segment2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}