{
  "name": "Kontakt Anreichern - Airtable",
  "nodes": [
    {
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "scrape_linkedin",
              "type": "boolean"
            },
            {
              "name": "get_last_whatsapp_contact",
              "type": "boolean"
            },
            {
              "name": "get_last_email_contact",
              "type": "boolean"
            },
            {
              "name": "record_id"
            }
          ]
        }
      },
      "id": "d9c0ded1-e463-4a9c-826c-0012dad2f415",
      "typeVersion": 1.1,
      "name": "When Executed by Another Workflow",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        300,
        160
      ]
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "loose",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $('When Executed by Another Workflow').item.json.scrape_linkedin }}",
                    "rightValue": "",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "id": "92b1cdb9-dc20-4a84-9fd2-4ef4b0a2e270"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "linkedin"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "loose",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "81057e05-edf9-4c7b-8884-f05bbe1e5819",
                    "leftValue": "={{ $('When Executed by Another Workflow').item.json.get_last_whatsapp_contact }}",
                    "rightValue": "",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "whatsapp"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "loose",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "5a3352a4-e352-43bf-be90-49202cd6e2ab",
                    "leftValue": "={{ $('When Executed by Another Workflow').item.json.get_last_email_contact }}",
                    "rightValue": "",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "email"
            }
          ]
        },
        "looseTypeValidation": true,
        "options": {
          "allMatchingOutputs": true
        }
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        720,
        160
      ],
      "id": "3440a707-f1c0-400c-8cf6-a7f14c4a7fa9",
      "name": "Switch"
    },
    {
      "parameters": {
        "url": "https://linkedin-data-api.p.rapidapi.com/get-profile-data-by-url",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "url",
              "value": "={{ $json.linkedin_url.split('?')[0].replace(/\\/$/, '') + '/' }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1020,
        -280
      ],
      "id": "52f3e5b4-f546-462e-9849-9ec2dc3faa89",
      "name": "HTTP Request",
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "c271953f-8d05-4e03-aca1-07efee1bf820",
              "name": "firstName",
              "value": "={{ $json.firstName }}",
              "type": "string"
            },
            {
              "id": "89ba002a-59b0-4c21-b6bb-60a27aa29eab",
              "name": "lastName",
              "value": "={{ $json.lastName }}",
              "type": "string"
            },
            {
              "id": "20594940-86ad-4e67-84ec-767d1e8d77d7",
              "name": "profilePicture",
              "value": "={{ $json.profilePicture }}",
              "type": "string"
            },
            {
              "id": "99e36834-c502-4a8e-a644-4be9bac0ec3a",
              "name": "fullPositions",
              "value": "={{ $json.fullPositions.chunk(3)[0] }}",
              "type": "array"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1240,
        -280
      ],
      "id": "0e81f7d7-f12d-4b87-99ba-d63146f735ef",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "operation": "getAll",
        "limit": 10,
        "filters": {
          "sender": "={{ $json.email }}"
        }
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        1000,
        460
      ],
      "id": "25a4f92e-29a2-45f6-9d2b-08d246caed0a",
      "name": "Gmail",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "email",
        "mailboxPath": {
          "__rl": true,
          "mode": "list",
          "value": "INBOX"
        },
        "emailDateRange": {
          "since": "2024-04-01T00:00:00"
        },
        "emailFlags": {},
        "emailSearchFilters": {
          "from": "={{ $json.email }}"
        }
      },
      "type": "n8n-nodes-imap.imap",
      "typeVersion": 1,
      "position": [
        1000,
        260
      ],
      "id": "407472c4-e419-47fd-9663-8a58da4a4a7f",
      "name": "IMAP",
      "alwaysOutputData": false,
      "credentials": {
        "imapApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "db_path": "/root/mcp-servers/whatsapp-mcp/whatsapp-bridge/store/messages.db",
        "query_type": "SELECT",
        "query": "=SELECT \n    *\nFROM \n    messages\nwhere chat_jid like \"%{{ parseInt($json.phone.replaceAll(\"+\",\"\"), 10) }}%\"\norder by timestamp desc \nlimit 1"
      },
      "type": "n8n-nodes-sqlite3.SqliteNode",
      "typeVersion": 1,
      "position": [
        1220,
        60
      ],
      "id": "43bccb60-cfd2-4861-84f5-ebc9625ebf69",
      "name": "get last WA message by user"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "64f16a90-2858-4589-baca-aaebbfbd367e",
              "name": "last_contact_date",
              "value": "={{ $json[0].timestamp.toDateTime().toLocal().toISO().split(\"T\")[0] }}",
              "type": "string"
            },
            {
              "id": "f988e25c-79ba-49a1-b859-ced62618c7c4",
              "name": "channel",
              "value": "whatsapp",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1518,
        60
      ],
      "id": "648b0037-568b-4484-a251-7f7ad2adb617",
      "name": "last_contact_json"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "64f16a90-2858-4589-baca-aaebbfbd367e",
              "name": "last_contact_date",
              "value": "={{ $json.latest_date.toDateTime().toLocal().toISO().split(\"T\")[0] }}",
              "type": "string"
            },
            {
              "id": "f988e25c-79ba-49a1-b859-ced62618c7c4",
              "name": "channel",
              "value": "private_email",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1518,
        260
      ],
      "id": "0422d29b-2be3-4a17-abbf-b4a3fb9cf1a1",
      "name": "last_contact_json1"
    },
    {
      "parameters": {
        "jsCode": "const messages = $input.all().map(r=>r.json)\nconsole.log(messages)\nconst latestDate = messages.reduce((latest, msg) => !latest || new Date(msg.envelope.date) > new Date(latest) ? msg.envelope.date : latest, null);\nreturn {\"latest_date\": latestDate}"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1220,
        260
      ],
      "id": "06f08aa2-4f0b-40ef-8d67-6f48c6ab5175",
      "name": "Code"
    },
    {
      "parameters": {
        "jsCode": "const messages = $input.all().map(r=>r.json)\nconst latestDate = messages.reduce((latest, msg) => !latest || parseInt(msg.internalDate) > parseInt(latest) ? msg.internalDate : latest, null);\nreturn {\"latest_date\": \nDateTime.fromMillis(parseInt(latestDate))}"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1220,
        460
      ],
      "id": "1118634d-6b83-4332-a8df-b6c3b01e7c6f",
      "name": "Code1"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "64f16a90-2858-4589-baca-aaebbfbd367e",
              "name": "last_contact_date",
              "value": "={{ $json.latest_date.toDateTime().toLocal().toISO().split(\"T\")[0] }}",
              "type": "string"
            },
            {
              "id": "f988e25c-79ba-49a1-b859-ced62618c7c4",
              "name": "channel",
              "value": "work_email",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1518,
        460
      ],
      "id": "7770c807-a784-483d-8c35-cd53f7df165b",
      "name": "last_contact_json2"
    },
    {
      "parameters": {
        "numberInputs": 3
      },
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.1,
      "position": [
        1760,
        260
      ],
      "id": "fc4cce27-b544-4e0a-a630-5daa98a7bce6",
      "name": "Merge"
    },
    {
      "parameters": {
        "jsCode": "const input = $input.all().map(r=>r.json)\nconst output = input.reduce((latest, current) => \n    new Date(current.last_contact_date) > new Date(latest.last_contact_date) ? current : latest\n  )\n\nreturn {\"output\": output, \"pairedItem\": $input.all().map(r=>r.json.last_contact_date).indexOf(output.last_contact_date)}"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1980,
        260
      ],
      "id": "7c327c0f-e817-40f2-a545-a11127e65961",
      "name": "Code2"
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4.1-mini",
          "mode": "list",
          "cachedResultName": "GPT-4.1-MINI"
        },
        "messages": {
          "values": [
            {
              "content": "Erstelle anhand den Daten des Linkedin-Profils folgende Felder:  \"professional_role\" -> Job-Titel des Kontakts \"company_linkedin_url\" -> Linkedin-URL des aktuellen Unternehmens des Kontakts \"job_summary\" -> Kurze Zusammenfassung des Jobs des Kontakts",
              "role": "system"
            },
            {
              "content": "[   {     \"firstName\": \"Matthias\",     \"lastName\": \"Fuchs\",     \"profilePicture\": \"https://media.licdn.com/dms/image/v2/D4D03AQHQTpgnP8oYyQ/profile-displayphoto-shrink_800_800/profile-displayphoto-shrink_800_800/0/1724930219601?e=1751500800&v=beta&t=THnrpKKIe5nKwNn8zk2mgJBPJ-jrLI7E82m90K3p_88\",     \"fullPositions\": [       {         \"companyId\": 101580224,         \"companyName\": \"Tiger Cow Studios\",         \"companyUsername\": \"tigercow\",         \"companyURL\": \"https://www.linkedin.com/company/tigercow/\",         \"companyLogo\": \"https://media.licdn.com/dms/image/v2/D4D0BAQFyovj0II7Aug/company-logo_400_400/company-logo_400_400/0/1725014670166/tigercow_logo?e=1751500800&v=beta&t=En4emPV3X9yD_pcTqb4Qb4xd4QrYqVInie8jsOHQ3mc\",         \"companyIndustry\": \"Computer Software\",         \"companyStaffCountRange\": \"2 - 10\",         \"title\": \"Co-Founder\",         \"multiLocaleTitle\": {           \"de_DE\": \"Co-Founder\"         },         \"multiLocaleCompanyName\": {           \"de_DE\": \"Tiger Cow Studios\"         },         \"location\": \"Berlin, Germany\",         \"description\": \"We build AI-powered automations tailored to grow your business\",         \"employmentType\": \"Full-time\",         \"start\": {           \"year\": 2024,           \"month\": 1,           \"day\": 0         },         \"end\": {           \"year\": 0,           \"month\": 0,           \"day\": 0         }       },       {         \"companyId\": 72063855,         \"companyName\": \"Angelize\",         \"companyUsername\": \"angelize\",         \"companyURL\": \"https://www.linkedin.com/company/angelize/\",         \"companyLogo\": \"https://media.licdn.com/dms/image/v2/C4E0BAQHjqszmJGFbiw/company-logo_400_400/company-logo_400_400/0/1648660104797/angelize_logo?e=1751500800&v=beta&t=xFvrWbDTyynS7XIui_expF5nXSFFmvuUV4dz7BaVjZ8\",         \"companyIndustry\": \"Venture Capital & Private Equity\",         \"companyStaffCountRange\": \"2 - 10\",         \"title\": \"Founding Partner\",         \"multiLocaleTitle\": {           \"de_DE\": \"Founding Partner\"         },         \"multiLocaleCompanyName\": {           \"de_DE\": \"Angelize\"         },         \"location\": \"Berlin, Deutschland\",         \"description\": \"\",         \"employmentType\": \"Full-time\",         \"start\": {           \"year\": 2021,           \"month\": 0,           \"day\": 0         },         \"end\": {           \"year\": 2023,           \"month\": 0,           \"day\": 0         }       },       {         \"companyId\": 65701355,         \"companyName\": \"KAURI TECH Investment GmbH\",         \"companyUsername\": \"kauri-tech-invest-gmbh\",         \"companyURL\": \"https://www.linkedin.com/company/kauri-tech-invest-gmbh/\",         \"companyLogo\": \"https://media.licdn.com/dms/image/v2/C4D0BAQGihNk6cXr31Q/company-logo_400_400/company-logo_400_400/0/1630508757276?e=1751500800&v=beta&t=2GrbDgcJ6cJsKcb-5RepSBwghGS4cWzVW_pnL7QBCOU\",         \"companyIndustry\": \"Venture Capital & Private Equity\",         \"companyStaffCountRange\": \"2 - 10\",         \"title\": \"Managing Partner\",         \"multiLocaleTitle\": {           \"de_DE\": \"Managing Partner\"         },         \"multiLocaleCompanyName\": {           \"de_DE\": \"KAURI TECH Investment GmbH\"         },         \"location\": \"Berlin, Deutschland\",         \"description\": \"\",         \"employmentType\": \"Full-time\",         \"start\": {           \"year\": 2018,           \"month\": 0,           \"day\": 0         },         \"end\": {           \"year\": 2021,           \"month\": 0,           \"day\": 0         }       }     ]   } ]"
            },
            {
              "content": " { \"professional_role\":  \"Co-Founder\", \"company_linkedin_url\":  \"https://www.linkedin.com/company/tigercow/\", \"job_summary\":  \"Founder von Tiger Cow Studios, Agentur f\u00fcr AI Automatisierungen\" }",
              "role": "assistant"
            },
            {
              "content": "=Perfekt, jetzt:\n\n{{$json.toJsonString()}}"
            }
          ]
        },
        "jsonOutput": true,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        1460,
        -280
      ],
      "id": "06020417-27ec-4abc-ae29-72a8c4456987",
      "name": "OpenAI",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "toolDescription": "Nutze dieses Tool um das Linkedin-Profil des Unternehmens des Kontakts abzurufen um mehr \u00fcber die Branche des Unternehmens zu erfahren.\n\nF\u00fclle daf\u00fcr den username des Unternehmens aus:\nhttps://www.linkedin.com/company/tigercow/ => tigercow",
        "url": "https://linkedin-data-api.p.rapidapi.com/get-company-details",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendQuery": true,
        "parametersQuery": {
          "values": [
            {
              "name": "username"
            }
          ]
        },
        "sendHeaders": true,
        "parametersHeaders": {
          "values": [
            {
              "name": "x-rapidapi-host",
              "valueProvider": "fieldValue",
              "value": "linkedin-data-api.p.rapidapi.com"
            }
          ]
        }
      },
      "type": "@n8n/n8n-nodes-langchain.toolHttpRequest",
      "typeVersion": 1.1,
      "position": [
        1640,
        -120
      ],
      "id": "2870675d-0d47-4538-b7a4-d7abe1be0a36",
      "name": "Company_Linkedin_abrufen",
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "mode": "combine",
        "combineBy": "combineByPosition",
        "options": {}
      },
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.1,
      "position": [
        2420,
        -20
      ],
      "id": "e078f6df-95d4-417a-b13f-2317c5b10d29",
      "name": "Merge1"
    },
    {
      "parameters": {
        "base": {
          "__rl": true,
          "value": "appPkvgIRRuhob92a",
          "mode": "list",
          "cachedResultName": "AI CRM",
          "cachedResultUrl": "https://airtable.com/appPkvgIRRuhob92a"
        },
        "table": {
          "__rl": true,
          "value": "tblMSeed2JnTr6KcN",
          "mode": "list",
          "cachedResultName": "contacts",
          "cachedResultUrl": "https://airtable.com/appPkvgIRRuhob92a/tblMSeed2JnTr6KcN"
        },
        "id": "={{ $json.record_id }}",
        "options": {}
      },
      "type": "n8n-nodes-base.airtable",
      "typeVersion": 2.1,
      "position": [
        520,
        160
      ],
      "id": "55d815f7-7797-4b41-93dd-d0a3e3aaf12d",
      "name": "Airtable",
      "credentials": {
        "airtableTokenApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "update",
        "base": {
          "__rl": true,
          "value": "appPkvgIRRuhob92a",
          "mode": "list",
          "cachedResultName": "AI CRM",
          "cachedResultUrl": "https://airtable.com/appPkvgIRRuhob92a"
        },
        "table": {
          "__rl": true,
          "value": "tblMSeed2JnTr6KcN",
          "mode": "list",
          "cachedResultName": "contacts",
          "cachedResultUrl": "https://airtable.com/appPkvgIRRuhob92a/tblMSeed2JnTr6KcN"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "id": "={{ $('Airtable').item.json.id }}",
            "professional_role": "={{ $json.message.content.professional_role }}",
            "company_linkedin_url": "={{ $json.message.content.company_linkedin_url }}",
            "general_notes": "={{ $json.message.content.job_summary }}",
            "city": "={{ $('HTTP Request').item.json.geo.full }}"
          },
          "matchingColumns": [
            "id"
          ],
          "schema": [
            {
              "id": "id",
              "displayName": "id",
              "required": false,
              "defaultMatch": true,
              "display": true,
              "type": "string",
              "readOnly": true,
              "removed": false
            },
            {
              "id": "full_name",
              "displayName": "full_name",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "readOnly": true,
              "removed": true
            },
            {
              "id": "first_name",
              "displayName": "first_name",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "last_name",
              "displayName": "last_name",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "phone",
              "displayName": "phone",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "email",
              "displayName": "email",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "linkedin_url",
              "displayName": "linkedin_url",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "last_catchup",
              "displayName": "last_catchup",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "dateTime",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "catchup_frequency_in_weeks",
              "displayName": "catchup_frequency_in_weeks",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "number",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "next_catchup",
              "displayName": "next_catchup",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "dateTime",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "languages_iso_array",
              "displayName": "languages_iso_array",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "array",
              "options": [
                {
                  "name": "DE",
                  "value": "DE"
                },
                {
                  "name": "EN",
                  "value": "EN"
                }
              ],
              "readOnly": false,
              "removed": true
            },
            {
              "id": "city",
              "displayName": "city",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "gift_ideas",
              "displayName": "gift_ideas",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "birthday",
              "displayName": "birthday",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "dateTime",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "general_notes",
              "displayName": "general_notes",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "relationship_description",
              "displayName": "relationship_description",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "relationship_category",
              "displayName": "relationship_category",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "options",
              "options": [
                {
                  "name": "social",
                  "value": "social"
                },
                {
                  "name": "work_client",
                  "value": "work_client"
                },
                {
                  "name": "family",
                  "value": "family"
                },
                {
                  "name": "other",
                  "value": "other"
                },
                {
                  "name": "work_network",
                  "value": "work_network"
                },
                {
                  "name": "work_partner",
                  "value": "work_partner"
                }
              ],
              "readOnly": false,
              "removed": true
            },
            {
              "id": "company_linkedin_url",
              "displayName": "company_linkedin_url",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "professional_role",
              "displayName": "professional_role",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "created_at",
              "displayName": "created_at",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "readOnly": true,
              "removed": true
            },
            {
              "id": "ID",
              "displayName": "ID",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "readOnly": true,
              "removed": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.airtable",
      "typeVersion": 2.1,
      "position": [
        1940,
        -280
      ],
      "id": "c5fc113b-c5ef-4e4b-8b5d-565b8ae47eda",
      "name": "Airtable1",
      "credentials": {
        "airtableTokenApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "update",
        "base": {
          "__rl": true,
          "value": "appPkvgIRRuhob92a",
          "mode": "list",
          "cachedResultName": "AI CRM",
          "cachedResultUrl": "https://airtable.com/appPkvgIRRuhob92a"
        },
        "table": {
          "__rl": true,
          "value": "tblMSeed2JnTr6KcN",
          "mode": "list",
          "cachedResultName": "contacts",
          "cachedResultUrl": "https://airtable.com/appPkvgIRRuhob92a/tblMSeed2JnTr6KcN"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "id": "={{ $('Airtable').first().json.id }}",
            "last_catchup": "={{  new Date($json.output.last_contact_date) > new Date($('Airtable').first().json.last_catchup) ? $json.output.last_contact_date : $('Airtable').first().json.last_catchup }}"
          },
          "matchingColumns": [
            "id"
          ],
          "schema": [
            {
              "id": "id",
              "displayName": "id",
              "required": false,
              "defaultMatch": true,
              "display": true,
              "type": "string",
              "readOnly": true,
              "removed": false
            },
            {
              "id": "full_name",
              "displayName": "full_name",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "readOnly": true,
              "removed": true
            },
            {
              "id": "first_name",
              "displayName": "first_name",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "last_name",
              "displayName": "last_name",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "phone",
              "displayName": "phone",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "email",
              "displayName": "email",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "linkedin_url",
              "displayName": "linkedin_url",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "last_catchup",
              "displayName": "last_catchup",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "dateTime",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "catchup_frequency_in_weeks",
              "displayName": "catchup_frequency_in_weeks",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "number",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "next_catchup",
              "displayName": "next_catchup",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "dateTime",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "languages_iso_array",
              "displayName": "languages_iso_array",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "array",
              "options": [
                {
                  "name": "DE",
                  "value": "DE"
                },
                {
                  "name": "EN",
                  "value": "EN"
                }
              ],
              "readOnly": false,
              "removed": true
            },
            {
              "id": "city",
              "displayName": "city",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "gift_ideas",
              "displayName": "gift_ideas",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "birthday",
              "displayName": "birthday",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "dateTime",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "general_notes",
              "displayName": "general_notes",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "relationship_description",
              "displayName": "relationship_description",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "relationship_category",
              "displayName": "relationship_category",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "options",
              "options": [
                {
                  "name": "social",
                  "value": "social"
                },
                {
                  "name": "work_client",
                  "value": "work_client"
                },
                {
                  "name": "family",
                  "value": "family"
                },
                {
                  "name": "other",
                  "value": "other"
                },
                {
                  "name": "work_network",
                  "value": "work_network"
                },
                {
                  "name": "work_partner",
                  "value": "work_partner"
                }
              ],
              "readOnly": false,
              "removed": true
            },
            {
              "id": "company_linkedin_url",
              "displayName": "company_linkedin_url",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "professional_role",
              "displayName": "professional_role",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "created_at",
              "displayName": "created_at",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "readOnly": true,
              "removed": true
            },
            {
              "id": "ID",
              "displayName": "ID",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "readOnly": true,
              "removed": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {
          "typecast": true
        }
      },
      "type": "n8n-nodes-base.airtable",
      "typeVersion": 2.1,
      "position": [
        2180,
        260
      ],
      "id": "6643c9bf-4455-4485-b45b-c2c5e9044c7d",
      "name": "Airtable2",
      "credentials": {
        "airtableTokenApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Airtable",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "get last WA message by user",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "IMAP",
            "type": "main",
            "index": 0
          },
          {
            "node": "Gmail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "get last WA message by user": {
      "main": [
        [
          {
            "node": "last_contact_json",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IMAP": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "last_contact_json1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code1": {
      "main": [
        [
          {
            "node": "last_contact_json2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "last_contact_json": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "last_contact_json1": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "last_contact_json2": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Code2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code2": {
      "main": [
        [
          {
            "node": "Airtable2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "OpenAI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Company_Linkedin_abrufen": {
      "ai_tool": [
        [
          {
            "node": "OpenAI",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI": {
      "main": [
        [
          {
            "node": "Airtable1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Airtable": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Airtable1": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Airtable2": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 1
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "b8c27981-1e80-4441-b46d-3772cc9282b7",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "4Jq6kKNdbbOEeCzj",
  "tags": [
    {
      "createdAt": "2025-03-25T17:27:05.902Z",
      "updatedAt": "2025-03-25T17:27:05.902Z",
      "id": "54Ri2YOXfTg4MYXj",
      "name": "Function"
    },
    {
      "createdAt": "2025-04-01T10:04:22.316Z",
      "updatedAt": "2025-04-01T10:04:22.316Z",
      "id": "gsgd8hej7FEhRA1u",
      "name": "CRM"
    }
  ]
}