{
  "meta": {
    "templateId": "buchpilot-contact-sync-v1"
  },
  "name": "BuchPilot: Kontakt-Sync (sevDesk \u2192 Lexoffice)",
  "nodes": [
    {
      "id": "trigger-1",
      "name": "Neuer sevDesk Kontakt",
      "type": "n8n-nodes-buchpilot.sevDeskTrigger",
      "typeVersion": 1,
      "position": [
        240,
        300
      ],
      "parameters": {
        "event": "newContact"
      },
      "credentials": {
        "sevDeskApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "id": "if-1",
      "name": "Firma oder Person?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        460,
        300
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": false,
            "leftValue": ""
          },
          "conditions": [
            {
              "id": "condition-1",
              "leftValue": "={{ $json.name2 }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "isNotEmpty"
              }
            }
          ],
          "combinator": "and"
        }
      }
    },
    {
      "id": "set-firma",
      "name": "Mapping: Firma",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        680,
        200
      ],
      "parameters": {
        "mode": "manual",
        "duplicateItem": false,
        "assignments": {
          "assignments": [
            {
              "id": "assign-1",
              "name": "contactType",
              "value": "company",
              "type": "string"
            },
            {
              "id": "assign-2",
              "name": "companyName",
              "value": "={{ $json.name2 }}",
              "type": "string"
            },
            {
              "id": "assign-3",
              "name": "role",
              "value": "customer",
              "type": "string"
            },
            {
              "id": "assign-4",
              "name": "surename",
              "value": "={{ $json.surename }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "set-person",
      "name": "Mapping: Person",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        680,
        400
      ],
      "parameters": {
        "mode": "manual",
        "duplicateItem": false,
        "assignments": {
          "assignments": [
            {
              "id": "assign-5",
              "name": "contactType",
              "value": "person",
              "type": "string"
            },
            {
              "id": "assign-6",
              "name": "lastName",
              "value": "={{ $json.surename }}",
              "type": "string"
            },
            {
              "id": "assign-7",
              "name": "role",
              "value": "customer",
              "type": "string"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "lexoffice-firma",
      "name": "Lexoffice: Firma anlegen",
      "type": "n8n-nodes-buchpilot.lexoffice",
      "typeVersion": 1,
      "position": [
        900,
        200
      ],
      "parameters": {
        "resource": "contact",
        "operation": "create",
        "role": "={{ $json.role }}",
        "contactType": "company",
        "companyName": "={{ $json.companyName }}"
      },
      "credentials": {
        "lexofficeApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "id": "lexoffice-person",
      "name": "Lexoffice: Person anlegen",
      "type": "n8n-nodes-buchpilot.lexoffice",
      "typeVersion": 1,
      "position": [
        900,
        400
      ],
      "parameters": {
        "resource": "contact",
        "operation": "create",
        "role": "={{ $json.role }}",
        "contactType": "person",
        "lastName": "={{ $json.lastName }}"
      },
      "credentials": {
        "lexofficeApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Neuer sevDesk Kontakt": {
      "main": [
        [
          {
            "node": "Firma oder Person?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Firma oder Person?": {
      "main": [
        [
          {
            "node": "Mapping: Firma",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Mapping: Person",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mapping: Firma": {
      "main": [
        [
          {
            "node": "Lexoffice: Firma anlegen",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mapping: Person": {
      "main": [
        [
          {
            "node": "Lexoffice: Person anlegen",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [
    {
      "name": "BuchPilot"
    }
  ]
}