{
  "nodes": [
    {
      "id": "090c0c78-fa41-41cd-affa-188714c72e96",
      "name": "When clicking \u2018Execute workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -2016,
        464
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "70f16c39-5979-4ee8-be93-62ebbf6c66da",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2224,
        -128
      ],
      "parameters": {
        "width": 716,
        "height": 488,
        "content": "### How it works:\n1. Initialisation\n   * intialisation of counters from \"Data Table\"\n   * lead selection and loading from Google Sheet\n\n2. Import of leads into CRM according 3 possibilities:\n   2.1 company does not exist \u27a1\ufe0f creation of company, incrementation of create counter\n   2.2 company exists only one time \u27a1\ufe0f update of existing company, incrementation of update counter\n   2.3 company exists multiple times \u27a1\ufe0f log quality inconsistency  \n\n3. Generation of import report \n\n### Setup steps:\n* Define credentials : Airtable, Google\n* Use or Create internal Data Table : EML_Import\n* Use or Create CRM Table(s) : Compagny\n* Airtable Search Conditions : AND({Company} = \"{{ $('Loop Over Items').item.json.Company }}\", {Email} = \"{{ $('Loop Over Items').item.json.Email }}\")\n* Google Search Conditions : Valid Email = OK"
      },
      "typeVersion": 1
    },
    {
      "id": "6aaeb094-4842-4153-b594-88feeb214860",
      "name": "Update row(s)",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        -1040,
        480
      ],
      "parameters": {
        "columns": {
          "value": {
            "executionId": "={{ $execution.id }}",
            "recordsRead": "={{ $json.recordsRead + 1}}"
          },
          "schema": [
            {
              "id": "executionId",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "executionId",
              "defaultMatch": false
            },
            {
              "id": "recordsRead",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "recordsRead",
              "defaultMatch": false
            },
            {
              "id": "recorsCreated",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "recorsCreated",
              "defaultMatch": false
            },
            {
              "id": "recordsUpdated",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "recordsUpdated",
              "defaultMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "filters": {
          "conditions": [
            {
              "keyValue": "={{ $('Insert row').item.json.id }}"
            }
          ]
        },
        "options": {},
        "operation": "update",
        "dataTableId": {
          "__rl": true,
          "mode": "list",
          "value": "YrL8Vo5VrnsRlXrx",
          "cachedResultUrl": "/projects/D1WQsJHiMg8XTFuj/datatables/YrL8Vo5VrnsRlXrx",
          "cachedResultName": "EML_Import"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "70c5df1b-ae7b-43f8-87ba-ff3cab94511f",
      "name": "Get row(s)",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        -1232,
        480
      ],
      "parameters": {
        "filters": {
          "conditions": [
            {
              "keyValue": "={{ $('Insert row').item.json.id }}"
            }
          ]
        },
        "operation": "get",
        "dataTableId": {
          "__rl": true,
          "mode": "list",
          "value": "YrL8Vo5VrnsRlXrx",
          "cachedResultUrl": "/projects/D1WQsJHiMg8XTFuj/datatables/YrL8Vo5VrnsRlXrx",
          "cachedResultName": "EML_Import"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e27e9dcb-29f2-40e9-9ff5-6aaa44e39e91",
      "name": "Insert row",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        -1824,
        464
      ],
      "parameters": {
        "columns": {
          "value": {
            "executionId": "={{ $execution.id }}",
            "recordsRead": 0,
            "recorsCreated": 0,
            "recordsUpdated": 0
          },
          "schema": [
            {
              "id": "executionId",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "executionId",
              "defaultMatch": false
            },
            {
              "id": "recordsRead",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "recordsRead",
              "defaultMatch": false
            },
            {
              "id": "recorsCreated",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "recorsCreated",
              "defaultMatch": false
            },
            {
              "id": "recordsUpdated",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "recordsUpdated",
              "defaultMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "dataTableId": {
          "__rl": true,
          "mode": "list",
          "value": "YrL8Vo5VrnsRlXrx",
          "cachedResultUrl": "/projects/D1WQsJHiMg8XTFuj/datatables/YrL8Vo5VrnsRlXrx",
          "cachedResultName": "EML_Import"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "abd4b1e1-5efc-4684-ba40-22220e1d2ae0",
      "name": "Limit",
      "type": "n8n-nodes-base.limit",
      "position": [
        -1040,
        -32
      ],
      "parameters": {
        "keep": "lastItems"
      },
      "typeVersion": 1
    },
    {
      "id": "81f73d48-a6d4-47b8-b5f5-fc9543d42edb",
      "name": "Get row(s)1",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        -864,
        -32
      ],
      "parameters": {
        "filters": {
          "conditions": [
            {
              "keyValue": "={{ $('Insert row').item.json.id }}"
            }
          ]
        },
        "operation": "get",
        "dataTableId": {
          "__rl": true,
          "mode": "list",
          "value": "YrL8Vo5VrnsRlXrx",
          "cachedResultUrl": "/projects/D1WQsJHiMg8XTFuj/datatables/YrL8Vo5VrnsRlXrx",
          "cachedResultName": "EML_Import"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "965719fb-0aa3-4c3b-8730-0ab54c706909",
      "name": "Send a message",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -672,
        -32
      ],
      "parameters": {
        "sendTo": "user@example.com",
        "message": "=Leads Import Report\nNumber of records read: {{ $json.recordsRead }}\nNumber of records created : {{ $json.recorsCreated }}\nNumber of records updated : {{ $json.recordsUpdated }}",
        "options": {},
        "subject": "REPORT EML IMPORT DE LEADS",
        "emailType": "text"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "a1258104-697e-47ac-bdae-b640f8a42b47",
      "name": "Wait1",
      "type": "n8n-nodes-base.wait",
      "position": [
        256,
        656
      ],
      "parameters": {
        "amount": 1
      },
      "typeVersion": 1.1
    },
    {
      "id": "d48c78a4-14b5-43b0-8346-3cc02998df73",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -896,
        192
      ],
      "parameters": {
        "color": 2,
        "width": 544,
        "height": 608,
        "content": "### Determination of retuned row(s) :\n**none :** no exisitng company\n**one :** only one exisitng company\n**multiple :** multiple existing occurrences of the same company\n\nWhen there are multiple occurences of the same company, it indicates a data quality issue \u27a1\ufe0f this to be solved"
      },
      "typeVersion": 1
    },
    {
      "id": "ade429d2-7b9f-48bd-b469-6150f5424117",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -288,
        192
      ],
      "parameters": {
        "color": 4,
        "width": 448,
        "height": 192,
        "content": "### Creation of a new company"
      },
      "typeVersion": 1
    },
    {
      "id": "5025ced0-adf1-431b-a6d1-4c7be6c5d062",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -288,
        400
      ],
      "parameters": {
        "color": 4,
        "width": 448,
        "height": 192,
        "content": "### Update of existing company"
      },
      "typeVersion": 1
    },
    {
      "id": "475be580-d995-447d-8c77-0d8ed20e4f90",
      "name": "Create Company",
      "type": "n8n-nodes-base.airtable",
      "position": [
        -208,
        240
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "appQMvR0bhVFIfsp5",
          "cachedResultUrl": "https://airtable.com/appQMvR0bhVFIfsp5",
          "cachedResultName": "PROSPECTION"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tblZvVs5HurZQdK2u",
          "cachedResultUrl": "https://airtable.com/appQMvR0bhVFIfsp5/tblZvVs5HurZQdK2u",
          "cachedResultName": "COMPANY"
        },
        "columns": {
          "value": {
            "City": "={{ $('Loop Over Items').item.json.City }}",
            "Email": "={{ $('Loop Over Items').item.json.Email }}",
            "Address": "={{ $('Loop Over Items').item.json.Address }}",
            "Company": "={{ $('Loop Over Items').item.json.Company }}",
            "Activity": "={{ $('Loop Over Items').item.json.Activity }}",
            "URL Site": "={{ $('Loop Over Items').item.json['URL Site'] }}",
            "ZIP Code": "={{ $('Loop Over Items').item.json['Zip Code'] }}",
            "Valid Email": "={{ $('Loop Over Items').item.json['Valid Email'] }}",
            "Phone Number": "={{ $('Loop Over Items').item.json['Phone Number'] }}",
            "Business Leader": "={{ $('Loop Over Items').item.json['Business Leader'] }}"
          },
          "schema": [
            {
              "id": "Company",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Company",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Business Leader",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Business Leader",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Activity",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Activity",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Address",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Address",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "ZIP Code",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "ZIP Code",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "City",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "City",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone Number",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Phone Number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Email",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "URL Site",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "URL Site",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Opt-in",
              "type": "boolean",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Opt-in",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Campaign",
              "type": "boolean",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Campaign",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Valid Email",
              "type": "options",
              "display": true,
              "options": [
                {
                  "name": "checked",
                  "value": "checked"
                },
                {
                  "name": "to be checked",
                  "value": "to be checked"
                }
              ],
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Valid Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "INTERACTION",
              "type": "array",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "INTERACTION",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {
          "typecast": true
        },
        "operation": "create"
      },
      "credentials": {
        "airtableTokenApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "478376a9-0322-4b91-abf4-2b18b3aeb8e7",
      "name": "Update row(s) - Creation",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        0,
        240
      ],
      "parameters": {
        "columns": {
          "value": {
            "executionId": "={{ $execution.id }}",
            "recorsCreated": "={{ $('Get row(s)').item.json.recorsCreated + 1}}"
          },
          "schema": [
            {
              "id": "executionId",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "executionId",
              "defaultMatch": false
            },
            {
              "id": "recordsRead",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "recordsRead",
              "defaultMatch": false
            },
            {
              "id": "recorsCreated",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "recorsCreated",
              "defaultMatch": false
            },
            {
              "id": "recordsUpdated",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "recordsUpdated",
              "defaultMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "filters": {
          "conditions": [
            {
              "keyValue": "={{ $('Insert row').item.json.id }}"
            }
          ]
        },
        "options": {},
        "operation": "update",
        "dataTableId": {
          "__rl": true,
          "mode": "list",
          "value": "YrL8Vo5VrnsRlXrx",
          "cachedResultUrl": "/projects/D1WQsJHiMg8XTFuj/datatables/YrL8Vo5VrnsRlXrx",
          "cachedResultName": "EML_Import"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "f31d06a1-6a9c-4270-abe8-98cd151dd848",
      "name": "Update row(s) - Update",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        0,
        448
      ],
      "parameters": {
        "columns": {
          "value": {
            "executionId": "={{ $execution.id }}",
            "recordsUpdated": "={{ $('Get row(s)').item.json.recordsUpdated + 1}}"
          },
          "schema": [
            {
              "id": "executionId",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "executionId",
              "defaultMatch": false
            },
            {
              "id": "recordsRead",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "recordsRead",
              "defaultMatch": false
            },
            {
              "id": "recorsCreated",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "recorsCreated",
              "defaultMatch": false
            },
            {
              "id": "recordsUpdated",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "recordsUpdated",
              "defaultMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "filters": {
          "conditions": [
            {
              "keyValue": "={{ $('Insert row').item.json.id }}"
            }
          ]
        },
        "options": {},
        "operation": "update",
        "dataTableId": {
          "__rl": true,
          "mode": "list",
          "value": "YrL8Vo5VrnsRlXrx",
          "cachedResultUrl": "/projects/D1WQsJHiMg8XTFuj/datatables/YrL8Vo5VrnsRlXrx",
          "cachedResultName": "EML_Import"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "83710b3d-b32b-40b2-bc28-be7350f8754b",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "position": [
        -672,
        480
      ],
      "parameters": {
        "jsCode": "const items = $items(\"Search Company\");\n\n// V\u00e9rifier si on a vraiment des r\u00e9sultats\nif (items.length === 0 || (items.length === 1 && !items[0].json.id)) {\n    // Aucun r\u00e9sultat\n    return [{\n        json: {\n            resultType: \"none\",\n            count: 0,\n            message: \"Aucun enregistrement trouv\u00e9\"\n        }\n    }];\n} else if (items.length === 1 && items[0].json.id) {\n    // Un seul r\u00e9sultat\n    return [{\n        json: {\n            resultType: \"one\",\n            count: 1,\n            record: items[0].json,\n            message: \"Un enregistrement trouv\u00e9\"\n        }\n    }];\n} else {\n    // Plusieurs r\u00e9sultats\n    return [{\n        json: {\n            resultType: \"multiple\",\n            count: items.length,\n            records: items.map(item => item.json),\n            message: `${items.length} enregistrements trouv\u00e9s`\n        }\n    }];\n}"
      },
      "typeVersion": 2
    },
    {
      "id": "7094a155-5554-42e8-adf0-3321fdee2a3b",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        -496,
        464
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "none",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "82df4137-54a6-4f3a-bf6f-bbde87c88001",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.resultType }}",
                    "rightValue": "none"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "one",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "1f244124-6f67-42de-9269-f474aaf06db9",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.resultType }}",
                    "rightValue": "one"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "multiple",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "728b1d9e-d5da-4d50-a96d-9b5777706018",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.resultType }}",
                    "rightValue": "multiple"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "819ea443-b06a-4d20-ab2f-e565202c8034",
      "name": "Get row(s) Leads",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -1632,
        464
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "OK",
              "lookupColumn": "Valid Email"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1FS4yS4CXmSg_Xa501AXNsRO8OQ_ieJDycLdsqLeTqic/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "=1FS4yS4CXmSg_Xa501AXNsRO8OQ_ieJDycLdsqLeTqic"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "12750d62-e59c-4a5a-8f2e-b1d1c077ef7b",
      "name": "Search Company",
      "type": "n8n-nodes-base.airtable",
      "position": [
        -848,
        480
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "appQMvR0bhVFIfsp5",
          "cachedResultUrl": "https://airtable.com/appQMvR0bhVFIfsp5",
          "cachedResultName": "PROSPECTION"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tblZvVs5HurZQdK2u",
          "cachedResultUrl": "https://airtable.com/appQMvR0bhVFIfsp5/tblZvVs5HurZQdK2u",
          "cachedResultName": "COMPANY"
        },
        "options": {},
        "operation": "search",
        "filterByFormula": "=AND({Company} = \"{{ $('Loop Over Items').item.json.Company }}\", {Email} = \"{{ $('Loop Over Items').item.json.Email }}\")"
      },
      "credentials": {
        "airtableTokenApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1,
      "alwaysOutputData": true
    },
    {
      "id": "5d77c157-2913-4664-8a62-224ab4a58f8a",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -1440,
        464
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "92040fed-ecad-4dba-8955-cd7456cc252b",
      "name": "Update Company",
      "type": "n8n-nodes-base.airtable",
      "position": [
        -208,
        448
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "appQMvR0bhVFIfsp5",
          "cachedResultUrl": "https://airtable.com/appQMvR0bhVFIfsp5",
          "cachedResultName": "PROSPECTION"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tblZvVs5HurZQdK2u",
          "cachedResultUrl": "https://airtable.com/appQMvR0bhVFIfsp5/tblZvVs5HurZQdK2u",
          "cachedResultName": "COMPANY"
        },
        "columns": {
          "value": {
            "City": "={{ $('Loop Over Items').item.json.City }}",
            "Email": "={{ $('Loop Over Items').item.json.Email }}",
            "Address": "={{ $('Loop Over Items').item.json.Address }}",
            "Company": "={{ $('Loop Over Items').item.json.Company }}",
            "Activity": "={{ $('Loop Over Items').item.json.Activity }}",
            "URL Site": "={{ $('Loop Over Items').item.json['URL Site'] }}",
            "ZIP Code": "={{ $('Loop Over Items').item.json['Zip Code'] }}",
            "Valid Email": "={{ $('Loop Over Items').item.json['Valid Email'] }}",
            "Phone Number": "={{ $('Loop Over Items').item.json['Phone Number'] }}",
            "Business Leader": "={{ $('Loop Over Items').item.json['Business Leader'] }}"
          },
          "schema": [
            {
              "id": "Company",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Company",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Business Leader",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Business Leader",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Activity",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Activity",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Address",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Address",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "ZIP Code",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "ZIP Code",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "City",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "City",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone Number",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Phone Number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Email",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "URL Site",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "URL Site",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Opt-in",
              "type": "boolean",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Opt-in",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Campaign",
              "type": "boolean",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Campaign",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Valid Email",
              "type": "options",
              "display": true,
              "options": [
                {
                  "name": "checked",
                  "value": "checked"
                },
                {
                  "name": "to be checked",
                  "value": "to be checked"
                }
              ],
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Valid Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "INTERACTION",
              "type": "array",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "INTERACTION",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Company",
            "Email"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {
          "typecast": true
        },
        "operation": "update"
      },
      "credentials": {
        "airtableTokenApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "a092f0eb-0aaa-4074-8cc2-6c28b8e92330",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -288,
        608
      ],
      "parameters": {
        "color": 3,
        "width": 448,
        "height": 192,
        "content": "### Data Quality Issue \u27a1\ufe0f Log"
      },
      "typeVersion": 1
    },
    {
      "id": "72e037b6-3d72-477b-8d8c-e56063548e6b",
      "name": "Create row(s) Logs",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -208,
        656
      ],
      "parameters": {
        "columns": {
          "value": {
            "Email": "={{ $json.records[0].Email }}",
            "Remark": "Data quality Issue : Presence of duplicate(s) => to be investigated",
            "Company": "={{ $json.records[0].Company }}"
          },
          "schema": [
            {
              "id": "Company",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Company",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Remark",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Remark",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 868691243,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1FS4yS4CXmSg_Xa501AXNsRO8OQ_ieJDycLdsqLeTqic/edit#gid=868691243",
          "cachedResultName": "Logs"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "=1FS4yS4CXmSg_Xa501AXNsRO8OQ_ieJDycLdsqLeTqic"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "7e6e8c4e-f589-4201-add1-b191969914b4",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2224,
        384
      ],
      "parameters": {
        "color": 5,
        "width": 720,
        "height": 432,
        "content": "## 1. Initialisation\n"
      },
      "typeVersion": 1
    },
    {
      "id": "e76ebbde-b82b-4a35-ba3d-72c3e1538fe5",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1456,
        176
      ],
      "parameters": {
        "color": 5,
        "width": 1824,
        "height": 640,
        "content": "## 2. Import of leads  (Iterative Loop)"
      },
      "typeVersion": 1
    },
    {
      "id": "1c5ca6ff-0aaa-4850-8de0-dc30655e9d8c",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1136,
        -128
      ],
      "parameters": {
        "color": 5,
        "width": 784,
        "height": 272,
        "content": "## 3. Generation of import report\n"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Code": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Limit": {
      "main": [
        [
          {
            "node": "Get row(s)1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait1": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Create Company",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Update Company",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Create row(s) Logs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s)": {
      "main": [
        [
          {
            "node": "Update row(s)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Insert row": {
      "main": [
        [
          {
            "node": "Get row(s) Leads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s)1": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update row(s)": {
      "main": [
        [
          {
            "node": "Search Company",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Company": {
      "main": [
        [
          {
            "node": "Update row(s) - Creation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search Company": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Company": {
      "main": [
        [
          {
            "node": "Update row(s) - Update",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Limit",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get row(s)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s) Leads": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create row(s) Logs": {
      "main": [
        [
          {
            "node": "Wait1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update row(s) - Update": {
      "main": [
        [
          {
            "node": "Wait1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update row(s) - Creation": {
      "main": [
        [
          {
            "node": "Wait1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Insert row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}