{
  "name": "AI Vanguard | Weekly business review",
  "nodes": [
    {
      "id": "070f8a67-f1b3-4841-943d-55c7fe6f9d05",
      "name": "Run sample now",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "parameters": {}
    },
    {
      "id": "e476fee7-b39c-4e37-a7e3-88b318aa91d9",
      "name": "Run on schedule",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.3,
      "position": [
        0,
        180
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 8 * * 1"
            }
          ]
        }
      }
    },
    {
      "id": "ac578205-cdeb-4857-9e97-3e37704147e8",
      "name": "Spreadsheet ID",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        240,
        90
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "7d039b49-a8ca-42fa-a668-1af688546877",
              "name": "spreadsheetId",
              "value": "REPLACE_WITH_YOUR_SHEET_ID",
              "type": "string"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "18c899e3-7d8c-46ec-a012-0e50cfd7702a",
      "name": "Read Input rows",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        480,
        90
      ],
      "parameters": {
        "authentication": "oAuth2",
        "resource": "sheet",
        "operation": "read",
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Spreadsheet ID').first().json.spreadsheetId }}"
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Input"
        },
        "options": {
          "outputFormatting": {
            "values": {
              "general": "UNFORMATTED_VALUE",
              "date": "FORMATTED_STRING"
            }
          }
        }
      }
    },
    {
      "id": "43101c00-6f08-4438-add5-dc469d8a0a2d",
      "name": "Keep exceptions with a case key",
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2.2,
      "position": [
        720,
        90
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "7bca421f-7528-459a-b99e-2696aa58df60",
              "leftValue": "={{ String($json['Case key'] ?? '').trim() }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            },
            {
              "id": "ed8ee7ae-e83f-41e6-a62f-c482f553fa9c",
              "leftValue": "={{ String($json['Exception'] ?? '').trim() }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "a32444be-8be9-4565-b6fd-75f92035bbc4",
      "name": "Normalize the case key",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        960,
        90
      ],
      "parameters": {
        "includeOtherFields": true,
        "assignments": {
          "assignments": [
            {
              "id": "834c0503-1994-4f8f-92d1-6f8dc11bd489",
              "name": "Case key",
              "value": "={{ String($json['Case key']).trim().toLowerCase() }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "c095d046-b6b0-47c8-bd00-0d1be64e9eca",
      "name": "Keep one row per case",
      "type": "n8n-nodes-base.removeDuplicates",
      "typeVersion": 2,
      "position": [
        1200,
        90
      ],
      "parameters": {
        "operation": "removeDuplicateInputItems",
        "compare": "selectedFields",
        "fieldsToCompare": "Case key",
        "options": {}
      }
    },
    {
      "id": "68a2808b-9218-407b-9d0a-2a6814929266",
      "name": "Put exceptions in Review Queue",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        1440,
        90
      ],
      "parameters": {
        "authentication": "oAuth2",
        "resource": "sheet",
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Spreadsheet ID').first().json.spreadsheetId }}"
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Review Queue"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Case key": "={{ String($json['Case key']).trim().toLowerCase() }}",
            "Exception": "={{ $json['Exception'] }}",
            "Evidence": "={{ $json['Evidence'] }}",
            "Owner": "={{ $json['Owner for review'] }}",
            "Next step": "={{ $json['Next step'] }}",
            "Last seen": "={{ $now.toISO() }}"
          },
          "matchingColumns": [
            "Case key"
          ],
          "schema": [
            {
              "id": "Case key",
              "displayName": "Case key",
              "required": false,
              "defaultMatch": true,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Exception",
              "displayName": "Exception",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Evidence",
              "displayName": "Evidence",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Owner",
              "displayName": "Owner",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Next step",
              "displayName": "Next step",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Last seen",
              "displayName": "Last seen",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Review status",
              "displayName": "Review status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Reviewer notes",
              "displayName": "Reviewer notes",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {
          "cellFormat": "RAW",
          "useAppend": true
        }
      }
    }
  ],
  "connections": {
    "Run sample now": {
      "main": [
        [
          {
            "node": "Spreadsheet ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run on schedule": {
      "main": [
        [
          {
            "node": "Spreadsheet ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Spreadsheet ID": {
      "main": [
        [
          {
            "node": "Read Input rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Input rows": {
      "main": [
        [
          {
            "node": "Keep exceptions with a case key",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Keep exceptions with a case key": {
      "main": [
        [
          {
            "node": "Normalize the case key",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize the case key": {
      "main": [
        [
          {
            "node": "Keep one row per case",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Keep one row per case": {
      "main": [
        [
          {
            "node": "Put exceptions in Review Queue",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "timezone": "Asia/Amman",
    "saveManualExecutions": false
  }
}
