{
  "id": "t17g3EslFyjyAC2z",
  "name": "Appointment Management Workflow from Webhook to Data Handling",
  "tags": [],
  "nodes": [
    {
      "id": "10e6488e-3e47-4402-9179-7613a8fd5667",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -928,
        832
      ],
      "parameters": {
        "path": "46161ac6-9838-4b3d-ad4a-c8d62362a656",
        "options": {},
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "typeVersion": 2
    },
    {
      "id": "9962bc00-2813-473d-a67d-48cf05dc3cd4",
      "name": "Ollama Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOllama",
      "position": [
        -208,
        -256
      ],
      "parameters": {
        "model": "qwen3:14b",
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "dc049299-ff3c-4516-a487-3c9b3cb2330a",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        -480,
        784
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "ba2fd0c7-972d-4a38-942f-21240866629c",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Webhook').item.json.body.name }}",
                    "rightValue": "set_appointment"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "62f8ded3-8547-4921-9ae1-035a4ef89020",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Webhook').item.json.body.name }}",
                    "rightValue": "reschedule"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "71678a92-e3ec-4f12-82ba-1f6c1ce1a45d",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Webhook').item.json.body.name }}",
                    "rightValue": "cancel"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "3620cad0-f32d-468e-bbf9-bd7c84e7cbe8",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Webhook').item.json.body.name }}",
                    "rightValue": "get_list"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "a3afabec-d5f6-4367-9ff1-941bfb9a09ad",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Webhook').item.json.body.name }}",
                    "rightValue": "get_user_info"
                  }
                ]
              }
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "ccb7d426-607e-435c-99de-ea3b8c693cc1",
      "name": "Ollama Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOllama",
      "position": [
        -112,
        448
      ],
      "parameters": {
        "model": "qwen3:14b",
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "2e8bc411-5aab-44ad-9788-70f202da562d",
      "name": "Ollama Chat Model2",
      "type": "@n8n/n8n-nodes-langchain.lmChatOllama",
      "position": [
        -128,
        896
      ],
      "parameters": {
        "model": "qwen3:14b",
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "83761da7-d45f-42cf-88a4-aef988ff5138",
      "name": "Ollama Chat Model3",
      "type": "@n8n/n8n-nodes-langchain.lmChatOllama",
      "position": [
        -48,
        1424
      ],
      "parameters": {
        "model": "qwen3:14b",
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "7a046794-e471-4b08-b47b-5c30b68e9887",
      "name": "Ollama Chat Model4",
      "type": "@n8n/n8n-nodes-langchain.lmChatOllama",
      "position": [
        -32,
        2048
      ],
      "parameters": {
        "model": "qwen3:14b",
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "2fe0102e-a99c-40af-9aef-b3d6bb179f2e",
      "name": "Load Interviewers Table",
      "type": "n8n-nodes-base.supabaseTool",
      "position": [
        -16,
        -240
      ],
      "parameters": {
        "tableId": "Unitek_interviewers",
        "operation": "getAll",
        "returnAll": true,
        "descriptionType": "manual",
        "toolDescription": "Use it to get all the data in the interviewers table"
      },
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "8b461c16-fd3c-46be-877f-8d4abbde3223",
      "name": "Delete Interviewer Record",
      "type": "n8n-nodes-base.supabaseTool",
      "position": [
        80,
        -144
      ],
      "parameters": {
        "filters": {
          "conditions": [
            {
              "keyName": "interviewer name",
              "keyValue": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('conditions0_Field_Value', `name of the interviewer set for the enroller`, 'string') }}",
              "condition": "eq"
            },
            {
              "keyName": "available",
              "keyValue": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('conditions1_Field_Value', `date of the interview`, 'string') }}",
              "condition": "eq"
            }
          ]
        },
        "tableId": "Unitek_interviewers",
        "matchType": "allFilters",
        "operation": "delete",
        "descriptionType": "manual",
        "toolDescription": "Use it to delete the interviewer's row when you set an appointment."
      },
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "0e6f09ef-2214-4a7d-bdec-0982503915cb",
      "name": "Create Interview Record",
      "type": "n8n-nodes-base.supabaseTool",
      "position": [
        144,
        -272
      ],
      "parameters": {
        "tableId": "Unitek_enrollers",
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "enroller name",
              "fieldValue": "={{ $('Webhook').item.json.body.args.name }}"
            },
            {
              "fieldId": "interviewer name",
              "fieldValue": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('fieldValues1_Field_Value', `name of the interviewer assigned to the  enroller`, 'string') }}"
            },
            {
              "fieldId": "date of interview",
              "fieldValue": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('fieldValues2_Field_Value', `date of the interview`, 'string') }}"
            },
            {
              "fieldId": "email",
              "fieldValue": "={{ $('Webhook').item.json.body.args.email }}"
            },
            {
              "fieldId": "program",
              "fieldValue": "={{ $('Webhook').item.json.body.args.program }}"
            },
            {
              "fieldId": "location",
              "fieldValue": "={{ $('Webhook').item.json.body.args.location }}"
            },
            {
              "fieldId": "phone_number",
              "fieldValue": "={{ $('Webhook').item.json.body.args.phone_number }}"
            },
            {
              "fieldId": "nationality id",
              "fieldValue": "={{ $('Webhook').item.json.body.args.nationality_number }}"
            }
          ]
        }
      },
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "95636afa-f6d7-42c0-bb5b-7722da726fbb",
      "name": "Assign Interviewer & Schedule",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "onError": "continueRegularOutput",
      "position": [
        -128,
        -416
      ],
      "parameters": {
        "text": "={{ $('Appointment Actions').item.json.set_appointment }}\n/no_think",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 1.9
    },
    {
      "id": "a1856c44-cd9c-4e7f-80b4-bd99935fbf17",
      "name": "Load Interviewers Table1",
      "type": "n8n-nodes-base.supabaseTool",
      "position": [
        32,
        400
      ],
      "parameters": {
        "tableId": "Unitek_interviewers",
        "operation": "getAll",
        "returnAll": true,
        "descriptionType": "manual",
        "toolDescription": "Use it to get all the data in the interviewers table"
      },
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "0fa5eff3-e9bf-4edf-8ae2-7a1d532532da",
      "name": "Reinsert Previous Interview Slot",
      "type": "n8n-nodes-base.supabaseTool",
      "position": [
        160,
        432
      ],
      "parameters": {
        "tableId": "Unitek_interviewers",
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "interviewer name",
              "fieldValue": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('fieldValues0_Field_Value', `The previous interviewer's name for the enroller`, 'string') }}"
            },
            {
              "fieldId": "available",
              "fieldValue": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('fieldValues1_Field_Value', `the previous date set for the enroller`, 'string') }}"
            },
            {
              "fieldId": "id",
              "fieldValue": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('fieldValues2_Field_Value', `this should be a unique number that isn't already in the table`, 'string') }}"
            }
          ]
        },
        "descriptionType": "manual",
        "toolDescription": "Use it to create a new row in the interviews table"
      },
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "89a32c96-1a40-4194-b29c-59881ca61bf4",
      "name": "AI Rescheduling Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        48,
        192
      ],
      "parameters": {
        "text": "={{ $('Appointment Actions').item.json.reschedule }}\n/no_think",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 1.9
    },
    {
      "id": "0a139d5d-df5e-4a59-a299-a7bfb683d2f5",
      "name": "Update Enroller Record",
      "type": "n8n-nodes-base.supabaseTool",
      "position": [
        304,
        416
      ],
      "parameters": {
        "filters": {
          "conditions": [
            {
              "keyName": "nationality id",
              "keyValue": "={{ $json.body.args.nationality_number }}",
              "condition": "eq"
            }
          ]
        },
        "tableId": "Unitek_enrollers",
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "interviewer name",
              "fieldValue": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('fieldValues0_Field_Value', `New interviewer's name for the enroller`, 'string') }}"
            },
            {
              "fieldId": "date of interview",
              "fieldValue": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('fieldValues1_Field_Value', `New date set for the enroller`, 'string') }}"
            }
          ]
        },
        "operation": "update",
        "descriptionType": "manual",
        "toolDescription": "use it to update the enroller's row"
      },
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "f88fe086-146c-4ecc-b944-6e7d9e678c10",
      "name": "Load Enroller Record",
      "type": "n8n-nodes-base.supabaseTool",
      "position": [
        432,
        432
      ],
      "parameters": {
        "filters": {
          "conditions": [
            {
              "keyName": "nationality id",
              "keyValue": "={{ $json.body.args.nationality_number }}"
            }
          ]
        },
        "tableId": "Unitek_enrollers",
        "operation": "get",
        "descriptionType": "manual",
        "toolDescription": "Use it to get the enroller's row in the enrollers table"
      },
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "4346c44f-c0d7-4544-bc55-492a4dabd57f",
      "name": "Delete New Interview Slot",
      "type": "n8n-nodes-base.supabaseTool",
      "position": [
        560,
        384
      ],
      "parameters": {
        "filters": {
          "conditions": [
            {
              "keyName": "interviewer name",
              "keyValue": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('conditions0_Field_Value', `A new interviewer has been assigned to the enroller.`, 'string') }}",
              "condition": "eq"
            },
            {
              "keyName": "available",
              "keyValue": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('conditions1_Field_Value', `New date set for the appointment.`, 'string') }}",
              "condition": "eq"
            }
          ]
        },
        "tableId": "Unitek_interviewers",
        "operation": "delete",
        "descriptionType": "manual"
      },
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ae33a1fa-c2b0-4f16-9f7a-7ba69354922d",
      "name": "AI Cancellation Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -80,
        752
      ],
      "parameters": {
        "text": "={{ $('Appointment Actions').item.json.cancel }}\n/no_think",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 1.9
    },
    {
      "id": "3a7e68d9-cc19-4e0f-a141-2db7faf10128",
      "name": "Fetch Enroller Profile",
      "type": "n8n-nodes-base.supabaseTool",
      "position": [
        32,
        896
      ],
      "parameters": {
        "filters": {
          "conditions": [
            {
              "keyName": "nationality id",
              "keyValue": "={{ $json.body.args.nationality_number }}"
            }
          ]
        },
        "tableId": "Unitek_enrollers",
        "operation": "get",
        "descriptionType": "manual",
        "toolDescription": "Use it to get the enroller's row from the enrollers table"
      },
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "95bf0b8c-b6df-4b7b-b90f-4691ff75bbb2",
      "name": "Insert Available Interviewer",
      "type": "n8n-nodes-base.supabaseTool",
      "position": [
        160,
        896
      ],
      "parameters": {
        "tableId": "Unitek_interviewers",
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "id",
              "fieldValue": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('fieldValues0_Field_Value', `Must be a unique number`, 'string') }}"
            },
            {
              "fieldId": "interviewer name",
              "fieldValue": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('fieldValues1_Field_Value', `Interviewer's name.`, 'string') }}"
            },
            {
              "fieldId": "available",
              "fieldValue": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('fieldValues2_Field_Value', `Date of the canceled appointment.`, 'string') }}"
            }
          ]
        },
        "descriptionType": "manual",
        "toolDescription": "use it to create the interviewer's row in the interviewers table."
      },
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "af5442a1-656b-424a-896f-73a7e535ad37",
      "name": "Delete Enroller Record",
      "type": "n8n-nodes-base.supabaseTool",
      "position": [
        304,
        864
      ],
      "parameters": {
        "filters": {
          "conditions": [
            {
              "keyName": "nationality id",
              "keyValue": "={{ $json.body.args.nationality_number }}",
              "condition": "eq"
            }
          ]
        },
        "tableId": "Unitek_enrollers",
        "operation": "delete"
      },
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "3242afca-c246-41a1-91b3-414ec17311ed",
      "name": "AI Class List Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -48,
        1232
      ],
      "parameters": {
        "text": "={{ $('Appointment Actions').item.json.get_list }}\n/no_think",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 1.9
    },
    {
      "id": "ee80b6f2-24de-48ba-9cbe-32f57164a80f",
      "name": "Fetch Enroller Classes",
      "type": "n8n-nodes-base.supabaseTool",
      "position": [
        96,
        1424
      ],
      "parameters": {
        "filters": {
          "conditions": [
            {
              "keyName": "nationality number",
              "keyValue": "={{ $('Webhook').item.json.body.args.nationality_number }}"
            }
          ]
        },
        "tableId": "Unitek_classes",
        "operation": "get"
      },
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "854469b9-7db7-4741-9801-deb89085af3d",
      "name": "AI Enroller Info Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -32,
        1856
      ],
      "parameters": {
        "text": "={{ $('Appointment Actions').item.json.get_user_info }}\n/no_think",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 1.9
    },
    {
      "id": "cb023711-e01f-45d2-97fc-6f91b0067080",
      "name": "Fetch Enroller Record",
      "type": "n8n-nodes-base.supabaseTool",
      "position": [
        112,
        2032
      ],
      "parameters": {
        "filters": {
          "conditions": [
            {
              "keyName": "nationality id",
              "keyValue": "={{ $('Webhook').item.json.body.args.nationality_number }}"
            }
          ]
        },
        "tableId": "Unitek_enrollers",
        "operation": "get"
      },
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "761ed319-5fc7-4768-851c-e6e807b76ffa",
      "name": "Respond Appointment Booking",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        480,
        -320
      ],
      "parameters": {
        "options": {},
        "respondWith": "allIncomingItems"
      },
      "typeVersion": 1.2
    },
    {
      "id": "a033ebd2-fe1c-41fd-b8b0-dcd7ea87907b",
      "name": "Respond Appointment Reschedule",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        816,
        224
      ],
      "parameters": {
        "options": {},
        "respondWith": "allIncomingItems"
      },
      "typeVersion": 1.2
    },
    {
      "id": "2c380d6f-1f1b-430a-8ee8-96bdf2852107",
      "name": "Respond Appointment Cancellation",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        624,
        832
      ],
      "parameters": {
        "options": {},
        "respondWith": "allIncomingItems"
      },
      "typeVersion": 1.2
    },
    {
      "id": "ce1fbaff-db3b-40ba-b539-26a223d79b00",
      "name": "Respond Class List Request",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        272,
        1232
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "ee003ab0-3d7e-486b-87db-b3ca1e562d6e",
      "name": "Respond Enroller Info Request",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        304,
        1856
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "d761447c-d5c7-4a96-aece-13d712b1b8b3",
      "name": "Appointment Email",
      "type": "n8n-nodes-base.if",
      "position": [
        672,
        -320
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "5f23bf1e-0098-44de-be50-117165f16133",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $('Webhook').item.json.body.args.email }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "738c4946-e64f-4a83-8793-d26342e5ab18",
      "name": "Reschedule Email",
      "type": "n8n-nodes-base.if",
      "position": [
        1008,
        224
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "5f23bf1e-0098-44de-be50-117165f16133",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $('Webhook').item.json.body.args.email }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "7ce83d3c-12cb-4ac5-bfeb-c3cc9598b9ba",
      "name": "Cancel Email",
      "type": "n8n-nodes-base.if",
      "position": [
        816,
        832
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "5f23bf1e-0098-44de-be50-117165f16133",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $('Webhook').item.json.body.args.email }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "19494a1f-63e8-4751-9a46-f759af7a6ae1",
      "name": "Skip If No Email",
      "type": "n8n-nodes-base.noOp",
      "position": [
        896,
        -256
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "5681f516-3590-4be4-babb-d05c32dd2e7b",
      "name": "Skip If Email Exists",
      "type": "n8n-nodes-base.noOp",
      "position": [
        880,
        -416
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "2a69ab4e-35de-4afe-9efa-cdee59557009",
      "name": "Skip Reschedule If Email Exists",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1232,
        320
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "1887c68e-09a8-4441-8fbf-92eea38958e2",
      "name": "Skip Reschedule If No Email",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1232,
        128
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "55151fc2-4290-4a7e-8448-9743f37e8539",
      "name": "Skip Cancellation If Email Exists",
      "type": "n8n-nodes-base.noOp",
      "position": [
        992,
        928
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "ecefc9df-1fce-4e11-9be9-409f6f198e03",
      "name": "Skip Cancellation If No Email",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1008,
        736
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "411599a5-def3-4ef7-a141-f21744d06d28",
      "name": "Appointment Actions",
      "type": "n8n-nodes-base.set",
      "position": [
        -704,
        832
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "b7510700-d948-45f7-905f-b5c3242b5840",
              "name": "set_appointment",
              "type": "string",
              "value": "=You are going to set an appointment for {{ $json.body.args.name }}\n**Only follow the instructions provided.**\nname:   {{ $json.body.args.name }}\nnationality number:   {{ $json.body.args.nationality_number }}\nphone_number:   {{ $json.body.args.phone_number }}\nemail:   {{ $json.body.args.email }}\nlocation:   {{ $json.body.args.location }}\nprogram:   {{ $json.body.args.program }}\nSteps:\n1. Check the \"interviewers\" table for the earliest available interviewer.\n2. If no interviewers exist, output: {\"error\": \"No interviewers available\"}.\n3. Otherwise:\n  - creat a row in the \"Unitek_enrollers\".\n  - delete the interviewer's row in the \"Unitek_interviewers\"."
            },
            {
              "id": "70eb320e-4d09-4f31-8233-5f3556b8d01e",
              "name": "reschedule",
              "type": "string",
              "value": "=You are going to reschedule the appointment set for a user\n**Only follow the instructions provided.**\n\nnationality number:   {{ $json.body.args.nationality_number }}\nPreferred Date: {{ $json.body.args.preferred_date }} (format: YYYY-MM-DD)\nInstructions:\n1. Check the \"interviewers\" table for an interviewer with available date equal to the preferred date.\n2. If no exact match is found, search for the next closest available date after the preferred date.\n3. If still no interviewers are available at all, return this JSON:      {      \"error\": \"No interviewers available\"    }   4. Otherwise:\n  - Get the enroller row in the enrollers table.\n  - Create a new row in the interviewers table and add the previous interviewer of the enroller to it.\n  - Update the enroller row in the enrollers table.\n  - Delete the new interviewer's row in the interviewers table."
            },
            {
              "id": "2f9c9b2e-d1dc-412e-972c-6d6957567362",
              "name": "cancel",
              "type": "string",
              "value": "=You are going to cancel the appointment set for a user\n**Only follow the instructions provided.**\nnationality number:   {{ $json.body.args.nationality_number }}\nsteps:\n1. get the row of the enroller.\n2. create a row in the interviewers table and add the interviewer's of the enroller to it.\n3. delete the enroller's row in the enrollers table."
            },
            {
              "id": "597dcb18-e712-4293-b095-f4a5fd5dc2a9",
              "name": "get_list",
              "type": "string",
              "value": "=You will get the list of classes for a user\n**Only follow the instructions provided.**\nNationality number:    {{ $json.body.args.nationality_number }}\nsteps:\nGet the list of classes for the user\nReturn the list of classes in JSON format"
            },
            {
              "id": "b3ef10cc-09ce-44ff-9c9f-cd03ecc082db",
              "name": "get_user_info",
              "type": "string",
              "value": "=You will get the list of informations for a user\n**Only follow the instructions provided.**\nNationality number:    {{ $json.body.args.nationality_number }}\nsteps: Get the row for the user and Return the information as JSON format."
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "7bbfc1ff-6dd9-4056-a3ca-2c714e93e220",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -912,
        -368
      ],
      "parameters": {
        "width": 528,
        "height": 1072,
        "content": "## Who\u2019s it for\nThis workflow is designed for organizations or services managing appointments, such as interview scheduling, class enrollments, or client meetings. It\u2019s ideal for users who want to automate appointment creation, rescheduling, cancellation, and data retrieval from a single webhook endpoint.\n\n## How it works / What it does\n\u25cf Receives incoming appointment requests via a Webhook node.\n\u25cf Processes requests in the Set Fields node, handling multiple actions:\n        \u2022 Set Appointment: Adds a new appointment and assigns an available interviewer.\n        \u2022 Reschedule: Changes the appointment date based on availability.\n        \u2022 Cancel: Deletes an appointment and frees the interviewer\u2019s slot.\n        \u2022 Get List: Returns a user\u2019s list of classes.\n        \u2022 Get User Info: Retrieves detailed information about a specific user.\nAll actions follow strict instructions to check tables, update rows, and return structured JSON responses.\n\n## How to set up\n1. Add the Webhook node and set the HTTP method to POST.\n2. Connect it to the Set Fields node.\n3. Configure the Set Fields node with the desired assignments (set_appointment, reschedule, cancel, get_list, get_user_info).\n4. Ensure your database tables (interviewers, enrollers) are properly configured and accessible.\n\n## Requirements\n\u2022 n8n environment\n\u2022 Database or table access for interviewers and enrollers\n\u2022 Properly formatted incoming JSON requests with necessary fields (e.g., name, nationality number, preferred date).\n\n## How to customize the workflow\n\u2022 Add or modify assignment actions to handle additional appointment scenarios.\n\u2022 Adjust table names or database connections based on your environment.\n\u2022 Extend JSON responses for custom client-side handling."
      },
      "typeVersion": 1
    },
    {
      "id": "eaceb45a-df1e-4a5b-9c9f-6590b4db3461",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -288,
        -560
      ],
      "parameters": {
        "color": 7,
        "width": 672,
        "height": 592,
        "content": "## Schedule Interviews Section\nHandles all steps for assigning an interviewer and creating the interview record.\nIncludes loading available interviewers, scheduling appointments, deleting old records, and creating new ones in the enrollers table."
      },
      "typeVersion": 1
    },
    {
      "id": "b3ee189d-3ef0-434a-8aa9-60fcc2dc3c07",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        432,
        -560
      ],
      "parameters": {
        "color": 7,
        "width": 608,
        "height": 496,
        "content": "## Email Validation Section\nChecks if the appointment request includes an email.\nSkips further actions if the email is missing or already exists, ensuring only valid requests proceed."
      },
      "typeVersion": 1
    },
    {
      "id": "8cabfafa-bb7d-41f2-97d9-dc9e3e813ad1",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -208,
        64
      ],
      "parameters": {
        "color": 7,
        "width": 912,
        "height": 512,
        "content": "## Appointment Rescheduling Section\nHandles rescheduling of enrollers\u2019 appointments.\nLoads previous and new interviewer slots, updates the enroller\u2019s record, reinserts or deletes interview slots, and uses AI to assign the optimal schedule."
      },
      "typeVersion": 1
    },
    {
      "id": "ca2a864f-86a3-4cda-a3b1-af2a9f44109c",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        768,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 736,
        "height": 512,
        "content": "## Appointment Reschedule Notification Section\nHandles rescheduling appointments and sending notifications.\nValidates email input, skips actions if necessary, and sends appointment reschedule responses."
      },
      "typeVersion": 1
    },
    {
      "id": "b47b240a-e45c-4901-9131-4af181b9d204",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -160,
        624
      ],
      "parameters": {
        "color": 7,
        "width": 672,
        "height": 416,
        "content": "## Appointment Cancellation Section\nManages appointment cancellations, reassigns interviewers, and updates records.\nHandles cancellation logic and updates the enroller and interviewer tables accordingly."
      },
      "typeVersion": 1
    },
    {
      "id": "bbdc1ad1-e203-4232-9e93-aee92ff5c496",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        560,
        608
      ],
      "parameters": {
        "color": 7,
        "width": 720,
        "height": 544,
        "content": "## Cancellation Email Handling\nManages sending email notifications after an appointment is canceled.\nHandles conditional logic to skip sending emails if the recipient address is missing or already processed."
      },
      "typeVersion": 1
    },
    {
      "id": "97d461ab-77fa-479f-8e7a-5252439ba3dd",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -96,
        1088
      ],
      "parameters": {
        "color": 7,
        "width": 608,
        "height": 512,
        "content": "## Class List Retrieval\nHandles fetching and responding with the list of classes for a given enroller.\nUses AI to process the request and query the Supabase database before sending the result back via webhook."
      },
      "typeVersion": 1
    },
    {
      "id": "1b0485ca-fb05-4edc-86aa-825e4eaebb7c",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        1664
      ],
      "parameters": {
        "color": 7,
        "width": 592,
        "height": 576,
        "content": "## Enroller Information Retrieval\nFetches and responds with detailed information about an enroller.\nAI processes the request, queries the Supabase enrollers table, and returns the data via webhook."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "9f698297-dde3-4173-ba6b-2e3d408b2dfc",
  "connections": {
    "Switch": {
      "main": [
        [
          {
            "node": "Assign Interviewer & Schedule",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "AI Rescheduling Agent",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "AI Cancellation Agent",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "AI Class List Agent",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "AI Enroller Info Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "Appointment Actions",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Cancel Email": {
      "main": [
        [
          {
            "node": "Skip Cancellation If No Email",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Skip Cancellation If Email Exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reschedule Email": {
      "main": [
        [
          {
            "node": "Skip Reschedule If No Email",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Skip Reschedule If Email Exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Appointment Email": {
      "main": [
        [
          {
            "node": "Skip If Email Exists",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Skip If No Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ollama Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Assign Interviewer & Schedule",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Ollama Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "AI Rescheduling Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Ollama Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "AI Cancellation Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Ollama Chat Model3": {
      "ai_languageModel": [
        [
          {
            "node": "AI Class List Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Ollama Chat Model4": {
      "ai_languageModel": [
        [
          {
            "node": "AI Enroller Info Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "AI Class List Agent": {
      "main": [
        [
          {
            "node": "Respond Class List Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Appointment Actions": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Load Enroller Record": {
      "ai_tool": [
        [
          {
            "node": "AI Rescheduling Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "AI Cancellation Agent": {
      "main": [
        [
          {
            "node": "Respond Appointment Cancellation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Rescheduling Agent": {
      "main": [
        [
          {
            "node": "Respond Appointment Reschedule",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Enroller Record": {
      "ai_tool": [
        [
          {
            "node": "AI Enroller Info Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "AI Enroller Info Agent": {
      "main": [
        [
          {
            "node": "Respond Enroller Info Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Delete Enroller Record": {
      "ai_tool": [
        [
          {
            "node": "AI Cancellation Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Enroller Classes": {
      "ai_tool": [
        [
          {
            "node": "AI Class List Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Enroller Profile": {
      "ai_tool": [
        [
          {
            "node": "AI Cancellation Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Update Enroller Record": {
      "ai_tool": [
        [
          {
            "node": "AI Rescheduling Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Create Interview Record": {
      "ai_tool": [
        [
          {
            "node": "Assign Interviewer & Schedule",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Load Interviewers Table": {
      "ai_tool": [
        [
          {
            "node": "Assign Interviewer & Schedule",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Load Interviewers Table1": {
      "ai_tool": [
        [
          {
            "node": "AI Rescheduling Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Delete Interviewer Record": {
      "ai_tool": [
        [
          {
            "node": "Assign Interviewer & Schedule",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Delete New Interview Slot": {
      "ai_tool": [
        [
          {
            "node": "AI Rescheduling Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Respond Appointment Booking": {
      "main": [
        [
          {
            "node": "Appointment Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Insert Available Interviewer": {
      "ai_tool": [
        [
          {
            "node": "AI Cancellation Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Assign Interviewer & Schedule": {
      "main": [
        [
          {
            "node": "Respond Appointment Booking",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Respond Appointment Reschedule": {
      "main": [
        [
          {
            "node": "Reschedule Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reinsert Previous Interview Slot": {
      "ai_tool": [
        [
          {
            "node": "AI Rescheduling Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Respond Appointment Cancellation": {
      "main": [
        [
          {
            "node": "Cancel Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}