{
  "nodes": [
    {
      "id": "89d3c9e8-e4cc-4a28-80ab-7f7661491168",
      "name": "No Operation, do nothing3",
      "type": "n8n-nodes-base.noOp",
      "position": [
        320,
        400
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "5c41293e-18e8-49eb-94bd-442d4c1fc373",
      "name": "End session1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        96,
        32
      ],
      "parameters": {
        "url": "={{ $('Configuration Variables').item.json.glpi_url }}apirest.php/killSession",
        "options": {},
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Session-Token",
              "value": "={{ $('Get session token').item.json.session_token }}"
            },
            {
              "name": "App-Token",
              "value": "={{ $('Configuration Variables').item.json.app_token }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "d15822e3-b973-457a-9706-779958ff44b1",
      "name": "No Operation, do nothing2",
      "type": "n8n-nodes-base.noOp",
      "position": [
        320,
        32
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "d33d8698-b491-4d09-8ea0-ce2d9feb9e95",
      "name": "Configuration Variables",
      "type": "n8n-nodes-base.set",
      "position": [
        -1248,
        560
      ],
      "parameters": {
        "fields": {
          "values": [
            {
              "name": "glpi_url",
              "stringValue": "https://your_glpi_server.com"
            },
            {
              "name": "app_token",
              "stringValue": "Your App Token is here"
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "37f976d6-bc9e-4bb1-a1a8-c2cd80dc0f21",
      "name": "Send a message to Support Technician 1",
      "type": "n8n-nodes-base.microsoftTeams",
      "position": [
        96,
        416
      ],
      "parameters": {
        "chatId": {
          "__rl": true,
          "mode": "list",
          "value": "19:user@example.com",
          "cachedResultUrl": "https://teams.microsoft.com/l/chat/19%3A9d87b5db-9cfe-4cc5-ab11-b131a06789ff_b3481c22-4337-4a46-aec4-0457bad71345%40unq.gbl.spaces/0?tenantId=84a66816-16ec-48c3-bcea-b62049cde20b",
          "cachedResultName": "Support Technician 1, Integropen Solutions (oneOnOne)"
        },
        "message": "=## Action Required: Ticket about to expire\n\n**Title:** {{ $json['1'] }}\n\n**ID:** {{ $json['2'] }}\n\n**Expires in:** {{ $json['18'] }}",
        "options": {
          "includeLinkToWorkflow": false
        },
        "resource": "chatMessage"
      },
      "credentials": {
        "microsoftTeamsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "ad446521-d997-4563-84f6-30dbd5865622",
      "name": "Send a message to Support Technician 2",
      "type": "n8n-nodes-base.microsoftTeams",
      "position": [
        320,
        608
      ],
      "parameters": {
        "chatId": {
          "__rl": true,
          "mode": "list",
          "value": "19:user@example.com",
          "cachedResultUrl": "https://teams.microsoft.com/l/chat/19%3A57fafa2a-5195-4d52-a389-ef2fb95d75f0_b3481c22-4337-4a46-aec4-0457bad71345%40unq.gbl.spaces/0?tenantId=84a66816-16ec-48c3-bcea-b62049cde20b",
          "cachedResultName": "Support Technician 2, Integropen Solutions (oneOnOne)"
        },
        "message": "=## Action Required: Ticket about to expire\n\n**Title:** {{ $json['1'] }}\n\n**ID:** {{ $json['2'] }}\n\n**Expires in:** {{ $json['18'] }}",
        "options": {
          "includeLinkToWorkflow": false
        },
        "resource": "chatMessage"
      },
      "credentials": {
        "microsoftTeamsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "27036a12-b3ee-4319-b65c-c98bb217897a",
      "name": "Aggregate",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        -128,
        32
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "1f1bb9d4-d8f6-40d2-94ce-ffe727d8c0ef",
      "name": "Tickets about to expire",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -800,
        560
      ],
      "parameters": {
        "url": "={{ $('Configuration Variables').item.json.glpi_url }}/apirest.php/search/Ticket",
        "options": {},
        "sendQuery": true,
        "sendHeaders": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "criteria[0][field]",
              "value": "18"
            },
            {
              "name": "criteria[0][searchtype]",
              "value": "lessthan"
            },
            {
              "name": "criteria[0][value]",
              "value": "={{new Date(Date.now() + (2 * 24 * 60 * 60 * 1000)).toISOString().split('T')[0]}}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "Session-Token",
              "value": "={{ $json.session_token }}"
            },
            {
              "name": "App-Token",
              "value": "={{ $('Configuration Variables').item.json.app_token }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "861d3525-6e45-476d-a00b-fade07e0ded8",
      "name": "Get session token",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1024,
        560
      ],
      "parameters": {
        "url": "={{ $json.glpi_url }}/apirest.php/initSession",
        "options": {},
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBasicAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "App-Token",
              "value": "={{ $json.app_token }}"
            }
          ]
        }
      },
      "credentials": {
        "httpBasicAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "db9e10ea-b03f-4792-b5e7-5b4484a5351c",
      "name": "Support Technician 1?",
      "type": "n8n-nodes-base.if",
      "position": [
        -128,
        320
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "2aae6f0c-eea2-4402-a2dc-d75f946134ee",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json[\"5\"] }}",
              "rightValue": "7"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "097be4cb-3a42-413e-99a1-281c5fbd284b",
      "name": "Support Technician 2?",
      "type": "n8n-nodes-base.if",
      "position": [
        96,
        224
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "6c4e4a5b-7eda-48dd-8b44-cc66715d3399",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json[\"5\"] }}",
              "rightValue": "8"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "9143952e-58bd-40ac-aece-3d718e54674b",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1472,
        560
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 9
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "9a2a292d-4472-4ad2-8c92-ee7ff5989f03",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -352,
        560
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "38834a1f-125c-4aa6-a4e0-63f8fce69d69",
      "name": "Split Out",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        -576,
        560
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "data"
      },
      "typeVersion": 1
    },
    {
      "id": "0f8bf852-c719-49ed-8400-975c74cdd7cd",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2048,
        -32
      ],
      "parameters": {
        "color": 5,
        "width": 720,
        "height": 496,
        "content": "## Requirements:\n- GLPI REST API\n- User with application administrator privileges\n\n- Necessary Changes\n\nUpdate the GLPI server URL in the \"Configuration Variables\" node\n\nglpi_url: \"https://your_glpi_server.com\"\napp_token: \"Your App Token is here\"\n\nGLPI User ID Identification\nFor complete workflow configuration, it's necessary to identify the correct IDs of technical users for proper notification assignment.\nUser IDs can be obtained by accessing user management in GLPI and observing the ID directly in the browser URL when selecting a specific user.\nPath: Administration > Users > [Select User]\nWhen clicking on the desired user, you can see the user ID directly in the browser URL (e.g., id=7 for Support Technician 1, id=8 for Support Technician 2).\n\n- The technician id must be taken into account for IF nodes to redirect to the correct technician in teams."
      },
      "typeVersion": 1
    },
    {
      "id": "ee77c5c3-03b1-47e2-825f-734f386ae613",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1312,
        -32
      ],
      "parameters": {
        "color": 4,
        "width": 976,
        "height": 496,
        "content": "## Tickets about to expire node\n\nThe criteria[0][value] field sets the date range for identifying cases that are close to expiration, allowing a notification to be generated for the technician.\n\nExample:\ncriteria[0][value]: {{new Date(Date.now() + (5 * 24 * 60 * 60 * 1000)).toISOString().split('T')[0]}}\n\nTechnical explanation:\nThe {{new Date(Date.now() + (5 * 24 * 60 * 60 * 1000)).toISOString().split('T')[0]}} value does the following:\n\nDate.now() \u2192 Gets the current date and time in milliseconds.\n\n+ (5 * 24 * 60 * 60 * 1000) \u2192 Adds 5 days (5 days \u00d7 24 hours \u00d7 60 minutes \u00d7 60 seconds \u00d7 1000 ms).\n\nnew Date(...) \u2192 Creates a Date object with that future date.\n\n.toISOString() \u2192 Converts the date to ISO 8601 format (YYYY-MM-DDTHH:mm:ss.sssZ).\n\n.split('T')[0] \u2192 It only keeps the date portion (YYYY-MM-DD) without the time.\n\nIn short: the field automatically generates the date 5 days from today in YYYY-MM-DD format, which will be used as a criterion to filter cases that are about to expire."
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Aggregate": {
      "main": [
        [
          {
            "node": "End session1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "End session1": {
      "main": [
        [
          {
            "node": "No Operation, do nothing2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Support Technician 1?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Configuration Variables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get session token": {
      "main": [
        [
          {
            "node": "Tickets about to expire",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Support Technician 1?": {
      "main": [
        [
          {
            "node": "Send a message to Support Technician 1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Support Technician 2?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Support Technician 2?": {
      "main": [
        [
          {
            "node": "Send a message to Support Technician 2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Configuration Variables": {
      "main": [
        [
          {
            "node": "Get session token",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Tickets about to expire": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "No Operation, do nothing3": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a message to Support Technician 1": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a message to Support Technician 2": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}