Task: Find ICP from Job Title - LoneScale Template

n8n workflow:
{"id":"94","meta":{"instanceId":"81b0d0f4ebb052991cb352e76cb8b2803ed521afd57aeef066e0ecfe83fd76cc"},"name":"Find ICP from Job Title - LoneScale Template","tags":[{"id":"1","name":"Example","createdAt":"2022-12-30T09:13:52.086Z","updatedAt":"2022-12-30T09:13:52.086Z"}],"nodes":[{"id":"9b7b7728-3d57-4670-af9c-83361ed9bde1","name":"Execute Workflow Trigger","type":"n8n-nodes-base.executeWorkflowTrigger","position":[100,320],"parameters":{},"typeVersion":1},{"id":"2e98e181-d178-484f-ab79-8bda713ae5cc","name":"split_in_batches","type":"n8n-nodes-base.splitInBatches","position":[500,320],"parameters":{"options":{},"batchSize":1},"typeVersion":1},{"id":"f0cbf664-9012-4edd-a0bb-4c61d157f036","name":"Lvl & intent","type":"n8n-nodes-base.code","position":[760,320],"parameters":{"mode":"runOnceForEachItem","jsCode":"const jobtitle = $input.item.json.fields.job_title\nconst levels = {\n  FR: {\n    Supervisor: {\n      name: [\n        'président',\n        'president',\n        'VP',\n        'Vice president',\n        'Vice président',\n        'Vice présidente',\n        'Associé',\n      ],\n      acronym: ['DG'],\n    },\n    Director: {\n      name: ['Directeur', 'Directrice'],\n      acronym: [''],\n    },\n    Founder: {\n      name:  ['fondateur',\n         'cofondateur'],\n      acronym: [''],\n    },\n    Manager: {\n      name: ['Responsable', 'chef', 'chargé'],\n      acronym: [''],\n    },\n    Intern: {\n      name: ['stagiaire', 'stage', 'alternant', 'apprenti'],\n      acronym: [''],\n    },\n  },\n  EN: {\n    Supervisor: {\n      name: [\n        'general director',\n        'partner',\n        'president',\n        'VP',\n        'Vice president',\n        'chief',\n      ],\n      acronym: [\n        'GD',\n        'COO',\n        'CRO',\n        'CFO',\n        'CCO',\n        'CEO',\n        'CTO',\n        'CPO',\n        'CDO',\n        'CISO',\n        'CGO',\n        'CLO',\n      ],\n    },\n        Founder: {\n      name:  ['founder',\n        'co-founder',\n        'cofounder'],\n      acronym: [''],\n    },\n    Director: {\n      name: ['Director', 'Head'],\n      acronym: [''],\n    },\n    Manager: {\n      name: ['Manager', 'Lead'],\n      acronym: [''],\n    },\n    Intern: {\n      name: ['intern', 'internship', 'apprentice', 'apprenticeship'],\n      acronym: [''],\n    },\n  },\n};\n\nconst departments = {\n  FR: {\n    Administrative: ['Administratif'],\n    'Sales': [\n      'développement',\n      'commercial',\n      'agence',\n      'business unit',\n    ],\n    'Revenue': [''],\n    'CRM': [''],\n    'Procurment': ['achat'],\n    Compliance: ['Conformité', 'assurance qualité'],\n    'Customer Care': ['expérience client', 'service client'],\n    Design: ['design'],\n    Executive: [\n      'Président',\n      'directeur général',\n      'directeur general',\n      'fondateur',\n      'cofondateur',\n      'Associé',\n    ],\n    'Finance': [\n      'expert-comptable',\n      'expert comptable',\n      'paie',\n      'comptable',\n      'financier', 'administratif et financier',\n    ],\n    'Human Resources': ['DRH', 'RRH', 'RH', 'ressources humaines'],\n    Legal: ['Avocat', 'Juridique', 'Propriété intellectuelle'],\n    'Growth outbound': [''],\n    'Marketing': [''],\n    'Marketing Else': ['stratégie de marque','Communications', 'contenu'],\n    Operations: ['opérations'],\n    Recruitment: ['recrutement'],\n    Tech: ['données', 'ingénieur données','numérique', 'DSI', \"des Systèmes d'Information\",'Produit','sécurité web'],\n    Supply: ['logistique'],\n  },\n  EN: {\n    Administrative: ['Administrative', 'office'],\n    'Sales': [\n      'CSO',\n      'commercial',\n      'ventes',\n      'sales',\n      'country',\n      'business',\n      'revenue',\n      'sdr',\n      'bdr',\n      'account',\n    ],\n    'Revenue': [\n      'CRO',\n      'revenue',\n    ],\n    'Procurment': ['purchase', 'purchasing'],\n    Compliance: ['CCO', 'Compliance', 'Quality assurance'],\n    'Customer Care': [\n      'customer',\n      'customer care',\n      'customer success',\n      'customer experience',\n      'customer service',\n    ],\n    Design: ['design', 'designer'],\n    CRM: ['crm', 'salesforce','hubspot'],\n\n    Executive: [\n      'CEO',\n      'Chief Executive Officer',\n      'general director',\n      'founder',\n      'cofounder',\n      'co-founder',\n      'Directeur Général',\n      'Directeur general',\n      'DG',\n      'fondateur',\n      'cofondateur',\n      'Chairmann',\n      'chief of staff',\n      'general director',\n      'president',\n    ],\n    'Finance': [\n      'CFO',\n      'financial',\n      'finance',\n      'finance and administrative',\n      'audit',\n      'accountant', 'accounting', 'payroll', 'fiscal',\n    ],\n    'Human Resources': ['HR', 'human resources', 'people', 'Happiness Manager'],\n    Legal: ['Attorney', 'Legal', 'intellectual property'],\n\n     'Growth outbound': [\n      'growth',\n      'outbound',\n      'growth outbound',\n      'growth ops',\n      'gotomarket',\n      'gtm',\n      'demandgen',\n      'demand generation',\n      'demand gen',\n      'go-to-market',\n      'growth engineer',\n      'lead generation',\n    ],\n    'Marketing': [\n      'CMO',\n      'marketing',\n      'acquisition',\n      'campaign',\n    ],\n    'Marketing Else': [\n      'digital marketing',\n      'digital performance',\n      'SEO',\n      'SEA',\n      'ads',\n      'content marketing',\n      'Communication',\n      'digital media',\n      'content',\n      'social media',\n      'content marketing',\n      'marketing communication',\n      'copywriting',\n      'copywriter',\n    ],\n    Operations: [\n      'COO',\n      'ops',\n      'sales ops',\n      'marketing ops',\n      'operations',\n      'operating',\n    ],\n    Recruitment: [\n      'recruiting',\n      'recruitment',\n      'talent',\n      'talent acquisition',\n      'sourcing',\n      'recruiter',\n    ],\n    Tech: [\n      'CDO',\n      'data',\n      'data engineering',\n      'data science',\n      'data scientist',\n      'data engineer',\n      'data analyst',\n      'CTO',\n      'technical',\n      'tech',\n      'engineering',\n      'software',\n      'software engineer',\n      'information technology',\n      'information system',\n      'IT',\n      'Dev ops',\n      'CISO',\n      'information security',\n      'cyber security',\n      'cyber',\n      'CPO', \n      'Product',\n    ],\n      \n    Supply: ['supply', 'supply chain', 'logistic', 'ecommerce', 'e-commerce'],\n  },\n};\n\nconst categories = {\n    DM: {\n        level: ['Founder', 'Director', 'Head', 'Supervisor'],\n        department: ['Sales', 'Revenue', 'Executive', 'Customer Care','Operations', 'Growth outbound','Marketing']\n    },\n    Champion: {\n        level: ['Lead', 'Manager', 'Contributor'],\n        department:['Revenue', 'Executive', 'Operations', 'Growth outbound','CRM','Marketing']\n    },\n    Champion2: {\n        level: ['Lead', 'Manager'],\n        department:['Sales','Customer Care','Operations']\n    },\n    User: {\n        level: ['Contributor'],\n        department:['Sales', 'Customer Care']\n    }\n}\n\nconst keywordFilter = (title, key) =>\n  new RegExp(`${key}\\\\b`, 'i').test(title) && key;\n\nconst capitalizeFirstLetter = (word) =>\n  word.toLowerCase().replace(/^\\w/, (c) => c.toUpperCase());\n\nconst matchDepartment = Object.keys(departments['EN']).find(\n  (d) =>\n    Array.from(\n      new Set([\n        ...departments['EN'][d].map(\n          (d) =>\n            keywordFilter(\n              jobtitle,\n              d,\n            ) && d,\n        ),\n        ...departments['FR'][d].map(\n          (d) =>\n            keywordFilter(\n              jobtitle,\n              d,\n            ) && d,\n        ),\n      ]),\n    ).filter(Boolean).length,\n);\n\nconst matchLevel = Object.keys(levels['EN']).find(\n  (l) =>\n    Array.from(\n      new Set([\n        ...[\n          ...levels['EN'][capitalizeFirstLetter(l)].name,\n          ...levels['EN'][capitalizeFirstLetter(l)].acronym,\n        ].map(\n          (d) =>\n            keywordFilter(\n              jobtitle.toLowerCase().match(d.toLowerCase()),\n              d,\n            ) && d,\n        ),\n        ...[\n          ...levels['FR'][capitalizeFirstLetter(l)].name,\n          ...levels['FR'][capitalizeFirstLetter(l)].acronym,\n        ].map(\n          (d) =>\n            keywordFilter(\n              jobtitle\n                .toLowerCase()\n                .match(d.toLowerCase()),\n              d,\n            ) && d,\n        ),\n      ]),\n    ).filter(Boolean).length,\n) || 'Contributor';\n\nconst matchCategory = Object.keys(categories).find(c => categories[c].level.includes(matchLevel) && categories[c].department.includes(matchDepartment)) || 'Other';\n\nreturn {\n  json: {\n    department: matchDepartment,\n    level: matchLevel,\n    category: matchCategory.match(/(Champion)/, 'g')?.[0] || matchCategory\n  },\n};"},"typeVersion":1},{"id":"45a0eeef-a776-40a5-837f-89fd5b4a650f","name":"sync_airtable","type":"n8n-nodes-base.airtable","position":[1360,460],"parameters":{"id":"={{ $json[\"id\"] }}","table":{"__rl":true,"mode":"id","value":"={{ $node[\"set_id_airtable\"].json[\"idtable\"] }}"},"fields":["department","level","icp","type_dm","statut"],"options":{},"operation":"update","application":{"__rl":true,"mode":"id","value":"={{ $node[\"set_id_airtable\"].json[\"idbase\"] }}"},"updateAllFields":false},"credentials":{"airtableApi":{"id":"8","name":"Airtable LS"}},"typeVersion":1},{"id":"929d7794-df10-4967-bbfb-1a62e9a734f0","name":"IF","type":"n8n-nodes-base.if","position":[980,320],"parameters":{"conditions":{"string":[{"value1":"={{ $json[\"category\"] }}","value2":"Other","operation":"contains"}]}},"typeVersion":1},{"id":"99835662-7399-4a51-b59f-3d0fdd509b05","name":"set_airtable_build_request1","type":"n8n-nodes-base.set","position":[1160,100],"parameters":{"values":{"string":[{"name":"id","value":"={{ $node[\"split_in_batches\"].json[\"id\"] }}"},{"name":"department","value":"={{ $json[\"department\"] }}"},{"name":"level","value":"={{ $json[\"level\"] }}"},{"name":"icp","value":"=No"},{"name":"type_dm","value":"={{ $json[\"category\"] }}"},{"name":"statut","value":"=categorized__{{new Date().toLocaleDateString()}}_{{new Date().toLocaleTimeString()}}"}]},"options":{}},"typeVersion":1},{"id":"551f1e9b-e80c-454d-8ef5-e1dd7d32cd82","name":"sync_airtable1","type":"n8n-nodes-base.airtable","position":[1340,100],"parameters":{"id":"={{ $json[\"id\"] }}","table":{"__rl":true,"mode":"id","value":"={{ $node[\"set_id_airtable\"].json[\"idtable\"] }}"},"fields":["department","level","icp","type_dm","statut"],"options":{},"operation":"update","application":{"__rl":true,"mode":"id","value":"={{ $node[\"set_id_airtable\"].json[\"idbase\"] }}"},"updateAllFields":false},"credentials":{"airtableApi":{"id":"8","name":"Airtable LS"}},"typeVersion":1},{"id":"2561aa6a-6bdd-4506-9237-c4c21838f7ec","name":"set_airtable_build_request","type":"n8n-nodes-base.set","position":[1180,460],"parameters":{"values":{"string":[{"name":"id","value":"={{ $node[\"split_in_batches\"].json[\"id\"] }}"},{"name":"department","value":"={{ $json[\"department\"] }}"},{"name":"level","value":"={{ $json[\"level\"] }}"},{"name":"icp","value":"=Yes"},{"name":"type_dm","value":"={{ $json[\"category\"] }}"},{"name":"statut","value":"=categorized__{{new Date().toLocaleDateString()}}_{{new Date().toLocaleTimeString()}}"}]},"options":{}},"typeVersion":1},{"id":"fd9aee93-60b3-4dcd-95fe-aa2cbe368eeb","name":"get_list_people_airtable","type":"n8n-nodes-base.airtable","position":[300,320],"parameters":{"table":{"__rl":true,"mode":"id","value":"={{ $node[\"set_id_airtable\"].json[\"idtable\"] }}"},"operation":"list","application":{"__rl":true,"mode":"id","value":"={{ $node[\"set_id_airtable\"].json[\"idbase\"] }}"},"additionalOptions":{"fields":["profile_id","full_name","headline","job_title"]}},"credentials":{"airtableApi":{"id":"8","name":"Airtable LS"}},"typeVersion":1},{"id":"20debc9d-c021-4e9c-8229-35e4f618885c","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[700,280],"parameters":{"width":225,"height":219,"content":"I am here"},"typeVersion":1}],"active":false,"pinData":{},"settings":{},"versionId":"9ada2bd6-efef-4cd4-9b43-beba9836c673","connections":{"IF":{"main":[[{"node":"set_airtable_build_request1","type":"main","index":0}],[{"node":"set_airtable_build_request","type":"main","index":0}]]},"Lvl & intent":{"main":[[{"node":"IF","type":"main","index":0}]]},"sync_airtable":{"main":[[{"node":"split_in_batches","type":"main","index":0}]]},"sync_airtable1":{"main":[[{"node":"split_in_batches","type":"main","index":0}]]},"split_in_batches":{"main":[[{"node":"Lvl & intent","type":"main","index":0}]]},"Execute Workflow Trigger":{"main":[[{"node":"get_list_people_airtable","type":"main","index":0}]]},"get_list_people_airtable":{"main":[[{"node":"split_in_batches","type":"main","index":0}]]},"set_airtable_build_request":{"main":[[{"node":"sync_airtable","type":"main","index":0}]]},"set_airtable_build_request1":{"main":[[{"node":"sync_airtable1","type":"main","index":0}]]}}}