{
  "name": "task assigner (dan)",
  "nodes": [
    {
      "parameters": {
        "mode": "rules",
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.email_agent }}",
                    "rightValue": "d.bensimon@permifast.com",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "fb364a80-d316-4cdb-b409-d56419826e3d"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": false
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "afc805ec-b73e-421c-ac2c-566f7de9e672",
                    "leftValue": "={{ $json.email_agent }}",
                    "rightValue": "lea@permifast.com",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": false
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "f7a31799-4b6c-4962-84fa-e1dae65a8497",
                    "leftValue": "={{ $json.email_agent }}",
                    "rightValue": "m.shana@permifast.com",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": false
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "deca85ab-f3e0-4938-8a90-b407a4135572",
                    "leftValue": "={{ $json.email_agent }}",
                    "rightValue": "g.lounes@permifast.com",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": false
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "2db6fb11-214e-4aa0-9a37-f340b78bf0f6",
                    "leftValue": "={{ $json.email_agent }}",
                    "rightValue": "gad@permifast.com",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": false
            }
          ]
        },
        "looseTypeValidation": false,
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        -1920,
        288
      ],
      "id": "1b1d6906-b641-4537-9b19-ed5e3660a037",
      "name": "Switch1"
    },
    {
      "parameters": {
        "authentication": "accessToken",
        "resource": "task",
        "operation": "create",
        "team": "9012457899",
        "space": "90125634468",
        "folderless": true,
        "list": "901214117329",
        "name": "={{ $json.name }}",
        "additionalFields": {
          "assignees": [
            254575423
          ],
          "dueDate": "={{ $json.dueDate }}",
          "dueDateTime": true,
          "status": "rdv pris"
        }
      },
      "type": "n8n-nodes-base.clickUp",
      "typeVersion": 1,
      "position": [
        -1696,
        -80
      ],
      "id": "64c1b988-11e1-4d9e-b6d5-f87f415812f5",
      "name": "dan1",
      "credentials": {
        "clickUpApi": {
          "id": "kCX5iMbeH1ogaZ4t",
          "name": "ClickUp account"
        }
      }
    },
    {
      "parameters": {
        "authentication": "accessToken",
        "resource": "task",
        "operation": "create",
        "team": "9012457899",
        "space": "90125634468",
        "folderless": true,
        "list": "901214117329",
        "name": "={{ $json.body.name }}",
        "additionalFields": {
          "assignees": [
            87773546
          ],
          "dueDate": "={{ $json.body.time }}",
          "dueDateTime": true,
          "status": "rdv pris"
        }
      },
      "type": "n8n-nodes-base.clickUp",
      "typeVersion": 1,
      "position": [
        -1696,
        128
      ],
      "id": "715031e5-e8ef-4349-8682-abb8ab585f49",
      "name": "lea1",
      "credentials": {
        "clickUpApi": {
          "id": "kCX5iMbeH1ogaZ4t",
          "name": "ClickUp account"
        }
      }
    },
    {
      "parameters": {
        "authentication": "accessToken",
        "resource": "task",
        "operation": "create",
        "team": "9012457899",
        "space": "90125634468",
        "folderless": true,
        "list": "901214117329",
        "name": "={{ $json.body.name }}",
        "additionalFields": {
          "assignees": [
            93787036
          ],
          "dueDate": "={{ $json.body.time }}",
          "dueDateTime": true,
          "status": "rdv pris"
        }
      },
      "type": "n8n-nodes-base.clickUp",
      "typeVersion": 1,
      "position": [
        -1696,
        320
      ],
      "id": "073c79a4-fdf1-4dae-8c4f-c9fb53fe0db9",
      "name": "shana1",
      "credentials": {
        "clickUpApi": {
          "id": "kCX5iMbeH1ogaZ4t",
          "name": "ClickUp account"
        }
      }
    },
    {
      "parameters": {
        "authentication": "accessToken",
        "resource": "task",
        "operation": "create",
        "team": "9012457899",
        "space": "90125634468",
        "folderless": true,
        "list": "901214117329",
        "name": "={{ $json.body.name }}",
        "additionalFields": {
          "assignees": [
            93787035
          ],
          "dueDate": "={{ $json.body.time }}",
          "dueDateTime": true,
          "status": "rdv pris"
        }
      },
      "type": "n8n-nodes-base.clickUp",
      "typeVersion": 1,
      "position": [
        -1696,
        528
      ],
      "id": "4385bbcd-4b87-4b6a-b877-f4515b8f0918",
      "name": "lounes1",
      "credentials": {
        "clickUpApi": {
          "id": "kCX5iMbeH1ogaZ4t",
          "name": "ClickUp account"
        }
      }
    },
    {
      "parameters": {
        "authentication": "accessToken",
        "resource": "task",
        "operation": "create",
        "team": "9012457899",
        "space": "90125634468",
        "folderless": true,
        "list": "901214117329",
        "name": "={{ $json.body.name }}",
        "additionalFields": {
          "assignees": [
            81767320
          ],
          "dueDate": "={{ $json.body.time }}",
          "dueDateTime": true,
          "status": "rdv pris"
        }
      },
      "type": "n8n-nodes-base.clickUp",
      "typeVersion": 1,
      "position": [
        -1696,
        720
      ],
      "id": "91bf4047-bd83-45ec-a4e7-440d7dff0610",
      "name": "gad1",
      "credentials": {
        "clickUpApi": {
          "id": "kCX5iMbeH1ogaZ4t",
          "name": "ClickUp account"
        }
      }
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "// R\u00e9cup\u00e9ration des horaires depuis le webhook\nconst hours = items[0].json.body.office_opening_hours;\n\n// S\u00e9curit\u00e9 : si rien trouv\u00e9 \u2192 erreur lisible\nif (!hours) {\n  throw new Error(\"office_opening_hours introuvable dans items[0].json.body\");\n}\n\n// Jour actuel en MAJ (MONDAY, TUESDAY\u2026)\nconst today = new Date().toLocaleString('en-US', { weekday: 'long' }).toUpperCase();\n\n// Cherche l\u2019entr\u00e9e correspondant au jour actuel\nconst entry = hours.find(h => h.days.includes(today));\n\n// Si aucun bloc trouv\u00e9 \u2192 on met dueDate \u00e0 null\nif (!entry) {\n  return [{\n    json: {\n      name: items[0].json.body.name,\n      email_agent: items[0].json.body.email_agent,\n      openTime: null,\n      dueDate: null,\n      message: `Aucun cr\u00e9neau trouv\u00e9 pour ${today}`\n    }\n  }];\n}\n\n// \u26a0\ufe0f NOUVEAU : on choisit l'apr\u00e8s-midi EN PRIORIT\u00c9\nlet openTime = null;\n\n// Si open_time_afternoon existe \u2192 on l'utilise\nif (entry.open_time_afternoon && entry.open_time_afternoon.trim() !== \"\") {\n  openTime = entry.open_time_afternoon;\n}\n// Sinon fallback sur open_time\nelse if (entry.open_time && entry.open_time.trim() !== \"\") {\n  openTime = entry.open_time;\n}\n\n// Construire une Date compl\u00e8te (aujourd\u2019hui + heure d\u2019ouverture)\nlet dueDate = null;\nif (openTime) {\n  const todayStr = new Date().toISOString().split(\"T\")[0];\n  dueDate = new Date(`${todayStr}T${openTime}:00`).getTime(); // timestamp\n}\n\nreturn [{\n  json: {\n    name: items[0].json.body.name,\n    email_agent: items[0].json.body.email_agent,\n    openTime,\n    dueDate\n  }\n}];\n",
        "notice": ""
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -2144,
        320
      ],
      "id": "fc99f41b-418c-472a-9144-4650a908b640",
      "name": "Code1"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "d14d3353-35ea-462b-a68a-1ac8d20993e0",
              "leftValue": "={{ $json.body.time }}",
              "rightValue": "morning",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "looseTypeValidation": false,
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -2368,
        832
      ],
      "id": "b777301d-07ae-4b5c-8cc0-766e0658dd80",
      "name": "If"
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "// R\u00e9cup\u00e9ration des horaires depuis le webhook\nconst hours = items[0].json.body.office_opening_hours;\n\n// S\u00e9curit\u00e9 : si rien trouv\u00e9 \u2192 erreur lisible\nif (!hours) {\n  throw new Error(\"office_opening_hours introuvable dans items[0].json.body\");\n}\n\n// Jour actuel en MAJ (MONDAY, TUESDAY\u2026)\nconst today = new Date().toLocaleString('en-US', { weekday: 'long' }).toUpperCase();\n\n// Cherche l\u2019entr\u00e9e correspondant au jour actuel\nconst entry = hours.find(h => h.days.includes(today));\n\n// Si aucun bloc trouv\u00e9 \u2192 on met dueDate \u00e0 null\nif (!entry) {\n  return [{\n    json: {\n      name: items[0].json.body.name,\n      email_agent: items[0].json.body.email_agent,\n      openTime: null,\n      dueDate: null,\n      message: `Aucun cr\u00e9neau trouv\u00e9 pour ${today}`\n    }\n  }];\n}\n\n// On choisit l\u2019heure d\u2019ouverture prioritaire\nlet openTime = entry.open_time || entry.open_time_afternoon;\n\n// Si aucune heure trouv\u00e9e \u2192 null\nif (!openTime || openTime.trim() === \"\") {\n  openTime = null;\n}\n\n// Construire une Date compl\u00e8te (aujourd\u2019hui + heure d\u2019ouverture)\nlet dueDate = null;\nif (openTime) {\n  const todayStr = new Date().toISOString().split(\"T\")[0];\n  dueDate = new Date(`${todayStr}T${openTime}:00`).getTime(); // timestamp\n}\n\nreturn [{\n  json: {\n    name: items[0].json.body.name,\n    email_agent: items[0].json.body.email_agent,\n    openTime,\n    dueDate\n  }\n}];\n",
        "notice": ""
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -2144,
        1328
      ],
      "id": "9786200d-25c9-41ad-b847-a12728ec4f65",
      "name": "Code2"
    },
    {
      "parameters": {
        "mode": "rules",
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.email_agent }}",
                    "rightValue": "d.bensimon@permifast.com",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "fb364a80-d316-4cdb-b409-d56419826e3d"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": false
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "afc805ec-b73e-421c-ac2c-566f7de9e672",
                    "leftValue": "={{ $json.email_agent }}",
                    "rightValue": "lea@permifast.com",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": false
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "f7a31799-4b6c-4962-84fa-e1dae65a8497",
                    "leftValue": "={{ $json.email_agent }}",
                    "rightValue": "m.shana@permifast.com",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": false
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "deca85ab-f3e0-4938-8a90-b407a4135572",
                    "leftValue": "={{ $json.email_agent }}",
                    "rightValue": "g.lounes@permifast.com",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": false
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "2db6fb11-214e-4aa0-9a37-f340b78bf0f6",
                    "leftValue": "={{ $json.email_agent }}",
                    "rightValue": "gad@permifast.com",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": false
            }
          ]
        },
        "looseTypeValidation": false,
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        -1920,
        1280
      ],
      "id": "1f5f99b9-12d0-43cd-ae5a-0256d2b25380",
      "name": "Switch2"
    },
    {
      "parameters": {
        "authentication": "accessToken",
        "resource": "task",
        "operation": "create",
        "team": "9012457899",
        "space": "90125634468",
        "folderless": true,
        "list": "901214117329",
        "name": "={{ $json.name }}",
        "additionalFields": {
          "assignees": [
            254575423
          ],
          "dueDate": "={{ $json.dueDate }}",
          "dueDateTime": true,
          "status": "rdv pris"
        }
      },
      "type": "n8n-nodes-base.clickUp",
      "typeVersion": 1,
      "position": [
        -1696,
        928
      ],
      "id": "e96344f8-9bb1-49f1-af03-5ed0653b68c0",
      "name": "dan2",
      "credentials": {
        "clickUpApi": {
          "id": "kCX5iMbeH1ogaZ4t",
          "name": "ClickUp account"
        }
      }
    },
    {
      "parameters": {
        "authentication": "accessToken",
        "resource": "task",
        "operation": "create",
        "team": "9012457899",
        "space": "90125634468",
        "folderless": true,
        "list": "901214117329",
        "name": "={{ $json.body.name }}",
        "additionalFields": {
          "assignees": [
            87773546
          ],
          "dueDate": "={{ $json.body.time }}",
          "dueDateTime": true,
          "status": "rdv pris"
        }
      },
      "type": "n8n-nodes-base.clickUp",
      "typeVersion": 1,
      "position": [
        -1696,
        1120
      ],
      "id": "fc3c8952-7dca-42a3-82ed-817205e03e0c",
      "name": "lea2",
      "credentials": {
        "clickUpApi": {
          "id": "kCX5iMbeH1ogaZ4t",
          "name": "ClickUp account"
        }
      }
    },
    {
      "parameters": {
        "authentication": "accessToken",
        "resource": "task",
        "operation": "create",
        "team": "9012457899",
        "space": "90125634468",
        "folderless": true,
        "list": "901214117329",
        "name": "={{ $json.body.name }}",
        "additionalFields": {
          "assignees": [
            93787036
          ],
          "dueDate": "={{ $json.body.time }}",
          "dueDateTime": true,
          "status": "rdv pris"
        }
      },
      "type": "n8n-nodes-base.clickUp",
      "typeVersion": 1,
      "position": [
        -1696,
        1328
      ],
      "id": "77e9d416-ae36-4b61-b550-4b69437d91f6",
      "name": "shana2",
      "credentials": {
        "clickUpApi": {
          "id": "kCX5iMbeH1ogaZ4t",
          "name": "ClickUp account"
        }
      }
    },
    {
      "parameters": {
        "authentication": "accessToken",
        "resource": "task",
        "operation": "create",
        "team": "9012457899",
        "space": "90125634468",
        "folderless": true,
        "list": "901214117329",
        "name": "={{ $json.body.name }}",
        "additionalFields": {
          "assignees": [
            93787035
          ],
          "dueDate": "={{ $json.body.time }}",
          "dueDateTime": true,
          "status": "rdv pris"
        }
      },
      "type": "n8n-nodes-base.clickUp",
      "typeVersion": 1,
      "position": [
        -1696,
        1520
      ],
      "id": "d34089fd-5e64-4380-a03b-9447d15d6553",
      "name": "lounes2",
      "credentials": {
        "clickUpApi": {
          "id": "kCX5iMbeH1ogaZ4t",
          "name": "ClickUp account"
        }
      }
    },
    {
      "parameters": {
        "authentication": "accessToken",
        "resource": "task",
        "operation": "create",
        "team": "9012457899",
        "space": "90125634468",
        "folderless": true,
        "list": "901214117329",
        "name": "={{ $json.body.name }}",
        "additionalFields": {
          "assignees": [
            81767320
          ],
          "dueDate": "={{ $json.body.time }}",
          "dueDateTime": true,
          "status": "rdv pris"
        }
      },
      "type": "n8n-nodes-base.clickUp",
      "typeVersion": 1,
      "position": [
        -1696,
        1728
      ],
      "id": "0f7de2ba-0747-45bc-9099-5cdca1e8cac2",
      "name": "gad2",
      "credentials": {
        "clickUpApi": {
          "id": "kCX5iMbeH1ogaZ4t",
          "name": "ClickUp account"
        }
      }
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "// --- 1) R\u00e9cup\u00e9ration s\u00e9curis\u00e9e des donn\u00e9es depuis $json ---\nconst body = $('Webhook').first().json.body;\nconst hours = body?.office_opening_hours;\n\nif (!hours) {\n  throw new Error(\"office_opening_hours introuvable dans $json.body\");\n}\n\n\n// --- 2) Jour actuel en majuscules (Europe/Paris) ---\nconst today = new Date().toLocaleString(\"en-US\", {\n  weekday: \"long\",\n  timeZone: \"Europe/Paris\"\n}).toUpperCase();\n\n\n// --- 3) Recherche de l'entr\u00e9e correspondant au jour ---\nconst entry = hours.find(h => Array.isArray(h.days) && h.days.includes(today));\n\nif (!entry) {\n  return [{\n    json: {\n      name: body.name,\n      email_agent: body.email_agent,\n      openTime: null,\n      dueDate: null,\n      message: `Aucun horaire trouv\u00e9 pour ${today}`\n    }\n  }];\n}\n\n\n// --- 4) Normalisation des heures (g\u00e8re \"9:00\" -> \"09:00\") ---\nfunction normalizeTime(t) {\n  if (!t || typeof t !== \"string\") return null;\n\n  const parts = t.split(\":\");\n  if (parts.length !== 2) return null;\n\n  const hh = parts[0].padStart(2, \"0\");\n  const mm = parts[1].padStart(2, \"0\");\n\n  return `${hh}:${mm}`;\n}\n\n\n// --- 5) Choix de l'heure : matin puis apr\u00e8s-midi en fallback ---\nlet openTime =\n  normalizeTime(entry.open_time) ||\n  normalizeTime(entry.open_time_afternoon);\n\nif (!openTime) {\n  return [{\n    json: {\n      name: body.name,\n      email_agent: body.email_agent,\n      openTime: null,\n      dueDate: null,\n      message: `Aucune heure valide trouv\u00e9e pour ${today}`\n    }\n  }];\n}\n\n\n// --- 6) Construction du timestamp ---\nconst todayStr = new Date().toLocaleDateString(\"fr-CA\", { timeZone: \"Europe/Paris\" });\n// fr-CA = 2025-02-19\n\nconst dateObj = new Date(`${todayStr}T${openTime}:00`);\n\nif (isNaN(dateObj.getTime())) {\n  return [{\n    json: {\n      name: body.name,\n      email_agent: body.email_agent,\n      openTime,\n      dueDate: null,\n      message: `Heure invalide d\u00e9tect\u00e9e : ${openTime}`\n    }\n  }];\n}\n\nconst dueDate = dateObj.getTime();\n\n\n// --- 7) Retour final ---\nreturn [{\n  json: {\n    name: body.name,\n    email_agent: body.email_agent,\n    openTime,\n    first_name: $input.first().json.first_name,\n    school_number: $input.first().json.school_number,\n    school_address: $input.first().json.school_address,\n    dueDate\n  }\n}];\n",
        "notice": ""
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -1488,
        3392
      ],
      "id": "cc776842-680a-40c8-84df-2afa46e892cf",
      "name": "Code3"
    },
    {
      "parameters": {
        "authentication": "accessToken",
        "resource": "task",
        "operation": "create",
        "team": "9012457899",
        "space": "90125634468",
        "folderless": true,
        "list": "901214117329",
        "name": "={{ $json.name }}",
        "additionalFields": {
          "assignees": [
            254575423
          ],
          "customFieldsJson": "=[\n  {\n    \"id\": \"c00b73b8-eafb-443e-9868-dfcc0ba9511a\",\n    \"value\": \"{{ $json.first_name }}\"\n  },\n  {\n    \"id\": \"97d99530-d40c-4927-9b54-772473180768\",\n    \"value\": \"{{ $json.school_number }}\"\n  }\n]\n",
          "dueDate": "={{ $json.dueDate }}",
          "dueDateTime": true,
          "status": "rdv pris"
        }
      },
      "type": "n8n-nodes-base.clickUp",
      "typeVersion": 1,
      "position": [
        -1040,
        2992
      ],
      "id": "7b271fbd-4c18-40d0-8420-bc23cd7a79e5",
      "name": "dan3",
      "credentials": {
        "clickUpApi": {
          "id": "kCX5iMbeH1ogaZ4t",
          "name": "ClickUp account"
        }
      }
    },
    {
      "parameters": {
        "mode": "rules",
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.email_agent }}",
                    "rightValue": "d.bensimon@permifast.com",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "fb364a80-d316-4cdb-b409-d56419826e3d"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": false
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "afc805ec-b73e-421c-ac2c-566f7de9e672",
                    "leftValue": "={{ $json.email_agent }}",
                    "rightValue": "lea@permifast.com",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": false
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "f7a31799-4b6c-4962-84fa-e1dae65a8497",
                    "leftValue": "={{ $json.email_agent }}",
                    "rightValue": "m.shana@permifast.com",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": false
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "deca85ab-f3e0-4938-8a90-b407a4135572",
                    "leftValue": "={{ $json.email_agent }}",
                    "rightValue": "g.lounes@permifast.com",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": false
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "2db6fb11-214e-4aa0-9a37-f340b78bf0f6",
                    "leftValue": "={{ $json.email_agent }}",
                    "rightValue": "gad@permifast.com",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": false
            }
          ]
        },
        "looseTypeValidation": false,
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        -1264,
        3344
      ],
      "id": "4aa2c6a4-4b14-4be9-b6ab-c8d0578cd991",
      "name": "Switch3"
    },
    {
      "parameters": {
        "authentication": "accessToken",
        "resource": "task",
        "operation": "create",
        "team": "9012457899",
        "space": "90125634468",
        "folderless": true,
        "list": "901214117329",
        "name": "={{ $json.name }}",
        "additionalFields": {
          "assignees": [
            87773546
          ],
          "customFieldsJson": "=[\n  {\n    \"id\": \"c00b73b8-eafb-443e-9868-dfcc0ba9511a\",\n    \"value\": \"{{ $json.first_name }}\"\n  },\n  {\n    \"id\": \"97d99530-d40c-4927-9b54-772473180768\",\n    \"value\": \"{{ $json.school_number }}\"\n  }\n]\n",
          "dueDate": "={{ $json.dueDate }}",
          "dueDateTime": true,
          "status": "rdv pris"
        }
      },
      "type": "n8n-nodes-base.clickUp",
      "typeVersion": 1,
      "position": [
        -1040,
        3184
      ],
      "id": "7c963730-f7d6-4ff9-9eb7-f1772ec7eff5",
      "name": "lea3",
      "credentials": {
        "clickUpApi": {
          "id": "kCX5iMbeH1ogaZ4t",
          "name": "ClickUp account"
        }
      }
    },
    {
      "parameters": {
        "authentication": "accessToken",
        "resource": "task",
        "operation": "create",
        "team": "9012457899",
        "space": "90125634468",
        "folderless": true,
        "list": "901214117329",
        "name": "={{ $json.name }}",
        "additionalFields": {
          "assignees": [
            93787036
          ],
          "customFieldsJson": "=[\n  {\n    \"id\": \"c00b73b8-eafb-443e-9868-dfcc0ba9511a\",\n    \"value\": \"{{ $json.first_name }}\"\n  },\n  {\n    \"id\": \"97d99530-d40c-4927-9b54-772473180768\",\n    \"value\": \"{{ $json.school_number }}\"\n  }\n]\n",
          "dueDate": "={{ $json.dueDate }}",
          "dueDateTime": true,
          "status": "rdv pris"
        }
      },
      "type": "n8n-nodes-base.clickUp",
      "typeVersion": 1,
      "position": [
        -1040,
        3392
      ],
      "id": "a8e0cf22-9e22-416b-bfd7-33479af6b874",
      "name": "shana3",
      "credentials": {
        "clickUpApi": {
          "id": "kCX5iMbeH1ogaZ4t",
          "name": "ClickUp account"
        }
      }
    },
    {
      "parameters": {
        "authentication": "accessToken",
        "resource": "task",
        "operation": "create",
        "team": "9012457899",
        "space": "90125634468",
        "folderless": true,
        "list": "901214117329",
        "name": "={{ $json.name }}",
        "additionalFields": {
          "assignees": [
            93787035
          ],
          "customFieldsJson": "=[\n  {\n    \"id\": \"c00b73b8-eafb-443e-9868-dfcc0ba9511a\",\n    \"value\": \"{{ $json.first_name }}\"\n  },\n  {\n    \"id\": \"97d99530-d40c-4927-9b54-772473180768\",\n    \"value\": \"{{ $json.school_number }}\"\n  }\n]\n",
          "dueDate": "={{ $json.dueDate }}",
          "dueDateTime": true,
          "status": "rdv pris"
        }
      },
      "type": "n8n-nodes-base.clickUp",
      "typeVersion": 1,
      "position": [
        -1040,
        3584
      ],
      "id": "2107d266-59b8-4ac4-8bfc-3d5d27b6383c",
      "name": "lounes3",
      "credentials": {
        "clickUpApi": {
          "id": "kCX5iMbeH1ogaZ4t",
          "name": "ClickUp account"
        }
      }
    },
    {
      "parameters": {
        "authentication": "accessToken",
        "resource": "task",
        "operation": "create",
        "team": "9012457899",
        "space": "90125634468",
        "folderless": true,
        "list": "901214117329",
        "name": "={{ $json.name }}",
        "additionalFields": {
          "assignees": [
            81767320
          ],
          "customFieldsJson": "=[\n  {\n    \"id\": \"c00b73b8-eafb-443e-9868-dfcc0ba9511a\",\n    \"value\": \"{{ $json.first_name }}\"\n  },\n  {\n    \"id\": \"97d99530-d40c-4927-9b54-772473180768\",\n    \"value\": \"{{ $json.school_number }}\"\n  }\n]\n",
          "dueDate": "={{ $json.dueDate }}",
          "dueDateTime": true,
          "status": "rdv pris"
        }
      },
      "type": "n8n-nodes-base.clickUp",
      "typeVersion": 1,
      "position": [
        -1040,
        3792
      ],
      "id": "e5846aa8-cf0c-4922-bc9f-302f2f384792",
      "name": "gad3",
      "credentials": {
        "clickUpApi": {
          "id": "kCX5iMbeH1ogaZ4t",
          "name": "ClickUp account"
        }
      }
    },
    {
      "parameters": {
        "authentication": "accessToken",
        "resource": "task",
        "operation": "getAll",
        "team": "9012457899",
        "space": "90125634468",
        "folderless": true,
        "list": "901214117329",
        "returnAll": true,
        "filters": {}
      },
      "type": "n8n-nodes-base.clickUp",
      "typeVersion": 1,
      "position": [
        -2144,
        2880
      ],
      "id": "231083de-1a74-4a69-b296-716d1e2f7790",
      "name": "ClickUp",
      "credentials": {
        "clickUpApi": {
          "id": "kCX5iMbeH1ogaZ4t",
          "name": "ClickUp account"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "514a37bf-55f5-468c-8c45-2384b5743426",
              "leftValue": "={{ $json.taskExists }}",
              "rightValue": "=true",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "looseTypeValidation": false,
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -1696,
        2880
      ],
      "id": "da3dcb58-a6f8-4d2a-84c3-209e78131a14",
      "name": "If1",
      "executeOnce": false
    },
    {
      "parameters": {
        "generalNotice": "",
        "respondWith": "json",
        "webhookNotice": "",
        "responseBody": "={\n  \"assignee\": \"{{ $json.assignee }}\",\n  \"email_agent\": \"d.bensimon@permifast.com\",\n  \"exist\": \"{{ $json.exist }}\"\n} ",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.3,
      "position": [
        -1040,
        1984
      ],
      "id": "c4c895b6-b796-4d5f-a776-75f9ef9244b2",
      "name": "Respond to Webhook"
    },
    {
      "parameters": {
        "mode": "manual",
        "duplicateItem": false,
        "assignments": {
          "assignments": [
            {
              "id": "a5d0f39f-9484-4f74-8ed3-14d2d593f812",
              "name": "exist",
              "value": true,
              "type": "boolean"
            },
            {
              "id": "4fe0ace9-7bad-44da-9b8a-5d319e671d4f",
              "name": "assignee",
              "value": "={{ $json.assignee }}",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": false,
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -1488,
        2384
      ],
      "id": "ee512cde-15dd-4b4b-9510-4c0d2b88b4a8",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "// Nom envoy\u00e9 par le Webhook\nconst webhookName = $('Webhook').first().json.body.name;\n\nlet exists = false;\nlet assignee = null;\n\n// Parcourt toutes les t\u00e2ches ClickUp\nfor (const item of items) {\n\n  if (item.json.name === webhookName) {\n    exists = true;\n\n    // R\u00e9cup\u00e8re l'assignee r\u00e9el de la t\u00e2che trouv\u00e9e\n    if (item.json.assignees && item.json.assignees.length > 0) {\n      assignee = item.json.assignees[0].username || null;\n    }\n\n    break;\n  }\n}\n\nreturn [\n  {\n    json: {\n      taskExists: exists ? 'true' : 'false',\n      assignee: assignee,\n      first_name: $('Webhook').first().json.body.first_name,\n      school_number: $('Webhook').first().json.body.school_number,\n      school_address: $('Webhook').first().json.body.school_address,\n      webhookName,\n    }\n  }\n];\n",
        "notice": ""
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -1920,
        2880
      ],
      "id": "3bf82bb6-e9d0-49d2-890e-08fd9d1edb62",
      "name": "Code"
    },
    {
      "parameters": {
        "mode": "rules",
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.assignee }}",
                    "rightValue": "dan bensimon",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "44f6014d-c164-4d76-9e7f-44f4c2b8163f"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": false
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "69329432-bca4-495f-842f-4ea3993a95e9",
                    "leftValue": "={{ $json.assignee }}",
                    "rightValue": "Milhano Shana",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": false
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "43ebafc8-1e9c-47f2-82ef-e9ce16e7505a",
                    "leftValue": "={{ $json.assignee }}",
                    "rightValue": "Lea Biton",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": false
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "fdc44e2a-d1c0-4da4-b963-9527f9be4118",
                    "leftValue": "={{ $json.assignee }}",
                    "rightValue": "Lounes Garidi",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": false
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "e6b78524-455e-4de5-8fe2-8b97096ddd2a",
                    "leftValue": "={{ $json.assignee }}",
                    "rightValue": "Gad Biton",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": false
            }
          ]
        },
        "looseTypeValidation": false,
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        -1264,
        2352
      ],
      "id": "99531b88-b515-4824-930e-a87d79245fba",
      "name": "Switch"
    },
    {
      "parameters": {
        "generalNotice": "",
        "respondWith": "json",
        "webhookNotice": "",
        "responseBody": "={\n  \"assignee\": \"{{ $json.assignee }}\",\n  \"email_agent\": \"gad@permifast.com\",\n  \"exist\": \"{{ $json.exist }}\"\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.3,
      "position": [
        -1040,
        2784
      ],
      "id": "9ce9487e-bfeb-4a45-a016-7f6f7c7a260c",
      "name": "Respond to Webhook4"
    },
    {
      "parameters": {
        "generalNotice": "",
        "respondWith": "json",
        "webhookNotice": "",
        "responseBody": "={\n  \"assignee\": \"{{ $json.assignee }}\",\n  \"email_agent\": \"g.lounes@permifast.com\",\n  \"exist\": \"{{ $json.exist }}\"\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.3,
      "position": [
        -1040,
        2592
      ],
      "id": "76ce4bc8-fedb-4377-80bf-7549f796d5a1",
      "name": "Respond to Webhook2"
    },
    {
      "parameters": {
        "generalNotice": "",
        "respondWith": "json",
        "webhookNotice": "",
        "responseBody": "={\n  \"assignee\": \"{{ $json.assignee }}\",\n  \"email_agent\": \"lea@permifast.com\",\n  \"exist\": \"{{ $json.exist }}\"\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.3,
      "position": [
        -1040,
        2384
      ],
      "id": "1b764d67-d25c-4b9d-ad4a-7e0de103dd58",
      "name": "Respond to Webhook3"
    },
    {
      "parameters": {
        "generalNotice": "",
        "respondWith": "json",
        "webhookNotice": "",
        "responseBody": "={\n  \"assignee\": \"{{ $json.assignee }}\",\n  \"email_agent\": \"m.shana@permifast.com\",\n  \"exist\": \"{{ $json.exist }}\"\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.3,
      "position": [
        -1040,
        2192
      ],
      "id": "94e2a953-df82-4a1d-bb48-95520f9e7891",
      "name": "Respond to Webhook1"
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "// --- 1) R\u00e9cup\u00e9ration s\u00e9curis\u00e9e des donn\u00e9es depuis $json ---\nconst body = $('Webhook1').first().json.body;\nconst hours = body?.office_opening_hours;\n\nif (!hours) {\n  throw new Error(\"office_opening_hours introuvable dans $json.body\");\n}\n\n\n// --- 2) Jour actuel en majuscules (Europe/Paris) ---\nconst today = new Date().toLocaleString(\"en-US\", {\n  weekday: \"long\",\n  timeZone: \"Europe/Paris\"\n}).toUpperCase();\n\n\n// --- 3) Recherche de l'entr\u00e9e correspondant au jour ---\nconst entry = hours.find(h => Array.isArray(h.days) && h.days.includes(today));\n\nif (!entry) {\n  return [{\n    json: {\n      name: body.name,\n      email_agent: body.email_agent,\n      openTime: null,\n      dueDate: null,\n      message: `Aucun horaire trouv\u00e9 pour ${today}`\n    }\n  }];\n}\n\n\n// --- 4) Normalisation des heures (g\u00e8re \"9:00\" -> \"09:00\") ---\nfunction normalizeTime(t) {\n  if (!t || typeof t !== \"string\") return null;\n\n  const parts = t.split(\":\");\n  if (parts.length !== 2) return null;\n\n  const hh = parts[0].padStart(2, \"0\");\n  const mm = parts[1].padStart(2, \"0\");\n\n  return `${hh}:${mm}`;\n}\n\n\n// --- 5) Choix de l'heure : matin puis apr\u00e8s-midi en fallback ---\nlet openTime =\n  normalizeTime(entry.open_time) ||\n  normalizeTime(entry.open_time_afternoon);\n\nif (!openTime) {\n  return [{\n    json: {\n      name: body.name,\n      email_agent: body.email_agent,\n      openTime: null,\n      dueDate: null,\n      message: `Aucune heure valide trouv\u00e9e pour ${today}`\n    }\n  }];\n}\n\n\n// --- 6) Construction du timestamp ---\nconst todayStr = new Date().toLocaleDateString(\"fr-CA\", { timeZone: \"Europe/Paris\" });\n// fr-CA = 2025-02-19\n\nconst dateObj = new Date(`${todayStr}T${openTime}:00`);\n\nif (isNaN(dateObj.getTime())) {\n  return [{\n    json: {\n      name: body.name,\n      email_agent: body.email_agent,\n      openTime,\n      dueDate: null,\n      message: `Heure invalide d\u00e9tect\u00e9e : ${openTime}`\n    }\n  }];\n}\n\nconst dueDate = dateObj.getTime();\n\n\n// --- 7) Retour final ---\nreturn [{\n  json: {\n    name: body.name,\n    email_agent: body.email_agent,\n    openTime,\n    first_name: $input.first().json.first_name,\n    school_number: $input.first().json.school_number,\n    school_address: $input.first().json.school_address,\n    dueDate\n  }\n}];\n",
        "notice": ""
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -1696,
        5440
      ],
      "id": "f531fb0e-1350-4895-bcdf-0a6accbcf77d",
      "name": "Code4"
    },
    {
      "parameters": {
        "authentication": "accessToken",
        "resource": "task",
        "operation": "create",
        "team": "9012457899",
        "space": "90125634468",
        "folderless": true,
        "list": "901214117329",
        "name": "={{ $json.name }}",
        "additionalFields": {
          "assignees": [
            254575423
          ],
          "customFieldsJson": "=[\n  {\n    \"id\": \"c00b73b8-eafb-443e-9868-dfcc0ba9511a\",\n    \"value\": \"{{ $json.first_name }}\"\n  },\n  {\n    \"id\": \"97d99530-d40c-4927-9b54-772473180768\",\n    \"value\": \"{{ $json.school_number }}\"\n  },\n  {\n    \"id\": \"a83bab50-8dc7-4a61-9a61-b98f7715d7f1\",\n    \"value\": \"{{ $json.school_email }}\"\n  }\n\n]",
          "dueDate": "={{ $json.dueDate }}",
          "dueDateTime": true,
          "status": "rdv pris"
        }
      },
      "type": "n8n-nodes-base.clickUp",
      "typeVersion": 1,
      "position": [
        -1264,
        5040
      ],
      "id": "e25c5c60-d6ee-4647-8b56-ee2c7c030c4b",
      "name": "dan",
      "credentials": {
        "clickUpApi": {
          "id": "kCX5iMbeH1ogaZ4t",
          "name": "ClickUp account"
        }
      }
    },
    {
      "parameters": {
        "mode": "rules",
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.email_agent }}",
                    "rightValue": "d.bensimon@permifast.com",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "fb364a80-d316-4cdb-b409-d56419826e3d"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": false
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "afc805ec-b73e-421c-ac2c-566f7de9e672",
                    "leftValue": "={{ $json.email_agent }}",
                    "rightValue": "lea@permifast.com",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": false
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "f7a31799-4b6c-4962-84fa-e1dae65a8497",
                    "leftValue": "={{ $json.email_agent }}",
                    "rightValue": "m.shana@permifast.com",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": false
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "deca85ab-f3e0-4938-8a90-b407a4135572",
                    "leftValue": "={{ $json.email_agent }}",
                    "rightValue": "g.lounes@permifast.com",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": false
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "2db6fb11-214e-4aa0-9a37-f340b78bf0f6",
                    "leftValue": "={{ $json.email_agent }}",
                    "rightValue": "gad@permifast.com",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": false
            }
          ]
        },
        "looseTypeValidation": false,
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        -1488,
        5408
      ],
      "id": "357caaad-ec80-416e-a046-ccac07616bcf",
      "name": "Switch4"
    },
    {
      "parameters": {
        "authentication": "accessToken",
        "resource": "task",
        "operation": "create",
        "team": "9012457899",
        "space": "90125634468",
        "folderless": true,
        "list": "901214117329",
        "name": "={{ $json.name }}",
        "additionalFields": {
          "assignees": [
            87773546
          ],
          "customFieldsJson": "=[\n  {\n    \"id\": \"c00b73b8-eafb-443e-9868-dfcc0ba9511a\",\n    \"value\": \"{{ $json.first_name }}\"\n  },\n  {\n    \"id\": \"97d99530-d40c-4927-9b54-772473180768\",\n    \"value\": \"{{ $json.school_number }}\"\n  },\n  {\n    \"id\": \"a83bab50-8dc7-4a61-9a61-b98f7715d7f1\",\n    \"value\": \"{{ $json.school_email }}\"\n  }\n\n]",
          "dueDate": "={{ $json.dueDate }}",
          "dueDateTime": true,
          "status": "rdv pris"
        }
      },
      "type": "n8n-nodes-base.clickUp",
      "typeVersion": 1,
      "position": [
        -1264,
        5248
      ],
      "id": "966e886e-08ec-4d14-afe2-606ae62c073b",
      "name": "lea",
      "credentials": {
        "clickUpApi": {
          "id": "kCX5iMbeH1ogaZ4t",
          "name": "ClickUp account"
        }
      }
    },
    {
      "parameters": {
        "authentication": "accessToken",
        "resource": "task",
        "operation": "create",
        "team": "9012457899",
        "space": "90125634468",
        "folderless": true,
        "list": "901214117329",
        "name": "={{ $json.name }}",
        "additionalFields": {
          "assignees": [
            93787036
          ],
          "customFieldsJson": "=[\n  {\n    \"id\": \"c00b73b8-eafb-443e-9868-dfcc0ba9511a\",\n    \"value\": \"{{ $json.first_name }}\"\n  },\n  {\n    \"id\": \"97d99530-d40c-4927-9b54-772473180768\",\n    \"value\": \"{{ $json.school_number }}\"\n  },\n  {\n    \"id\": \"a83bab50-8dc7-4a61-9a61-b98f7715d7f1\",\n    \"value\": \"{{ $json.school_email }}\"\n  }\n\n]",
          "dueDate": "={{ $json.dueDate }}",
          "dueDateTime": true,
          "status": "rdv pris"
        }
      },
      "type": "n8n-nodes-base.clickUp",
      "typeVersion": 1,
      "position": [
        -1264,
        5440
      ],
      "id": "afdb4e91-d95f-4854-a312-fbf893ea1f63",
      "name": "shana",
      "credentials": {
        "clickUpApi": {
          "id": "kCX5iMbeH1ogaZ4t",
          "name": "ClickUp account"
        }
      }
    },
    {
      "parameters": {
        "authentication": "accessToken",
        "resource": "task",
        "operation": "create",
        "team": "9012457899",
        "space": "90125634468",
        "folderless": true,
        "list": "901214117329",
        "name": "={{ $json.name }}",
        "additionalFields": {
          "assignees": [
            93787035
          ],
          "customFieldsJson": "=[\n  {\n    \"id\": \"c00b73b8-eafb-443e-9868-dfcc0ba9511a\",\n    \"value\": \"{{ $json.first_name }}\"\n  },\n  {\n    \"id\": \"97d99530-d40c-4927-9b54-772473180768\",\n    \"value\": \"{{ $json.school_number }}\"\n  },\n  {\n    \"id\": \"a83bab50-8dc7-4a61-9a61-b98f7715d7f1\",\n    \"value\": \"{{ $json.school_email }}\"\n  }\n\n]",
          "dueDate": "={{ $json.dueDate }}",
          "dueDateTime": true,
          "status": "rdv pris"
        }
      },
      "type": "n8n-nodes-base.clickUp",
      "typeVersion": 1,
      "position": [
        -1264,
        5648
      ],
      "id": "1d794ef3-141f-4449-9315-e233b868d6d4",
      "name": "lounes",
      "credentials": {
        "clickUpApi": {
          "id": "kCX5iMbeH1ogaZ4t",
          "name": "ClickUp account"
        }
      }
    },
    {
      "parameters": {
        "authentication": "accessToken",
        "resource": "task",
        "operation": "create",
        "team": "9012457899",
        "space": "90125634468",
        "folderless": true,
        "list": "901214117329",
        "name": "={{ $json.name }}",
        "additionalFields": {
          "assignees": [
            81767320
          ],
          "customFieldsJson": "=[\n  {\n    \"id\": \"c00b73b8-eafb-443e-9868-dfcc0ba9511a\",\n    \"value\": \"{{ $json.first_name }}\"\n  },\n  {\n    \"id\": \"97d99530-d40c-4927-9b54-772473180768\",\n    \"value\": \"{{ $json.school_number }}\"\n  },\n  {\n    \"id\": \"a83bab50-8dc7-4a61-9a61-b98f7715d7f1\",\n    \"value\": \"{{ $json.school_email }}\"\n  }\n]",
          "dueDate": "={{ $json.dueDate }}",
          "dueDateTime": true,
          "status": "rdv pris"
        }
      },
      "type": "n8n-nodes-base.clickUp",
      "typeVersion": 1,
      "position": [
        -1264,
        5840
      ],
      "id": "8f9b981a-ee40-4be7-b3bf-3bf7fd25b700",
      "name": "gad",
      "credentials": {
        "clickUpApi": {
          "id": "kCX5iMbeH1ogaZ4t",
          "name": "ClickUp account"
        }
      }
    },
    {
      "parameters": {
        "authentication": "accessToken",
        "resource": "task",
        "operation": "getAll",
        "team": "9012457899",
        "space": "90125634468",
        "folderless": true,
        "list": "901214117329",
        "returnAll": true,
        "filters": {}
      },
      "type": "n8n-nodes-base.clickUp",
      "typeVersion": 1,
      "position": [
        -2368,
        4944
      ],
      "id": "ef968ec9-f3ae-4d77-bd40-b94303f4d3de",
      "name": "ClickUp1",
      "credentials": {
        "clickUpApi": {
          "id": "kCX5iMbeH1ogaZ4t",
          "name": "ClickUp account"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "514a37bf-55f5-468c-8c45-2384b5743426",
              "leftValue": "={{ $json.taskExists }}",
              "rightValue": "=true",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "looseTypeValidation": false,
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -1920,
        4944
      ],
      "id": "30897000-e019-4084-9b16-a97c18c4af55",
      "name": "If2",
      "executeOnce": false
    },
    {
      "parameters": {
        "generalNotice": "",
        "respondWith": "json",
        "webhookNotice": "",
        "responseBody": "={\n  \"assignee\": \"{{ $json.assignee }}\",\n  \"email_agent\": \"d.bensimon@permifast.com\",\n  \"exist\": \"{{ $json.exist }}\"\n} ",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.3,
      "position": [
        -1264,
        4048
      ],
      "id": "bc06dc8a-ead5-47d3-97dd-bd9876d389c9",
      "name": "Respond to Webhook5"
    },
    {
      "parameters": {
        "mode": "manual",
        "duplicateItem": false,
        "assignments": {
          "assignments": [
            {
              "id": "a5d0f39f-9484-4f74-8ed3-14d2d593f812",
              "name": "exist",
              "value": true,
              "type": "boolean"
            },
            {
              "id": "4fe0ace9-7bad-44da-9b8a-5d319e671d4f",
              "name": "assignee",
              "value": "={{ $json.assignee }}",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": false,
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -1696,
        4448
      ],
      "id": "d06f1ce3-c727-44d3-8316-48d769c81d38",
      "name": "Edit Fields1"
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "// Nom envoy\u00e9 par le Webhook\nconst webhookName = $('Webhook1').first().json.body.name;\n\nlet exists = false;\nlet assignee = null;\n\n// Parcourt toutes les t\u00e2ches ClickUp\nfor (const item of items) {\n\n  if (item.json.name === webhookName) {\n    exists = true;\n\n    // R\u00e9cup\u00e8re l'assignee r\u00e9el de la t\u00e2che trouv\u00e9e\n    if (item.json.assignees && item.json.assignees.length > 0) {\n      assignee = item.json.assignees[0].username || null;\n    }\n\n    break;\n  }\n}\n\nreturn [\n  {\n    json: {\n      taskExists: exists ? 'true' : 'false',\n      assignee: assignee,\n      first_name: $('Webhook1').first().json.body.firstname,\n      school_number: $('Webhook1').first().json.body.school_number,\n      school_address: $('Webhook1').first().json.body.school_address,\n      webhookName,\n    }\n  }\n];\n",
        "notice": ""
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -2144,
        4944
      ],
      "id": "c57f20cd-bf75-40f6-a0b8-9d6d9037a6f0",
      "name": "Code5"
    },
    {
      "parameters": {
        "mode": "rules",
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.assignee }}",
                    "rightValue": "dan bensimon",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "44f6014d-c164-4d76-9e7f-44f4c2b8163f"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": false
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "69329432-bca4-495f-842f-4ea3993a95e9",
                    "leftValue": "={{ $json.assignee }}",
                    "rightValue": "Milhano Shana",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": false
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "43ebafc8-1e9c-47f2-82ef-e9ce16e7505a",
                    "leftValue": "={{ $json.assignee }}",
                    "rightValue": "Lea Biton",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": false
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "fdc44e2a-d1c0-4da4-b963-9527f9be4118",
                    "leftValue": "={{ $json.assignee }}",
                    "rightValue": "Lounes Garidi",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": false
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "e6b78524-455e-4de5-8fe2-8b97096ddd2a",
                    "leftValue": "={{ $json.assignee }}",
                    "rightValue": "Gad Biton",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": false
            }
          ]
        },
        "looseTypeValidation": false,
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        -1488,
        4400
      ],
      "id": "ec2658bd-81c3-4cca-b3e9-b47cb5f0a2ef",
      "name": "Switch5"
    },
    {
      "parameters": {
        "generalNotice": "",
        "respondWith": "json",
        "webhookNotice": "",
        "responseBody": "={\n  \"assignee\": \"{{ $json.assignee }}\",\n  \"email_agent\": \"gad@permifast.com\",\n  \"exist\": \"{{ $json.exist }}\"\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.3,
      "position": [
        -1264,
        4848
      ],
      "id": "c932ccd9-829c-4336-bc11-15d7678b40a2",
      "name": "Respond to Webhook6"
    },
    {
      "parameters": {
        "generalNotice": "",
        "respondWith": "json",
        "webhookNotice": "",
        "responseBody": "={\n  \"assignee\": \"{{ $json.assignee }}\",\n  \"email_agent\": \"g.lounes@permifast.com\",\n  \"exist\": \"{{ $json.exist }}\"\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.3,
      "position": [
        -1264,
        4640
      ],
      "id": "e6aedc58-79a4-472a-8e1c-04c9afa5f150",
      "name": "Respond to Webhook7"
    },
    {
      "parameters": {
        "generalNotice": "",
        "respondWith": "json",
        "webhookNotice": "",
        "responseBody": "={\n  \"assignee\": \"{{ $json.assignee }}\",\n  \"email_agent\": \"lea@permifast.com\",\n  \"exist\": \"{{ $json.exist }}\"\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.3,
      "position": [
        -1264,
        4448
      ],
      "id": "31585ba0-8684-4b1b-a5ef-ce4e93ac1400",
      "name": "Respond to Webhook8"
    },
    {
      "parameters": {
        "generalNotice": "",
        "respondWith": "json",
        "webhookNotice": "",
        "responseBody": "={\n  \"assignee\": \"{{ $json.assignee }}\",\n  \"email_agent\": \"m.shana@permifast.com\",\n  \"exist\": \"{{ $json.exist }}\"\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.3,
      "position": [
        -1264,
        4240
      ],
      "id": "14be29bf-96f4-4dfe-9497-f5951ed6c8ce",
      "name": "Respond to Webhook9"
    },
    {
      "parameters": {
        "multipleMethods": false,
        "httpMethod": "POST",
        "path": "clickup",
        "authentication": "none",
        "responseMode": "responseNode",
        "webhookNotice": "",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -2640,
        4944
      ],
      "id": "de3d271a-1024-4bbc-a6a3-6c27778b9874",
      "name": "Webhook1",
      "webhookId": "1a776168-382a-48d2-b984-249805ab6820"
    }
  ],
  "connections": {
    "Switch1": {
      "main": [
        [
          {
            "node": "dan1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "lea1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "shana1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "lounes1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "gad1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code1": {
      "main": [
        [
          {
            "node": "Switch1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Code2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch2": {
      "main": [
        [
          {
            "node": "dan2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "lea2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "shana2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "lounes2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "gad2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code2": {
      "main": [
        [
          {
            "node": "Switch2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code3": {
      "main": [
        [
          {
            "node": "Switch3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch3": {
      "main": [
        [
          {
            "node": "dan3",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "lea3",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "shana3",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "lounes3",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "gad3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ClickUp": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If1": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Code3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "If1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Respond to Webhook1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Respond to Webhook3",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Respond to Webhook2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Respond to Webhook4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code4": {
      "main": [
        [
          {
            "node": "Switch4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch4": {
      "main": [
        [
          {
            "node": "dan",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "lea",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "shana",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "lounes",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "gad",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ClickUp1": {
      "main": [
        [
          {
            "node": "Code5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If2": {
      "main": [
        [
          {
            "node": "Edit Fields1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Code4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields1": {
      "main": [
        [
          {
            "node": "Switch5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code5": {
      "main": [
        [
          {
            "node": "If2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch5": {
      "main": [
        [
          {
            "node": "Respond to Webhook5",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Respond to Webhook9",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Respond to Webhook8",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Respond to Webhook7",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Respond to Webhook6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook1": {
      "main": [
        [
          {
            "node": "ClickUp1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "tags": [
    "HhChYWtb4zhvUvXU"
  ],
  "versionId": "2a38ca49-5395-481b-a3c0-e084600e46dd"
}